diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-17 22:42:56 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-17 22:42:56 -0700 |
commit | a764983fccd6cce64043d76e09a5e1718e7f8fd6 (patch) | |
tree | cd6f730c5b93c584a7cdda57079b318d99bb3120 /t | |
parent | 71a1cf90ce16ce6951f1ce76fcea98b13bc54576 (diff) | |
download | rainbows-a764983fccd6cce64043d76e09a5e1718e7f8fd6.tar.gz |
We use the "G" global constant from the Rev model everywhere to simplify things a little. Test cases are more consistent now, too.
Diffstat (limited to 't')
-rw-r--r-- | t/lib-graceful.sh | 47 | ||||
-rwxr-xr-x | t/t1002-thread-pool-graceful.sh | 37 | ||||
-rwxr-xr-x | t/t2002-thread-spawn-graceful.sh | 37 | ||||
-rwxr-xr-x | t/t3002-revactor-graceful.sh | 38 | ||||
-rwxr-xr-x | t/t4002-rev-graceful.sh | 52 |
5 files changed, 51 insertions, 160 deletions
diff --git a/t/lib-graceful.sh b/t/lib-graceful.sh new file mode 100644 index 0000000..d2a6be8 --- /dev/null +++ b/t/lib-graceful.sh @@ -0,0 +1,47 @@ +model=$1 +. ./test-lib.sh +echo "graceful test for model=$model" +case $model in +Rev) require_rev ;; +Revactor) require_revactor ;; +esac + +eval $(unused_listen) +rtmpfiles unicorn_config curl_out pid r_err r_out fifo +rm -f $fifo +mkfifo $fifo + +cat > $unicorn_config <<EOF +listen "$listen" +stderr_path "$r_err" +stdout_path "$r_out" +pid "$pid" +Rainbows! { use :$model } +EOF + +rainbows -D sleep.ru -c $unicorn_config +wait_for_pid $pid +rainbows_pid=$(cat $pid) + +curl -sSfv -T- </dev/null http://$listen/5 > $curl_out 2> $fifo & + +awk -v rainbows_pid=$rainbows_pid ' +{ print $0 } +/100 Continue/ { + print "awk: sending SIGQUIT to", rainbows_pid + system("kill -QUIT "rainbows_pid) +}' $fifo +wait + +dbgcat r_err + +test x"$(wc -l < $curl_out)" = x1 +nr=$(sort < $curl_out | uniq | wc -l) + +test "$nr" -eq 1 +test x$(sort < $curl_out | uniq) = xHello +! grep Error $r_err +while kill -0 $rainbows_pid >/dev/null 2>&1 +do + sleep 1 +done diff --git a/t/t1002-thread-pool-graceful.sh b/t/t1002-thread-pool-graceful.sh index 0830bc7..c5d1f87 100755 --- a/t/t1002-thread-pool-graceful.sh +++ b/t/t1002-thread-pool-graceful.sh @@ -1,37 +1,2 @@ #!/bin/sh -. ./test-lib.sh - -eval $(unused_listen) -rtmpfiles unicorn_config curl_out curl_err pid r_err r_out -nr_thread=10 -nr_client=10 -cat > $unicorn_config <<EOF -listen "$listen" -stderr_path "$r_err" -stdout_path "$r_out" -pid "$pid" -Rainbows! do - use :ThreadPool - worker_connections $nr_thread -end -EOF - -rainbows -D sleep.ru -c $unicorn_config -wait_for_pid $pid - -for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" </dev/null) -do - curl -sSf http://$listen/5 >> $curl_out 2>> $curl_err & -done -sleep 2 -kill -QUIT $(cat $pid) -wait - -dbgcat r_err -! 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 +. ./lib-graceful.sh ThreadPool diff --git a/t/t2002-thread-spawn-graceful.sh b/t/t2002-thread-spawn-graceful.sh index 5a02670..b263306 100755 --- a/t/t2002-thread-spawn-graceful.sh +++ b/t/t2002-thread-spawn-graceful.sh @@ -1,37 +1,2 @@ #!/bin/sh -. ./test-lib.sh - -eval $(unused_listen) -rtmpfiles unicorn_config curl_out curl_err pid r_err r_out -nr_thread=10 -nr_client=10 -cat > $unicorn_config <<EOF -listen "$listen" -stderr_path "$r_err" -stdout_path "$r_out" -pid "$pid" -Rainbows! do - use :ThreadSpawn - worker_connections $nr_thread -end -EOF - -rainbows -D sleep.ru -c $unicorn_config -wait_for_pid $pid - -for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" </dev/null) -do - curl -sSf http://$listen/5 >> $curl_out 2>> $curl_err & -done -sleep 2 -kill -QUIT $(cat $pid) -wait - -dbgcat r_err -! 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 +. ./lib-graceful.sh ThreadSpawn diff --git a/t/t3002-revactor-graceful.sh b/t/t3002-revactor-graceful.sh index 67c6ba3..8696e06 100755 --- a/t/t3002-revactor-graceful.sh +++ b/t/t3002-revactor-graceful.sh @@ -1,38 +1,2 @@ #!/bin/sh -. ./test-lib.sh -require_revactor - -eval $(unused_listen) -rtmpfiles unicorn_config curl_out curl_err pid r_err r_out -nr_actor=10 -nr_client=10 -cat > $unicorn_config <<EOF -listen "$listen" -stderr_path "$r_err" -stdout_path "$r_out" -pid "$pid" -Rainbows! do - use :Revactor - worker_connections $nr_actor -end -EOF - -rainbows -D sleep.ru -c $unicorn_config -wait_for_pid $pid - -for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" </dev/null) -do - curl -sSf http://$listen/5 >> $curl_out 2>> $curl_err & -done -sleep 2 -kill -QUIT $(cat $pid) -wait - -dbgcat r_err -! 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 +. ./lib-graceful.sh Revactor diff --git a/t/t4002-rev-graceful.sh b/t/t4002-rev-graceful.sh index e286886..788bc6b 100755 --- a/t/t4002-rev-graceful.sh +++ b/t/t4002-rev-graceful.sh @@ -1,52 +1,2 @@ #!/bin/sh -. ./test-lib.sh -require_rev - -eval $(unused_listen) -rtmpfiles unicorn_config tmp pid r_err r_out out -nr_client=10 -cat > $unicorn_config <<EOF -listen "$listen" -stderr_path "$r_err" -stdout_path "$r_out" -pid "$pid" -Rainbows! do - use :Rev -end -EOF - -rainbows -D sleep.ru -c $unicorn_config -wait_for_pid $pid - -for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" </dev/null) -do - ( - rtmpfiles fifo tmp - rm -f $fifo - mkfifo $fifo - ( - printf 'GET /0 HTTP/1.1\r\n' - cat $fifo > $tmp & - sleep 1 - printf 'Host: example.com\r\n' - sleep 1 - printf 'Connection: close\r\n' - sleep 1 - printf '\r\n' - wait - ) | socat - TCP:$listen > $fifo - fgrep 'Hello' $tmp >> $out || : - rm -f $fifo $tmp - ) & -done - -sleep 2 # potentially racy :< -kill -QUIT $(cat $pid) -wait - -test x"$(wc -l < $out)" = x$nr_client -nr=$(sort < $out | uniq | wc -l) -test "$nr" -eq 1 - -test x$(sort < $out | uniq) = xHello -! grep Error $r_err +. ./lib-graceful.sh Rev |