diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/t0007-worker-follows-master-to-death.sh | 50 | ||||
-rw-r--r-- | t/worker-follows-master-to-death.ru | 17 |
2 files changed, 67 insertions, 0 deletions
diff --git a/t/t0007-worker-follows-master-to-death.sh b/t/t0007-worker-follows-master-to-death.sh new file mode 100755 index 0000000..ac40277 --- /dev/null +++ b/t/t0007-worker-follows-master-to-death.sh @@ -0,0 +1,50 @@ +#!/bin/sh +. ./test-lib.sh +t_plan 7 "ensure worker follows master to death" + +t_begin "setup" && { + rtmpfiles curl_err curl_out + rainbows_setup + echo timeout 3 >> $unicorn_config + rainbows -D -c $unicorn_config worker-follows-master-to-death.ru + rainbows_wait_start +} + +t_begin "read worker PID" && { + worker_pid=$(curl -sSf http://$listen/pid) + t_info "worker_pid=$worker_pid" +} + +t_begin "start a long sleeping request" && { + curl -sSfv -T- </dev/null http://$listen/sleep/2 >$curl_out 2> $fifo & + curl_pid=$! + t_info "curl_pid=$curl_pid" +} + +t_begin "nuke the master once we're connected" && { + awk -v rainbows_pid=$rainbows_pid ' +{ print $0 } +/100 Continue/ { + print "awk: sending SIGKILL to", rainbows_pid + system("kill -9 "rainbows_pid) +}' < $fifo > $curl_err + wait +} + +t_begin "worker is no longer running" && { + sleep 6 + kill -0 $worker_pid 2> $tmp && false + test -s $tmp +} + +t_begin "sleepy curl request is no longer running" && { + kill -0 $curl_pid 2> $tmp && false + test -s $tmp +} + +t_begin "sleepy curl request completed gracefully" && { + test x$(cat $curl_out) = x$worker_pid + dbgcat curl_err +} + +t_done diff --git a/t/worker-follows-master-to-death.ru b/t/worker-follows-master-to-death.ru new file mode 100644 index 0000000..ed2a519 --- /dev/null +++ b/t/worker-follows-master-to-death.ru @@ -0,0 +1,17 @@ +use Rack::ContentLength +headers = { 'Content-Type' => 'text/plain' } +run lambda { |env| + /\A100-continue\z/i =~ env['HTTP_EXPECT'] and return [ 100, {}, [] ] + env['rack.input'].read + + case env["PATH_INFO"] + when %r{/sleep/(\d+)} + (case env['rainbows.model'] + when :Revactor + Actor + else + Kernel + end).sleep($1.to_i) + end + [ 200, headers, [ "#$$\n" ] ] +} |