2020-02-09 20:57:13 +08:00
|
|
|
#!/usr/bin/env bash
|
2020-02-09 17:19:45 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright ownership.
|
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
# (the "License"); you may not use this file except in compliance with
|
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
2020-02-18 12:40:15 +08:00
|
|
|
# 'make init' operates scripts and related configuration files in the current directory
|
|
|
|
# The 'apisix' command is a command in the /usr/local/apisix,
|
|
|
|
# and the configuration file for the operation is in the /usr/local/apisix/conf
|
|
|
|
|
2021-03-12 00:02:02 +08:00
|
|
|
. ./t/cli/common.sh
|
2020-11-17 18:00:30 +08:00
|
|
|
|
2020-06-10 11:32:52 +08:00
|
|
|
git checkout conf/config.yaml
|
|
|
|
|
2020-08-15 17:19:35 +08:00
|
|
|
# check 'Server: APISIX' is not in nginx.conf. We already added it in Lua code.
|
|
|
|
make init
|
|
|
|
|
|
|
|
if grep "Server: APISIX" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: 'Server: APISIX' should not be added twice"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: 'Server: APISIX' not in nginx.conf"
|
|
|
|
|
2020-08-26 14:19:46 +08:00
|
|
|
#make init <- no need to re-run since we don't change the config yet.
|
|
|
|
|
|
|
|
# check the error_log directive uses warn level by default.
|
|
|
|
if ! grep "error_log logs/error.log warn;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: error_log directive doesn't use warn level by default"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: error_log directive uses warn level by default"
|
|
|
|
|
2020-02-18 12:40:15 +08:00
|
|
|
# check whether the 'reuseport' is in nginx.conf .
|
|
|
|
|
|
|
|
grep -E "listen 9080.*reuseport" conf/nginx.conf > /dev/null
|
|
|
|
if [ ! $? -eq 0 ]; then
|
2020-02-09 17:19:45 +08:00
|
|
|
echo "failed: nginx.conf file is missing reuseport configuration"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-02-18 12:40:15 +08:00
|
|
|
echo "passed: nginx.conf file contains reuseport configuration"
|
|
|
|
|
|
|
|
# check default ssl port
|
2020-08-18 20:18:55 +08:00
|
|
|
echo "
|
|
|
|
apisix:
|
|
|
|
ssl:
|
|
|
|
listen_port: 8443
|
|
|
|
" > conf/config.yaml
|
2020-02-18 12:40:15 +08:00
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
grep "listen 8443 ssl" conf/nginx.conf > /dev/null
|
|
|
|
if [ ! $? -eq 0 ]; then
|
|
|
|
echo "failed: failed to update ssl port"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep "listen \[::\]:8443 ssl" conf/nginx.conf > /dev/null
|
|
|
|
if [ ! $? -eq 0 ]; then
|
|
|
|
echo "failed: failed to update ssl port"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: change default ssl port"
|
2020-03-26 09:48:18 +08:00
|
|
|
|
2020-10-17 17:44:26 +08:00
|
|
|
# check support multiple ports listen in http and https
|
|
|
|
|
|
|
|
echo "
|
|
|
|
apisix:
|
|
|
|
node_listen:
|
|
|
|
- 9080
|
|
|
|
- 9081
|
|
|
|
- 9082
|
|
|
|
ssl:
|
|
|
|
listen_port:
|
|
|
|
- 9443
|
|
|
|
- 9444
|
|
|
|
- 9445
|
|
|
|
" > conf/config.yaml
|
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
count_http_ipv4=`grep -c "listen 908." conf/nginx.conf || true`
|
|
|
|
if [ $count_http_ipv4 -ne 3 ]; then
|
|
|
|
echo "failed: failed to support multiple ports listen in http with ipv4"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
count_http_ipv6=`grep -c "listen \[::\]:908." conf/nginx.conf || true`
|
|
|
|
if [ $count_http_ipv6 -ne 3 ]; then
|
|
|
|
echo "failed: failed to support multiple ports listen in http with ipv6"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
count_https_ipv4=`grep -c "listen 944. ssl" conf/nginx.conf || true`
|
|
|
|
if [ $count_https_ipv4 -ne 3 ]; then
|
|
|
|
echo "failed: failed to support multiple ports listen in https with ipv4"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
count_https_ipv6=`grep -c "listen \[::\]:944. ssl" conf/nginx.conf || true`
|
|
|
|
if [ $count_https_ipv6 -ne 3 ]; then
|
|
|
|
echo "failed: failed to support multiple ports listen in https with ipv6"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: support multiple ports listen in http and https"
|
|
|
|
|
2020-09-14 18:12:29 +08:00
|
|
|
# check default env
|
|
|
|
echo "
|
|
|
|
nginx_config:
|
|
|
|
envs:
|
|
|
|
- TEST
|
|
|
|
" > conf/config.yaml
|
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
grep "env TEST;" conf/nginx.conf > /dev/null
|
|
|
|
if [ ! $? -eq 0 ]; then
|
|
|
|
echo "failed: failed to update env"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: change default env"
|
|
|
|
|
2020-11-14 19:39:29 +08:00
|
|
|
# support environment variables
|
|
|
|
echo '
|
|
|
|
nginx_config:
|
|
|
|
envs:
|
|
|
|
- ${{var_test}}_${{FOO}}
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
var_test=TEST FOO=bar make init
|
|
|
|
|
|
|
|
if ! grep "env TEST_bar;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: failed to resolve variables"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-12-10 15:48:47 +08:00
|
|
|
out=$(make init 2>&1 || true)
|
|
|
|
if ! echo "$out" | grep "can't find environment variable"; then
|
|
|
|
echo "failed: failed to resolve variables"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-11-14 19:39:29 +08:00
|
|
|
echo "passed: resolve variables"
|
|
|
|
|
|
|
|
echo '
|
|
|
|
nginx_config:
|
|
|
|
worker_rlimit_nofile: ${{nofile9}}
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
nofile9=99999 make init
|
|
|
|
|
|
|
|
if ! grep "worker_rlimit_nofile 99999;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: failed to resolve variables as integer"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: resolve variables as integer"
|
|
|
|
|
|
|
|
echo '
|
|
|
|
apisix:
|
|
|
|
enable_admin: ${{admin}}
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
admin=false make init
|
|
|
|
|
|
|
|
if grep "location /apisix/admin" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: failed to resolve variables as boolean"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: resolve variables as boolean"
|
|
|
|
|
2020-11-24 16:06:11 +08:00
|
|
|
echo '
|
|
|
|
nginx_config:
|
|
|
|
envs:
|
|
|
|
- ${{ var_test}}_${{ FOO }}
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
var_test=TEST FOO=bar make init
|
|
|
|
|
|
|
|
if ! grep "env TEST_bar;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: failed to resolve variables wrapped with whitespace"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: resolve variables wrapped with whitespace"
|
|
|
|
|
2020-12-10 15:48:47 +08:00
|
|
|
# support environment variables in local_conf
|
|
|
|
echo '
|
|
|
|
etcd:
|
|
|
|
host:
|
|
|
|
- "http://${{ETCD_HOST}}:${{ETCD_PORT}}"
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
ETCD_HOST=127.0.0.1 ETCD_PORT=2379 make init
|
|
|
|
|
|
|
|
if ! grep "env ETCD_HOST=127.0.0.1;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: support environment variables in local_conf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# don't override user's envs configuration
|
|
|
|
echo '
|
|
|
|
etcd:
|
|
|
|
host:
|
|
|
|
- "http://${{ETCD_HOST}}:${{ETCD_PORT}}"
|
|
|
|
nginx_config:
|
|
|
|
envs:
|
|
|
|
- ETCD_HOST
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
ETCD_HOST=127.0.0.1 ETCD_PORT=2379 make init
|
|
|
|
|
|
|
|
if grep "env ETCD_HOST=127.0.0.1;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: support environment variables in local_conf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep "env ETCD_HOST;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: support environment variables in local_conf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo '
|
|
|
|
etcd:
|
|
|
|
host:
|
|
|
|
- "http://${{ETCD_HOST}}:${{ETCD_PORT}}"
|
|
|
|
nginx_config:
|
|
|
|
envs:
|
|
|
|
- ETCD_HOST=1.1.1.1
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
ETCD_HOST=127.0.0.1 ETCD_PORT=2379 make init
|
|
|
|
|
|
|
|
if grep "env ETCD_HOST=127.0.0.1;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: support environment variables in local_conf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep "env ETCD_HOST=1.1.1.1;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: support environment variables in local_conf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "pass: support environment variables in local_conf"
|
|
|
|
|
|
|
|
# support merging worker_processes
|
|
|
|
echo '
|
|
|
|
nginx_config:
|
|
|
|
worker_processes: 1
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
if ! grep "worker_processes 1;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: failed to merge worker_processes"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo '
|
|
|
|
nginx_config:
|
|
|
|
worker_processes: ${{nproc}}
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
nproc=1 make init
|
|
|
|
|
|
|
|
if ! grep "worker_processes 1;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: failed to merge worker_processes"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo '
|
|
|
|
nginx_config:
|
|
|
|
worker_processes: true
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
out=$(make init 2>&1 || true)
|
|
|
|
if ! echo "$out" | grep 'path\[nginx_config->worker_processes\] expect'; then
|
|
|
|
echo "failed: failed to merge worker_processes"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo '
|
|
|
|
nginx_config:
|
|
|
|
worker_processes: ${{nproc}}
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
out=$(nproc=false make init 2>&1 || true)
|
|
|
|
if ! echo "$out" | grep 'path\[nginx_config->worker_processes\] expect'; then
|
|
|
|
echo "failed: failed to merge worker_processes"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: merge worker_processes"
|
|
|
|
|
2020-03-26 09:48:18 +08:00
|
|
|
# check nameserver imported
|
2020-08-18 20:18:55 +08:00
|
|
|
git checkout conf/config.yaml
|
2020-03-26 09:48:18 +08:00
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
i=`grep -E '^nameserver[[:space:]]+(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4]0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])[[:space:]]?$' /etc/resolv.conf | awk '{print $2}'`
|
|
|
|
for ip in $i
|
|
|
|
do
|
|
|
|
echo $ip
|
|
|
|
grep $ip conf/nginx.conf > /dev/null
|
|
|
|
if [ ! $? -eq 0 ]; then
|
|
|
|
echo "failed: system DNS "$ip" unimported"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "passed: system nameserver imported"
|
2020-06-07 21:02:50 +08:00
|
|
|
|
2020-06-10 11:32:52 +08:00
|
|
|
# enable enable_dev_mode
|
2020-08-18 20:18:55 +08:00
|
|
|
git checkout conf/config.yaml
|
|
|
|
|
|
|
|
echo "
|
|
|
|
apisix:
|
|
|
|
enable_dev_mode: true
|
|
|
|
" > conf/config.yaml
|
2020-06-10 11:32:52 +08:00
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
count=`grep -c "worker_processes 1;" conf/nginx.conf`
|
|
|
|
if [ $count -ne 1 ]; then
|
|
|
|
echo "failed: worker_processes is not 1 when enable enable_dev_mode"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
count=`grep -c "listen 9080.*reuseport" conf/nginx.conf || true`
|
|
|
|
if [ $count -ne 0 ]; then
|
|
|
|
echo "failed: reuseport should be disabled when enable enable_dev_mode"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-08-18 20:18:55 +08:00
|
|
|
echo "passed: enable enable_dev_mode"
|
|
|
|
|
|
|
|
# check whether the 'worker_cpu_affinity' is in nginx.conf
|
2020-06-10 11:32:52 +08:00
|
|
|
|
2020-08-18 20:18:55 +08:00
|
|
|
git checkout conf/config.yaml
|
2020-06-09 20:44:15 +08:00
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
grep -E "worker_cpu_affinity" conf/nginx.conf > /dev/null
|
|
|
|
if [ ! $? -eq 0 ]; then
|
|
|
|
echo "failed: nginx.conf file is missing worker_cpu_affinity configuration"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: nginx.conf file contains worker_cpu_affinity configuration"
|
|
|
|
|
2020-07-24 16:05:29 +08:00
|
|
|
# check the 'worker_shutdown_timeout' in 'nginx.conf' .
|
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
grep -E "worker_shutdown_timeout 240s" conf/nginx.conf > /dev/null
|
|
|
|
if [ ! $? -eq 0 ]; then
|
|
|
|
echo "failed: worker_shutdown_timeout in nginx.conf is required 240s"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: worker_shutdown_timeout in nginx.conf is ok"
|
2020-08-07 17:25:26 +08:00
|
|
|
|
2020-09-15 21:58:30 +08:00
|
|
|
# check the 'client_max_body_size' in 'nginx.conf' .
|
|
|
|
|
2020-10-17 19:26:48 +08:00
|
|
|
git checkout conf/config.yaml
|
2020-11-17 18:00:30 +08:00
|
|
|
|
|
|
|
echo '
|
|
|
|
nginx_config:
|
|
|
|
http:
|
|
|
|
client_max_body_size: 512m
|
|
|
|
' > conf/config.yaml
|
2020-09-15 21:58:30 +08:00
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
if ! grep -E "client_max_body_size 512m" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: client_max_body_size in nginx.conf doesn't change"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: client_max_body_size in nginx.conf is ok"
|
|
|
|
|
2020-08-07 17:25:26 +08:00
|
|
|
# check worker processes number is configurable.
|
|
|
|
|
2020-08-18 20:18:55 +08:00
|
|
|
git checkout conf/config.yaml
|
|
|
|
|
|
|
|
echo "
|
|
|
|
nginx_config:
|
|
|
|
worker_processes: 2
|
|
|
|
" > conf/config.yaml
|
2020-08-07 17:25:26 +08:00
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
grep "worker_processes 2;" conf/nginx.conf > /dev/null
|
|
|
|
if [ ! $? -eq 0 ]; then
|
|
|
|
echo "failed: worker_processes in nginx.conf doesn't change"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
sed -i 's/worker_processes: 2/worker_processes: auto/' conf/config.yaml
|
|
|
|
echo "passed: worker_processes number is configurable"
|
2020-08-26 16:51:44 +08:00
|
|
|
|
2021-01-29 11:19:46 +08:00
|
|
|
# check customized config.yaml is copied and reverted.
|
|
|
|
|
|
|
|
git checkout conf/config.yaml
|
|
|
|
|
|
|
|
echo "
|
|
|
|
apisix:
|
|
|
|
admin_api_mtls:
|
|
|
|
admin_ssl_cert: '../t/certs/apisix_admin_ssl.crt'
|
|
|
|
admin_ssl_cert_key: '../t/certs/apisix_admin_ssl.key'
|
|
|
|
port_admin: 9180
|
|
|
|
https_admin: true
|
|
|
|
" > conf/customized_config.yaml
|
|
|
|
|
|
|
|
cp conf/config.yaml conf/config_original.yaml
|
|
|
|
|
|
|
|
make init
|
|
|
|
|
2021-06-01 08:55:06 +08:00
|
|
|
if ./bin/apisix start -c conf/not_existed_config.yaml; then
|
|
|
|
echo "failed: apisix still start with invalid customized config.yaml"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-01-29 11:19:46 +08:00
|
|
|
./bin/apisix start -c conf/customized_config.yaml
|
|
|
|
|
|
|
|
if cmp -s "conf/config.yaml" "conf/config_original.yaml"; then
|
2021-02-23 11:34:49 +08:00
|
|
|
rm conf/config_original.yaml
|
2021-01-29 11:19:46 +08:00
|
|
|
echo "failed: customized config.yaml copied failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
code=$(curl -k -i -m 20 -o /dev/null -s -w %{http_code} https://127.0.0.1:9180/apisix/admin/routes -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1')
|
|
|
|
if [ ! $code -eq 200 ]; then
|
2021-02-23 11:34:49 +08:00
|
|
|
rm conf/config_original.yaml conf/customized_config.yaml
|
2021-01-29 11:19:46 +08:00
|
|
|
echo "failed: customized config.yaml not be used"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
make stop
|
|
|
|
|
|
|
|
if ! cmp -s "conf/config.yaml" "conf/config_original.yaml"; then
|
2021-02-23 11:34:49 +08:00
|
|
|
rm conf/config_original.yaml conf/customized_config.yaml
|
2021-01-29 11:19:46 +08:00
|
|
|
echo "failed: customized config.yaml reverted failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-02-23 11:34:49 +08:00
|
|
|
rm conf/config_original.yaml conf/customized_config.yaml
|
2021-01-29 11:19:46 +08:00
|
|
|
echo "passed: customized config.yaml copied and reverted succeeded"
|
|
|
|
|
2020-10-21 09:59:45 +08:00
|
|
|
# allow to merge configuration without middle layer
|
|
|
|
|
|
|
|
git checkout conf/config.yaml
|
|
|
|
|
|
|
|
echo '
|
|
|
|
nginx_config:
|
|
|
|
http:
|
|
|
|
lua_shared_dicts:
|
|
|
|
my_dict: 1m
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
if ! grep "lua_shared_dict my_dict 1m;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: 'my_dict' not in nginx.conf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: found 'my_dict' in nginx.conf"
|
2020-10-22 16:28:26 +08:00
|
|
|
|
|
|
|
# check disable cpu affinity
|
|
|
|
git checkout conf/config.yaml
|
|
|
|
|
|
|
|
echo '
|
|
|
|
nginx_config:
|
|
|
|
enable_cpu_affinity: false
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
count=`grep -c "worker_cpu_affinity" conf/nginx.conf || true`
|
|
|
|
if [ $count -ne 0 ]; then
|
|
|
|
echo "failed: nginx.conf file found worker_cpu_affinity when disable it"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: nginx.conf file disable cpu affinity"
|
|
|
|
|
|
|
|
# set worker processes with env
|
|
|
|
git checkout conf/config.yaml
|
|
|
|
|
2020-10-30 08:14:04 +08:00
|
|
|
export APISIX_WORKER_PROCESSES=8
|
2020-10-22 16:28:26 +08:00
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
count=`grep -c "worker_processes 8;" conf/nginx.conf || true`
|
|
|
|
if [ $count -ne 1 ]; then
|
|
|
|
echo "failed: worker_processes is not 8 when using env to set worker processes"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: using env to set worker processes"
|
2020-10-30 16:07:24 +08:00
|
|
|
|
2020-11-09 22:44:26 +08:00
|
|
|
# set worker processes with env
|
|
|
|
git checkout conf/config.yaml
|
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
count=`grep -c "ssl_session_tickets off;" conf/nginx.conf || true `
|
|
|
|
if [ $count -eq 0 ]; then
|
|
|
|
echo "failed: ssl_session_tickets is off when ssl.ssl_session_tickets is false."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-11-17 18:00:30 +08:00
|
|
|
echo '
|
|
|
|
apisix:
|
|
|
|
ssl:
|
|
|
|
ssl_session_tickets: true
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
2020-11-09 22:44:26 +08:00
|
|
|
make init
|
|
|
|
|
|
|
|
count=`grep -c "ssl_session_tickets on;" conf/nginx.conf || true `
|
|
|
|
if [ $count -eq 0 ]; then
|
|
|
|
echo "failed: ssl_session_tickets is on when ssl.ssl_session_tickets is true."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: disable ssl_session_tickets by default"
|
|
|
|
|
2021-01-27 14:45:32 +08:00
|
|
|
# support 3rd-party plugin
|
|
|
|
echo '
|
|
|
|
apisix:
|
|
|
|
extra_lua_path: "\$prefix/example/?.lua"
|
|
|
|
extra_lua_cpath: "\$prefix/example/?.lua"
|
|
|
|
plugins:
|
|
|
|
- 3rd-party
|
|
|
|
stream_plugins:
|
|
|
|
- 3rd-party
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
rm logs/error.log
|
|
|
|
make init
|
|
|
|
make run
|
|
|
|
|
|
|
|
sleep 0.5
|
|
|
|
make stop
|
|
|
|
|
|
|
|
if grep "failed to load plugin [3rd-party]" logs/error.log > /dev/null; then
|
|
|
|
echo "failed: 3rd-party plugin can not be loaded"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "passed: 3rd-party plugin can be loaded"
|
2021-01-27 22:36:35 +08:00
|
|
|
|
|
|
|
# validate extra_lua_path
|
|
|
|
echo '
|
|
|
|
apisix:
|
|
|
|
extra_lua_path: ";"
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
out=$(make init 2>&1 || true)
|
|
|
|
if ! echo "$out" | grep 'invalid extra_lua_path'; then
|
|
|
|
echo "failed: can't detect invalid extra_lua_path"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: detect invalid extra_lua_path"
|
|
|
|
|
|
|
|
# check restart with old nginx.pid exist
|
|
|
|
echo "-1" > logs/nginx.pid
|
|
|
|
out=$(./bin/apisix start 2>&1 || true)
|
|
|
|
if echo "$out" | grep "APISIX is running"; then
|
2021-02-23 11:34:49 +08:00
|
|
|
rm logs/nginx.pid
|
2021-01-27 22:36:35 +08:00
|
|
|
echo "failed: should ignore stale nginx.pid"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-02-23 11:34:49 +08:00
|
|
|
rm logs/nginx.pid
|
2021-01-27 22:36:35 +08:00
|
|
|
echo "pass: ignore stale nginx.pid"
|
2021-05-18 14:28:30 +08:00
|
|
|
|
|
|
|
# check the keepalive related parameter settings in the upstream
|
|
|
|
git checkout conf/config.yaml
|
|
|
|
|
|
|
|
echo '
|
|
|
|
nginx_config:
|
|
|
|
http:
|
|
|
|
upstream:
|
|
|
|
keepalive: 32
|
|
|
|
keepalive_requests: 100
|
|
|
|
keepalive_timeout: 6s
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
if ! grep "keepalive 32;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: 'keepalive 32;' not in nginx.conf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep "keepalive_requests 100;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: 'keepalive_requests 100;' not in nginx.conf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep "keepalive_timeout 6s;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: 'keepalive_timeout 6s;' not in nginx.conf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: found the keepalive related parameter in nginx.conf"
|
2021-05-28 18:07:30 +08:00
|
|
|
|
|
|
|
# check the charset setting
|
|
|
|
git checkout conf/config.yaml
|
|
|
|
|
|
|
|
echo '
|
|
|
|
nginx_config:
|
|
|
|
http:
|
|
|
|
charset: gbk
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
if ! grep "charset gbk;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: 'charset gbk;' not in nginx.conf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: found the 'charset gbk;' in nginx.conf"
|
2021-05-31 08:54:42 +08:00
|
|
|
|
|
|
|
# check realip recursive setting
|
|
|
|
git checkout conf/config.yaml
|
|
|
|
|
|
|
|
echo '
|
|
|
|
nginx_config:
|
|
|
|
http:
|
|
|
|
real_ip_recursive: "on"
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
if ! grep "real_ip_recursive on;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: 'real_ip_recursive on;' not in nginx.conf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: found 'real_ip_recursive on' in nginx.conf"
|
2021-05-31 19:06:39 +08:00
|
|
|
|
|
|
|
# check the variables_hash_max_size setting
|
|
|
|
git checkout conf/config.yaml
|
|
|
|
|
|
|
|
echo '
|
|
|
|
nginx_config:
|
|
|
|
http:
|
|
|
|
variables_hash_max_size: 1024
|
|
|
|
' > conf/config.yaml
|
|
|
|
|
|
|
|
make init
|
|
|
|
|
|
|
|
if ! grep "variables_hash_max_size 1024;" conf/nginx.conf > /dev/null; then
|
|
|
|
echo "failed: 'variables_hash_max_size 1024;' not in nginx.conf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "passed: found the 'variables_hash_max_size 1024;' in nginx.conf"
|