about summary refs log tree commit homepage
path: root/t/t0010-keepalive-timeout-effective.sh
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-26 00:41:26 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-26 13:41:06 -0800
commit278d9d5a7f3d2dc3c6563af1584b5e773e08073d (patch)
treea3066da21425c49f3ca89bb8cf3af2ab03c285d0 /t/t0010-keepalive-timeout-effective.sh
parent1079dfa30108466d413f30526eda468cdf0ae985 (diff)
downloadrainbows-278d9d5a7f3d2dc3c6563af1584b5e773e08073d.tar.gz
Both FiberSpawn and FiberPool share similar main loops, the
only difference being the handling of connection acceptance.
So move the scheduler into it's own function for consistency.

We'll also correctly implement keepalive timeout so clients
get disconnected at the right time.
Diffstat (limited to 't/t0010-keepalive-timeout-effective.sh')
-rwxr-xr-xt/t0010-keepalive-timeout-effective.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/t/t0010-keepalive-timeout-effective.sh b/t/t0010-keepalive-timeout-effective.sh
new file mode 100755
index 0000000..9d4d651
--- /dev/null
+++ b/t/t0010-keepalive-timeout-effective.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+. ./test-lib.sh
+t_plan 6 "keepalive_timeout tests for $model"
+
+t_begin "setup and start" && {
+        rainbows_setup
+        rainbows -D env.ru -c $unicorn_config
+        rainbows_wait_start
+}
+
+t_begin 'check server up' && {
+        curl -sSf http://$listen/
+}
+
+t_begin "send keepalive response that does not expect close" && {
+        req='GET / HTTP/1.1\r\nHost: example.com\r\n\r\n'
+        t0=$(date +%s)
+        (
+                cat $fifo > $tmp &
+                printf "$req"
+                wait
+                date +%s > $ok
+        ) | socat - TCP:$listen > $fifo
+        now="$(cat $ok)"
+        elapsed=$(( $now - $t0 ))
+        t_info "elapsed=$elapsed (expecting >=5s)"
+        test $elapsed -ge 5
+}
+
+t_begin 'keepalive not unreasonably long' && {
+        test $elapsed -lt 15
+}
+
+t_begin "killing succeeds" && {
+        kill $rainbows_pid
+}
+
+t_begin "check stderr" && {
+        check_stderr
+}
+
+t_done