diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-15 00:37:59 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-15 00:46:19 -0700 |
commit | cbaa604582a9f80eba3fc0c2423234f497f21726 (patch) | |
tree | 4a8436099453a90eb57e045a7308a4882dc87cab /t | |
parent | 537dffa88eeb7b573aa8176270f0635085de4706 (diff) | |
download | rainbows-cbaa604582a9f80eba3fc0c2423234f497f21726.tar.gz |
Diffstat (limited to 't')
-rwxr-xr-x | t/t9000-rack-app-pool.sh | 37 | ||||
-rw-r--r-- | t/t9000.ru | 14 |
2 files changed, 51 insertions, 0 deletions
diff --git a/t/t9000-rack-app-pool.sh b/t/t9000-rack-app-pool.sh new file mode 100755 index 0000000..41402d9 --- /dev/null +++ b/t/t9000-rack-app-pool.sh @@ -0,0 +1,37 @@ +#!/bin/sh +. ./test-lib.sh + +eval $(unused_listen) +rtmpfiles unicorn_config pid r_err r_out curl_out curl_err + +nr_client=30 + +cat > $unicorn_config <<EOF +listen "$listen" +pid "$pid" +stderr_path "$r_err" +stdout_path "$r_out" +Rainbows! do + use :ThreadSpawn + worker_connections 50 +end +EOF + +APP_POOL_SIZE=4 +APP_POOL_SIZE=$APP_POOL_SIZE rainbows -D t9000.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/ >> $curl_out 2>> $curl_err ) & +done +wait +echo elapsed=$(( $(date +%s) - $start )) +kill $(cat $pid) + +test $APP_POOL_SIZE -eq $(sort < $curl_out | uniq | wc -l) +! test -s $curl_err + +! grep Error $r_err +# diff --git a/t/t9000.ru b/t/t9000.ru new file mode 100644 index 0000000..af6b4fc --- /dev/null +++ b/t/t9000.ru @@ -0,0 +1,14 @@ +use Rack::ContentLength +use Rack::ContentType +use Rainbows::AppPool, :size => ENV['APP_POOL_SIZE'].to_i +sleep_class = ENV['SLEEP_CLASS'] +sleep_class = sleep_class ? Object.const_get(sleep_class) : Kernel +class Sleeper + def call(env) + sleep_class = ENV['SLEEP_CLASS'] + sleep_class = sleep_class ? Object.const_get(sleep_class) : Kernel + sleep_class.sleep 1 + [ 200, {}, [ "#{object_id}\n" ] ] + end +end +run Sleeper.new |