about summary refs log tree commit homepage
path: root/t/t0008-ensure-usable-after-limit.sh
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-11 15:21:32 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-11 15:46:58 -0800
commit0f68fbf889568ee38828301f403b7284bac2b63a (patch)
tree79483242922e6e6a36e6194c540bd80a9cd035b3 /t/t0008-ensure-usable-after-limit.sh
parent8c104a8a9e341aaaa36bd270cf48ded2f479f5a0 (diff)
downloadrainbows-0f68fbf889568ee38828301f403b7284bac2b63a.tar.gz
Make sure any aborted/broken clients don't screw up
our connection accounting.
Diffstat (limited to 't/t0008-ensure-usable-after-limit.sh')
-rwxr-xr-xt/t0008-ensure-usable-after-limit.sh105
1 files changed, 104 insertions, 1 deletions
diff --git a/t/t0008-ensure-usable-after-limit.sh b/t/t0008-ensure-usable-after-limit.sh
index d5c2e79..ce15f3b 100755
--- a/t/t0008-ensure-usable-after-limit.sh
+++ b/t/t0008-ensure-usable-after-limit.sh
@@ -1,7 +1,8 @@
 #!/bin/sh
 . ./test-lib.sh
+test -r random_blob || die "random_blob required, run with 'make $0'"
 
-t_plan 6 "ensure we're accounting worker_connections properly"
+t_plan 14 "ensure we're accounting worker_connections properly"
 nr=2
 
 t_begin "setup" && {
@@ -71,6 +72,108 @@ t_begin "check results" && {
         done
 }
 
+t_begin "fire off truncated concurrent requests" && {
+
+        req='POST / HTTP/1.1\r\n'
+        req="$req"'Host: example.com\r\n'
+        req="$req"'Transfer-Encoding: chunked\r\n'
+
+        for i in a b c d
+        do
+                rtmpfiles ${i}_tmp
+                eval 'i_tmp=$'${i}_tmp
+                eval "i=$"$i
+                (
+                        (
+                                # need a full HTTP request to get around
+                                # httpready
+                                printf "$req"
+                                echo ok > $i
+                        ) | socat - TCP:$listen > $i_tmp
+                ) &
+        done
+        wait
+}
+
+t_begin "check broken results" && {
+        for i in a b c d
+        do
+                eval 'i_tmp=$'${i}_tmp
+                eval "i=$"$i
+                test xok = x$(cat $i)
+                dbgcat i_tmp
+        done
+}
+
+t_begin "repeat concurrent tests with faster clients" && {
+        for i in a b c d
+        do
+                eval 'i_tmp=$'${i}_tmp
+                eval "i=$"$i
+                curl -sSf -T- </dev/null http://$listen/ > $i 2> $i_tmp &
+        done
+        wait
+}
+
+t_begin "check results" && {
+        for i in a b c d
+        do
+                eval 'i_tmp=$'${i}_tmp
+                eval "i=$"$i
+                test ! -s $i_tmp
+                test x$null_sha1 = x$(cat $i)
+        done
+}
+
+t_begin "fire off garbage" && {
+        for i in a b c d
+        do
+                rtmpfiles ${i}_fifo ${i}_tmp
+                eval 'i_fifo=$'${i}_fifo
+                eval 'i_tmp=$'${i}_tmp
+                eval "i=$"$i
+                (
+                        (
+                                cat $i_fifo > $i_tmp &
+                                dd if=random_blob bs=4096 count=1
+                                wait
+                                echo ok > $i
+                        ) | socat - TCP:$listen > $i_fifo
+                ) &
+        done
+        wait
+}
+
+t_begin "check broken results" && {
+        for i in a b c d
+        do
+                eval 'i_tmp=$'${i}_tmp
+                eval "i=$"$i
+                test xok = x$(cat $i)
+                grep -F 'HTTP/1.1 400 Bad Request' $i_tmp
+        done
+}
+
+t_begin "repeat concurrent tests with faster clients" && {
+        for i in a b c d
+        do
+                eval 'i_tmp=$'${i}_tmp
+                eval "i=$"$i
+                curl -sSf -T- </dev/null http://$listen/ > $i 2> $i_tmp &
+        done
+        wait
+}
+
+t_begin "check results" && {
+        for i in a b c d
+        do
+                eval 'i_tmp=$'${i}_tmp
+                eval "i=$"$i
+                test ! -s $i_tmp
+                test x$null_sha1 = x$(cat $i)
+        done
+}
+
 t_begin "teardown" && {
         kill $rainbows_pid
 }