Skip to content

Commit 7e66678

Browse files
committed
feat(makefile): update test-nginx to support run specific case
1 parent c6aa2df commit 7e66678

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

src/apisix/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ test-busted:
2020
-v ${ROOT_DIR}/plugins:/bkgateway/apisix/plugins \
2121
apisix-test-busted "/run-test-busted.sh"
2222

23+
# make test-nginx
24+
# make test-nginx CASE_FILE=bk-traffic-label.t
2325
.PHONY: test-nginx
2426
test-nginx:
2527
@docker run --rm ${RUN_WITH_IT} \
2628
-v ${ROOT_DIR}/t:/bkgateway/t/ \
2729
-v ${ROOT_DIR}/plugins:/bkgateway/apisix/plugins \
28-
apisix-test-nginx "/run-test-nginx.sh"
30+
apisix-test-nginx "/run-test-nginx.sh" $(if $(CASE_FILE),$(CASE_FILE))
2931

3032
.PHONY: apisix-test-images
3133
apisix-test-images: apisix-test-busted apisix-test-nginx

src/apisix/ci/run-test-nginx.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,10 @@ export OPENRESTY_PREFIX="/usr/local/openresty-debug"
7171
export APISIX_MAIN="https://raw.githubusercontent.com/apache/incubator-apisix/master/rockspec/apisix-master-0.rockspec"
7272
export PATH=$OPENRESTY_PREFIX/nginx/sbin:$OPENRESTY_PREFIX/luajit/bin:$OPENRESTY_PREFIX/bin:$PATH
7373

74-
FLUSH_ETCD=1 prove --timer -Itest-nginx/lib -I./ t/bk-*.t
74+
if [ -n "$1" ]; then
75+
CASE_FILE=$1
76+
FLUSH_ETCD=1 prove --timer -Itest-nginx/lib -I./ t/bk-00.t t/$CASE_FILE
77+
else
78+
FLUSH_ETCD=1 prove --timer -Itest-nginx/lib -I./ t/bk-*.t
79+
fi
7580

src/apisix/t/bk-00.t

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#
2+
# TencentBlueKing is pleased to support the open source community by making
3+
# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available.
4+
# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
5+
# Licensed under the MIT License (the "License"); you may not use this file except
6+
# in compliance with the License. You may obtain a copy of the License at
7+
#
8+
# http://opensource.org/licenses/MIT
9+
#
10+
# Unless required by applicable law or agreed to in writing, software distributed under
11+
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
12+
# either express or implied. See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# We undertake not to change the open source license (MIT license) applicable
16+
# to the current version of the project delivered to anyone in the future.
17+
#
18+
19+
# NOTE: this file should be ran as the first test file
20+
# otherwise other test files would fail
21+
22+
use t::APISIX 'no_plan';
23+
24+
repeat_each(1);
25+
no_long_string();
26+
no_root_location();
27+
no_shuffle();
28+
29+
add_block_preprocessor(sub {
30+
my ($block) = @_;
31+
32+
if (!defined $block->request) {
33+
$block->set_value("request", "GET /t");
34+
}
35+
});
36+
37+
run_tests;
38+
39+
__DATA__
40+
41+
=== TEST 1: sanity
42+
--- config
43+
location /t {
44+
content_by_lua_block {
45+
local ok = true
46+
if not ok then
47+
ngx.say(err)
48+
end
49+
50+
ngx.say("done")
51+
}
52+
}
53+
--- response_body
54+
done

src/apisix/t/bk-traffic-label.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#
2+
23
# TencentBlueKing is pleased to support the open source community by making
34
# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available.
45
# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.

0 commit comments

Comments
 (0)