diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-11-09 12:27:40 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-11-09 12:28:48 -0800 |
commit | f8c283b855eadc18c8f531a8bb2363a4050c9436 (patch) | |
tree | d3a0bffeec4c722e02ce940b11ac97dd4f7fe9d5 /t | |
parent | b933b1607db5438e424b323c297b57c680587ed7 (diff) | |
download | rainbows-f8c283b855eadc18c8f531a8bb2363a4050c9436.tar.gz |
Counting worker connections is easy-to-forget when implementing new concurrency models and forgetting to do it means new clients cannot be accepted. Fortunately some concurrency models tend to do it for us.
Diffstat (limited to 't')
-rwxr-xr-x | t/t0008-ensure-usable-after-limit.sh | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/t/t0008-ensure-usable-after-limit.sh b/t/t0008-ensure-usable-after-limit.sh new file mode 100755 index 0000000..d5c2e79 --- /dev/null +++ b/t/t0008-ensure-usable-after-limit.sh @@ -0,0 +1,78 @@ +#!/bin/sh +. ./test-lib.sh + +t_plan 6 "ensure we're accounting worker_connections properly" +nr=2 + +t_begin "setup" && { + rtmpfiles a b c d + rainbows_setup $model $nr + rainbows -D sha1.ru -c $unicorn_config + rainbows_wait_start +} + +null_sha1=da39a3ee5e6b4b0d3255bfef95601890afd80709 + +t_begin "fire off concurrent processes" && { + + req='POST / HTTP/1.1\r\n' + req="$req"'Host: example.com\r\n' + req="$req"'Transfer-Encoding: chunked\r\n\r\n' + + for i in a b c d + do + rtmpfiles ${i}_fifo ${i}_tmp + eval 'i_fifo=$'${i}_fifo + eval 'i_tmp=$'${i}_tmp + eval "i=$"$i + ( + ( + cat $i_fifo > $i_tmp & + # need a full HTTP request to get around + # httpready + printf "$req" + sleep 5 + printf '0\r\n\r\n' + wait + echo ok > $i + ) | socat - TCP:$listen > $i_fifo + ) & + done + wait +} + +t_begin "check results" && { + for i in a b c d + do + eval 'i_tmp=$'${i}_tmp + eval "i=$"$i + test xok = x$(cat $i) + test x$null_sha1 = x$(tail -1 $i_tmp) + done +} + +t_begin "repeat concurrent tests with faster clients" && { + for i in a b c d + do + eval 'i_tmp=$'${i}_tmp + eval "i=$"$i + curl -sSf -T- </dev/null http://$listen/ > $i 2> $i_tmp & + done + wait +} + +t_begin "check results" && { + for i in a b c d + do + eval 'i_tmp=$'${i}_tmp + eval "i=$"$i + test ! -s $i_tmp + test x$null_sha1 = x$(cat $i) + done +} + +t_begin "teardown" && { + kill $rainbows_pid +} + +t_done |