about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-05-20 14:24:14 -0700
committerEric Wong <normalperson@yhbt.net>2011-05-20 14:24:14 -0700
commita396de855e291d27d43454618031432634fe7d37 (patch)
tree403734e810e668813ec26e1bfa0180f8f1f3503e
parent5d5033afa9052dc0d60e743f07bc694f008182b3 (diff)
This will only be supported for certain concurency models, but
it's probably good enough.
-rw-r--r--t/t0043-quit-keepalive-disconnect.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/t/t0043-quit-keepalive-disconnect.sh b/t/t0043-quit-keepalive-disconnect.sh
new file mode 100644
index 0000000..f0a4d22
--- /dev/null
+++ b/t/t0043-quit-keepalive-disconnect.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+. ./test-lib.sh
+case $model in
+Coolio|CoolioThreadSpawn|CoolioThreadPool|EventMachine) ;;
+Epoll|XEpoll|XEpollThreadPool|XEpollThreadSpawn) ;;
+*)
+        t_info "$0 not supported for $model"
+        exit 0
+        ;;
+esac
+
+t_plan 7 "keepalive clients disconnected on SIGQUIT for $model"
+
+t_begin "setup and start" && {
+        rainbows_setup $model 50 30
+        rainbows -E none -D env.ru -c $unicorn_config
+        rainbows_wait_start
+}
+
+t_begin "start a keepalive request" && {
+        (
+                cat < $fifo > $tmp &
+                printf 'GET / HTTP/1.1\r\nHost: example.com\r\n\r\n'
+                wait
+        ) | socat - TCP4:$listen > $fifo &
+}
+
+t_begin "wait for response" && {
+        while ! tail -1 < $tmp | grep '}$' >/dev/null
+        do
+                sleep 1
+        done
+}
+
+t_begin "stop Rainbows! gracefully" && {
+        t0=$(date +%s)
+        kill -QUIT $rainbows_pid
+}
+
+t_begin "keepalive client disconnected quickly" && {
+        wait
+        diff=$(( $(date +%s) - $t0 ))
+        test $diff -le 2 || die "client diff=$diff > 2"
+}
+
+t_begin "wait for termination" && {
+        while kill -0 $rainbows_pid
+        do
+                sleep 1
+        done
+        diff=$(( $(date +%s) - $t0 ))
+        test $diff -le 4 || die "server diff=$diff > 4"
+}
+
+t_begin "check stderr" && {
+        check_stderr
+}
+
+t_done