From 43ec2e56861ac5f9ff98e305c581732640ee10ca Mon Sep 17 00:00:00 2001
From: Bisakh Mondal <bisakhmondal00@gmail.com>
Date: Fri, 10 Dec 2021 22:28:53 +0530
Subject: [PATCH] shell tests

---
 t/cli/test_access_log.sh | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/t/cli/test_access_log.sh b/t/cli/test_access_log.sh
index 8e79b009f405..fa2dc8134497 100755
--- a/t/cli/test_access_log.sh
+++ b/t/cli/test_access_log.sh
@@ -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