Skip to content

Commit

Permalink
feat(makefile): update test-nginx to support run specific case
Browse files Browse the repository at this point in the history
  • Loading branch information
wklken committed Nov 7, 2024
1 parent c6aa2df commit 7e66678
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/apisix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ test-busted:
-v ${ROOT_DIR}/plugins:/bkgateway/apisix/plugins \
apisix-test-busted "/run-test-busted.sh"

# make test-nginx
# make test-nginx CASE_FILE=bk-traffic-label.t
.PHONY: test-nginx
test-nginx:
@docker run --rm ${RUN_WITH_IT} \
-v ${ROOT_DIR}/t:/bkgateway/t/ \
-v ${ROOT_DIR}/plugins:/bkgateway/apisix/plugins \
apisix-test-nginx "/run-test-nginx.sh"
apisix-test-nginx "/run-test-nginx.sh" $(if $(CASE_FILE),$(CASE_FILE))

.PHONY: apisix-test-images
apisix-test-images: apisix-test-busted apisix-test-nginx
Expand Down
7 changes: 6 additions & 1 deletion src/apisix/ci/run-test-nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,10 @@ export OPENRESTY_PREFIX="/usr/local/openresty-debug"
export APISIX_MAIN="https://raw.githubusercontent.com/apache/incubator-apisix/master/rockspec/apisix-master-0.rockspec"
export PATH=$OPENRESTY_PREFIX/nginx/sbin:$OPENRESTY_PREFIX/luajit/bin:$OPENRESTY_PREFIX/bin:$PATH

FLUSH_ETCD=1 prove --timer -Itest-nginx/lib -I./ t/bk-*.t
if [ -n "$1" ]; then
CASE_FILE=$1
FLUSH_ETCD=1 prove --timer -Itest-nginx/lib -I./ t/bk-00.t t/$CASE_FILE
else
FLUSH_ETCD=1 prove --timer -Itest-nginx/lib -I./ t/bk-*.t
fi

54 changes: 54 additions & 0 deletions src/apisix/t/bk-00.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# TencentBlueKing is pleased to support the open source community by making
# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available.
# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
# Licensed under the MIT License (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://opensource.org/licenses/MIT
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific language governing permissions and
# limitations under the License.
#
# We undertake not to change the open source license (MIT license) applicable
# to the current version of the project delivered to anyone in the future.
#

# NOTE: this file should be ran as the first test file
# otherwise other test files would fail

use t::APISIX 'no_plan';

repeat_each(1);
no_long_string();
no_root_location();
no_shuffle();

add_block_preprocessor(sub {
my ($block) = @_;

if (!defined $block->request) {
$block->set_value("request", "GET /t");
}
});

run_tests;

__DATA__
=== TEST 1: sanity
--- config
location /t {
content_by_lua_block {
local ok = true
if not ok then
ngx.say(err)
end
ngx.say("done")
}
}
--- response_body
done
1 change: 1 addition & 0 deletions src/apisix/t/bk-traffic-label.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#

# TencentBlueKing is pleased to support the open source community by making
# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available.
# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
Expand Down

0 comments on commit 7e66678

Please sign in to comment.