about summary refs log tree commit homepage
path: root/t/t0200-async-response.sh
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-10-24 20:41:15 -0700
committerEric Wong <normalperson@yhbt.net>2009-10-24 20:42:57 -0700
commit15fe80b3bff7b0d249ee32bcbbe1dfa116d3c629 (patch)
tree8edf5313e3ef41395b406706dd807b97e6321eb9 /t/t0200-async-response.sh
parente77369a6bde35a4e8925d450aac85f328f87d208 (diff)
downloadrainbows-15fe80b3bff7b0d249ee32bcbbe1dfa116d3c629.tar.gz
This will make it easier to enable and manage tests for new
concurrency models.
Diffstat (limited to 't/t0200-async-response.sh')
-rwxr-xr-xt/t0200-async-response.sh66
1 files changed, 66 insertions, 0 deletions
diff --git a/t/t0200-async-response.sh b/t/t0200-async-response.sh
new file mode 100755
index 0000000..f3ead0b
--- /dev/null
+++ b/t/t0200-async-response.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+CONFIG_RU=${CONFIG_RU-'async-response.ru'}
+. ./test-lib.sh
+
+case $CONFIG_RU in
+*no-autochunk.ru)
+        t_plan 7 "async response w/o autochunk for $model"
+        skip_autochunk=true
+        ;;
+*)
+        t_plan 6 "async response for $model"
+        skip_autochunk=false
+        ;;
+esac
+
+t_begin "setup and start" && {
+        rainbows_setup
+        rtmpfiles a b c curl_err
+        # can't load Rack::Lint here since it'll cause Rev to slurp
+        rainbows -E none -D $CONFIG_RU -c $unicorn_config
+        rainbows_wait_start
+}
+
+t_begin "send async requests off in parallel" && {
+        t0=$(date +%s)
+        ( curl --no-buffer -sSf http://$listen/ 2>> $curl_err | utee $a) &
+        ( curl --no-buffer -sSf http://$listen/ 2>> $curl_err | utee $b) &
+        ( curl --no-buffer -sSf http://$listen/ 2>> $curl_err | utee $c) &
+        wait
+        t1=$(date +%s)
+}
+
+t_begin "ensure elapsed requests were processed in parallel" && {
+        elapsed=$(( $t1 - $t0 ))
+        echo "elapsed=$elapsed < 30"
+        test $elapsed -lt 30
+}
+
+t_begin "termination signal sent" && {
+        kill $rainbows_pid
+}
+
+dbgcat a
+dbgcat b
+dbgcat c
+dbgcat r_err
+dbgcat curl_err
+
+t_begin "no errors from curl" && {
+        test ! -s $curl_err
+}
+
+t_begin "no errors in stderr" && check_stderr
+
+dbgcat r_err
+
+if $skip_autochunk
+then
+        t_begin "no responses are chunked" && {
+                test x"$(cat $a)" = x0123456789
+                test x"$(cat $b)" = x0123456789
+                test x"$(cat $c)" = x0123456789
+        }
+fi
+
+t_done