1919
2020. ./t/cli/common.sh
2121
22+ rm logs/error.log || true
23+
2224git checkout conf/config.yaml
2325
2426echo '
2527apisix:
2628 worker_startup_time_threshold: 3
29+ nginx_config:
30+ worker_processes: 1
31+ http_configuration_snippet: |
32+ server {
33+ listen 1980;
34+ location /hello {
35+ return 200 "hello world";
36+ }
37+ }
2738' > conf/config.yaml
2839
2940make run
3041
3142sleep 5
3243
44+ admin_key=$( yq ' .deployment.admin.admin_key[0].key' conf/config.yaml | sed ' s/"//g' )
45+ curl -k -i http://127.0.0.1:9180/apisix/admin/routes/1 -H " X-API-KEY: $admin_key " -X PUT -d '
46+ {
47+ "uri": "/hello",
48+ "upstream": {
49+ "nodes": {
50+ "127.0.0.1:1980": 1
51+ },
52+ "scheme": "http",
53+ "type": "roundrobin"
54+ }
55+ }'
56+
57+ sleep 1
58+
59+ code=$( curl -v -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9080/hello)
60+ if [ ! $code -eq 200 ]; then
61+ echo " failed: request failed, http status $code "
62+ exit 1
63+ fi
64+
3365MASTER_PID=$( cat logs/nginx.pid)
3466
35- worker_pids =$( pgrep -P " $MASTER_PID " -f " nginx: worker process" || true)
67+ worker_pid =$( pgrep -P " $MASTER_PID " -f " nginx: worker process" || true)
3668
37- if [ -n " $worker_pids " ]; then
38- pid=$( echo " $worker_pids " | shuf -n 1)
39- echo " killing worker $pid (master $MASTER_PID )"
40- kill " $pid "
69+ if [ -n " $worker_pid " ]; then
70+ echo " killing worker $worker_pid (master $MASTER_PID )"
71+ kill " $worker_pid "
4172else
4273 echo " failed: no worker process found for master $MASTER_PID "
4374 exit 1
@@ -50,6 +81,17 @@ if ! grep 'master process has been running for a long time, reloading the full c
5081 exit 1
5182fi
5283
84+ if grep ' API disabled in the context of init_worker_by_lua' logs/error.log; then
85+ echo " failed: cannot access etcd in init_worker phase"
86+ exit 1
87+ fi
88+
89+ code=$( curl -v -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9080/hello)
90+ if [ ! $code -eq 200 ]; then
91+ echo " failed: request failed for new worker, http status $code "
92+ exit 1
93+ fi
94+
5395echo " passed: load full configuration for new worker"
5496
5597make stop
0 commit comments