about summary refs log tree commit homepage
path: root/t/t0005-large-file-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/t0005-large-file-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/t0005-large-file-response.sh')
-rwxr-xr-xt/t0005-large-file-response.sh83
1 files changed, 83 insertions, 0 deletions
diff --git a/t/t0005-large-file-response.sh b/t/t0005-large-file-response.sh
new file mode 100755
index 0000000..7aafd5b
--- /dev/null
+++ b/t/t0005-large-file-response.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+. ./test-lib.sh
+test -r random_blob || die "random_blob required, run with 'make $0'"
+
+if ! grep -v ^VmRSS: /proc/self/status >/dev/null 2>&1
+then
+        t_info "skipping, can't read RSS from /proc/self/status"
+        exit 0
+fi
+
+t_plan 10 "large file response slurp avoidance for $model"
+
+t_begin "setup and startup" && {
+        rtmpfiles curl_out
+        rainbows_setup $model
+        # can't load Rack::Lint here since it'll cause Rev to slurp
+        rainbows -E none -D large-file-response.ru -c $unicorn_config
+        rainbows_wait_start
+}
+
+t_begin "read random blob size" && {
+        random_blob_size=$(wc -c < random_blob)
+}
+
+t_begin "read current RSS" && {
+        curl -v http://$listen/rss
+        dbgcat r_err
+        rss_before=$(curl -sSfv http://$listen/rss)
+        t_info "rss_before=$rss_before"
+}
+
+t_begin "send a series HTTP/1.1 requests sequentially" && {
+        for i in a b c
+        do
+                size=$( (curl -sSfv http://$listen/random_blob &&
+                         echo ok >$ok) |wc -c)
+                test $size -eq $random_blob_size
+                test xok = x$(cat $ok)
+        done
+}
+
+# this was a problem during development
+t_begin "HTTP/1.0 test" && {
+        size=$( (curl -0 -sSfv http://$listen/random_blob &&
+                 echo ok >$ok) |wc -c)
+        test $size -eq $random_blob_size
+        test xok = x$(cat $ok)
+}
+
+t_begin "HTTP/0.9 test" && {
+        (
+                printf 'GET /random_blob\r\n'
+                cat $fifo > $tmp &
+                wait
+                echo ok > $ok
+        ) | socat - TCP:$listen > $fifo
+        cmp $tmp random_blob
+        test xok = x$(cat $ok)
+}
+
+dbgcat r_err
+
+t_begin "read RSS again" && {
+        curl -v http://$listen/rss
+        rss_after=$(curl -sSfv http://$listen/rss)
+        t_info "rss_after=$rss_after"
+}
+
+t_begin "shutdown server" && {
+        kill -QUIT $rainbows_pid
+}
+
+t_begin "compare RSS before and after" && {
+        diff=$(( $rss_after - $rss_before ))
+        t_info "test diff=$diff < orig=$random_blob_size"
+        test $diff -le $random_blob_size
+}
+
+dbgcat r_err
+
+t_begin "check stderr" && check_stderr
+
+t_done