Skip to content

Commit

Permalink
shell tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bisakhmondal committed Dec 10, 2021
1 parent 8ff645f commit 43ec2e5
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions t/cli/test_access_log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,41 @@ fi

make stop
echo "passed: should find upstream scheme"

# check stream logs
echo '
apisix:
stream_proxy: # UDP proxy
udp:
- "127.0.0.1:9200"
nginx_config:
stream:
enable_access_log: true
access_log_format: "$remote_addr $protocol test_stream_access_log_format"
' > conf/config.yaml

make init

grep "test_stream_access_log_format" conf/nginx.conf > /dev/null
if [ ! $? -eq 0 ]; then
echo "failed: stream access_log_format in nginx.conf doesn't change"
exit 1
fi

# check if logs are being written
make run
sleep 0.1
# sending single udp packet
echo -n "hello" | nc -4u -w0 localhost 9200
sleep 4
tail -n 1 logs/access_stream.log > output.log

if ! grep '127.0.0.1 UDP test_stream_access_log_format' output.log; then
echo "failed: should have found udp log entry"
cat output.log
exit 1
fi

make stop
git checkout conf/config.yaml

0 comments on commit 43ec2e5

Please sign in to comment.