From b42dfd01f140485ff95896e30761c09b29b61235 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Wed, 17 Aug 2022 12:46:02 -0700 Subject: [PATCH] test for growth of compressed pipelined responses add a test to compare the Content-Length of successive compressed messages on a single HTTP connection that should contain the same data; fail if the size grows by more than 100 bytes from one query to the next. (cherry picked from commit 3c11fafadfa5024d965bdcc5c80f225625af7b16) --- bin/tests/system/statschannel/tests.sh | 33 ++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/bin/tests/system/statschannel/tests.sh b/bin/tests/system/statschannel/tests.sh index fe56e16227..8bc2a331fe 100644 --- a/bin/tests/system/statschannel/tests.sh +++ b/bin/tests/system/statschannel/tests.sh @@ -408,9 +408,9 @@ else echo_i "skipping test as nc not found" fi +echo_i "Check HTTP/1.1 pipelined requests are handled (POST) ($n)" +ret=0 if [ -x "${NC}" ] ; then - echo_i "Check HTTP/1.1 pipelined requests are handled (POST) ($n)" - ret=0 ${NC} 10.53.0.3 ${EXTRAPORT1} << EOF > nc.out$n || ret=1 POST /xml/v3/status HTTP/1.1 Host: 10.53.0.3:${EXTRAPORT1} @@ -428,12 +428,12 @@ Connection: close EOF lines=$(grep "^HTTP/1.1" nc.out$n | wc -l) test $lines = 2 || ret=1 - if [ $ret != 0 ]; then echo_i "failed"; fi - status=$((status + ret)) - n=$((n + 1)) else echo_i "skipping test as nc not found" fi +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) echo_i "Check HTTP/1.1 pipelined with truncated stream ($n)" ret=0 @@ -462,5 +462,28 @@ if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status + ret)) n=$((n + 1)) +echo_i "Check pipelined responses do not grow excessively ($n)" +ret=0 +i=0 +if [ -x "${NC}" ] ; then + { + while test $i -lt 10; do + printf "GET /json/v1 HTTP/1.1\r\nHost: 10.53.0.3:%s\r\nAccept-Encoding: deflate, gzip, br, zstd\r\n\r\n" "${EXTRAPORT1}" + i=$((i + 1)) + done + } | ${NC} 10.53.0.3 ${EXTRAPORT1} | grep -a Content-Length | + awk 'BEGIN { prev=0; } + { if (prev != 0 && $2 - prev > 100) { + exit(1); + } + prev = $2; + }' || ret=1 +else + echo_i "skipping test as nc not found" +fi +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) +n=$((n + 1)) + echo_i "exit status: $status" [ $status -eq 0 ] || exit 1