about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-10-17 22:42:56 -0700
committerEric Wong <normalperson@yhbt.net>2009-10-17 22:42:56 -0700
commit1c0dab453688e8bfc9f21656e9b89b88fb3cc1d3 (patch)
tree84c63565ca4e45b4489e474a40237da49c177266 /t
parent49981da0edf3cb142079ee9341640bd5b798c880 (diff)
downloadrainbows-1c0dab453688e8bfc9f21656e9b89b88fb3cc1d3.tar.gz
Diffstat (limited to 't')
-rw-r--r--t/lib-reopen-logs.sh60
-rwxr-xr-xt/t1003-thread-pool-reopen-logs.sh2
-rwxr-xr-xt/t2003-thread-spawn-reopen-logs.sh2
-rwxr-xr-xt/t3003-revactor-reopen-logs.sh53
-rwxr-xr-xt/t4003-rev-reopen-logs.sh2
-rwxr-xr-x[-rw-r--r--]t/test-lib.sh0
6 files changed, 67 insertions, 52 deletions
diff --git a/t/lib-reopen-logs.sh b/t/lib-reopen-logs.sh
new file mode 100644
index 0000000..ace223a
--- /dev/null
+++ b/t/lib-reopen-logs.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+# don't set nr_client for Rev, only _one_ app running at once :x
+nr_client=${nr_client-2}
+. ./test-lib.sh
+
+eval $(unused_listen)
+rtmpfiles unicorn_config curl_out curl_err pid r_err r_out r_rot
+
+
+cat > $unicorn_config <<EOF
+listen "$listen"
+pid "$pid"
+stderr_path "$r_err"
+stdout_path "$r_out"
+Rainbows! { use :$model }
+EOF
+
+rainbows -D sleep.ru -c $unicorn_config
+wait_for_pid $pid
+
+start=$(date +%s)
+for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" </dev/null)
+do
+        ( curl -sSf http://$listen/2 >> $curl_out 2>> $curl_err ) &
+done
+! grep Error $r_err
+
+rm $r_rot
+mv $r_err $r_rot
+
+kill -USR1 $(cat $pid)
+wait_for_pid $r_err
+
+dbgcat r_rot
+dbgcat r_err
+
+wait
+echo elapsed=$(( $(date +%s) - $start ))
+! test -s $curl_err
+test x"$(wc -l < $curl_out)" = x$nr_client
+nr=$(sort < $curl_out | uniq | wc -l)
+
+test "$nr" -eq 1
+test x$(sort < $curl_out | uniq) = xHello
+! grep Error $r_err
+! grep Error $r_rot
+
+before_rot=$(wc -c < $r_rot)
+before_err=$(wc -c < $r_err)
+curl -sSfv http://$listen/
+after_rot=$(wc -c < $r_rot)
+after_err=$(wc -c < $r_err)
+
+test $after_rot -eq $before_rot && echo "before_rot -eq after_rot"
+test $after_err -gt $before_err && echo "before_err -gt after_err"
+
+kill $(cat $pid)
+dbgcat r_err
+! grep Error $r_err
+! grep Error $r_rot
diff --git a/t/t1003-thread-pool-reopen-logs.sh b/t/t1003-thread-pool-reopen-logs.sh
new file mode 100755
index 0000000..6bba7ef
--- /dev/null
+++ b/t/t1003-thread-pool-reopen-logs.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. ./lib-reopen-logs.sh
diff --git a/t/t2003-thread-spawn-reopen-logs.sh b/t/t2003-thread-spawn-reopen-logs.sh
new file mode 100755
index 0000000..6bba7ef
--- /dev/null
+++ b/t/t2003-thread-spawn-reopen-logs.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. ./lib-reopen-logs.sh
diff --git a/t/t3003-revactor-reopen-logs.sh b/t/t3003-revactor-reopen-logs.sh
index 47b2eaf..6bba7ef 100755
--- a/t/t3003-revactor-reopen-logs.sh
+++ b/t/t3003-revactor-reopen-logs.sh
@@ -1,53 +1,2 @@
 #!/bin/sh
-. ./test-lib.sh
-
-eval $(unused_listen)
-rtmpfiles unicorn_config curl_out curl_err pid r_err r_out r_rot
-
-nr_client=30
-nr_actor=10
-
-cat > $unicorn_config <<EOF
-listen "$listen"
-pid "$pid"
-stderr_path "$r_err"
-stdout_path "$r_out"
-Rainbows! do
-  use :Revactor
-  worker_connections $nr_actor
-end
-EOF
-
-rainbows -D sleep.ru -c $unicorn_config
-wait_for_pid $pid
-
-start=$(date +%s)
-for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" </dev/null)
-do
-        ( curl -sSf http://$listen/2 >> $curl_out 2>> $curl_err ) &
-done
-! grep Error $r_err
-
-rm $r_rot
-mv $r_err $r_rot
-
-kill -USR1 $(cat $pid)
-wait_for_pid $r_err
-
-dbgcat r_rot
-dbgcat r_err
-
-wait
-echo elapsed=$(( $(date +%s) - $start ))
-! test -s $curl_err
-test x"$(wc -l < $curl_out)" = x$nr_client
-nr=$(sort < $curl_out | uniq | wc -l)
-
-test "$nr" -eq 1
-test x$(sort < $curl_out | uniq) = xHello
-! grep Error $r_err
-! grep Error $r_rot
-
-kill $(cat $pid)
-dbgcat r_err
-! grep Error $r_err
+. ./lib-reopen-logs.sh
diff --git a/t/t4003-rev-reopen-logs.sh b/t/t4003-rev-reopen-logs.sh
new file mode 100755
index 0000000..6bba7ef
--- /dev/null
+++ b/t/t4003-rev-reopen-logs.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. ./lib-reopen-logs.sh
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 54d1b2d..54d1b2d 100644..100755
--- a/t/test-lib.sh
+++ b/t/test-lib.sh