diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/t0013-reload-bad-config.sh | 54 | ||||
-rwxr-xr-x | t/t0014-config-conflict.sh | 50 |
2 files changed, 104 insertions, 0 deletions
diff --git a/t/t0013-reload-bad-config.sh b/t/t0013-reload-bad-config.sh new file mode 100755 index 0000000..abe1d5e --- /dev/null +++ b/t/t0013-reload-bad-config.sh @@ -0,0 +1,54 @@ +#!/bin/sh +. ./test-lib.sh +t_plan 7 "reload config.ru error with preload_app true" + +t_begin "setup and start" && { + rainbows_setup + rtmpfiles ru + + cat > $ru <<\EOF +use Rack::ContentLength +use Rack::ContentType, "text/plain" +x = { "hello" => "world" } +run lambda { |env| [ 200, {}, [ x.inspect << "\n" ] ] } +EOF + echo 'preload_app true' >> $unicorn_config + rainbows -D -c $unicorn_config $ru + rainbows_wait_start +} + +t_begin "hit with curl" && { + out=$(curl -sSf http://$listen/) + test x"$out" = x'{"hello"=>"world"}' +} + +t_begin "introduce syntax error in rackup file" && { + echo '...' >> $ru +} + +t_begin "reload signal succeeds" && { + kill -HUP $rainbows_pid + rainbows_wait_start + while ! egrep '(done|error) reloading' $r_err >/dev/null + do + sleep 1 + done + + grep 'error reloading' $r_err >/dev/null + > $r_err +} + +t_begin "hit with curl" && { + out=$(curl -sSf http://$listen/) + test x"$out" = x'{"hello"=>"world"}' +} + +t_begin "killing succeeds" && { + kill $rainbows_pid +} + +t_begin "check stderr" && { + check_stderr +} + +t_done diff --git a/t/t0014-config-conflict.sh b/t/t0014-config-conflict.sh new file mode 100755 index 0000000..b91355d --- /dev/null +++ b/t/t0014-config-conflict.sh @@ -0,0 +1,50 @@ +#!/bin/sh +. ./test-lib.sh +t_plan 6 "config variables conflict with preload_app" + +t_begin "setup and start" && { + rainbows_setup + rtmpfiles ru rutmp + + cat > $ru <<\EOF +use Rack::ContentLength +use Rack::ContentType, "text/plain" +config = ru = { "hello" => "world" } +run lambda { |env| [ 200, {}, [ ru.inspect << "\n" ] ] } +EOF + echo 'preload_app true' >> $unicorn_config + rainbows -D -c $unicorn_config $ru + rainbows_wait_start +} + +t_begin "hit with curl" && { + out=$(curl -sSf http://$listen/) + test x"$out" = x'{"hello"=>"world"}' +} + +t_begin "modify rackup file" && { + sed -e 's/world/WORLD/' < $ru > $rutmp + mv $rutmp $ru +} + +t_begin "reload signal succeeds" && { + kill -HUP $rainbows_pid + rainbows_wait_start + while ! egrep '(done|error) reloading' < $r_err >/dev/null + do + sleep 1 + done + + grep 'done reloading' $r_err >/dev/null +} + +t_begin "hit with curl" && { + out=$(curl -sSf http://$listen/) + test x"$out" = x'{"hello"=>"WORLD"}' +} + +t_begin "killing succeeds" && { + kill $rainbows_pid +} + +t_done |