http_server: kill a warning
[rainbows.git] / t / t0007-worker-follows-master-to-death.sh
blob38eb6e991c2a0a36e23880502cb68d5ccdf5cb14
1 #!/bin/sh
2 . ./test-lib.sh
3 t_plan 7 "ensure worker follows master to death"
5 t_begin "setup" && {
6 rtmpfiles curl_err curl_out
7 rainbows_setup
8 echo timeout 3 >> $unicorn_config
9 rainbows -D -c $unicorn_config worker-follows-master-to-death.ru
10 rainbows_wait_start
13 t_begin "read worker PID" && {
14 worker_pid=$(curl -sSf http://$listen/pid)
15 t_info "worker_pid=$worker_pid"
18 t_begin "start a long sleeping request" && {
19 curl -sSfv -T- </dev/null http://$listen/sleep/2 >$curl_out 2> $fifo &
20 curl_pid=$!
21 t_info "curl_pid=$curl_pid"
24 t_begin "nuke the master once we're connected" && {
25 awk -v rainbows_pid=$rainbows_pid '
26 { print $0 }
27 /100 Continue/ {
28 print "awk: sending SIGKILL to", rainbows_pid
29 system("kill -9 "rainbows_pid)
30 }' < $fifo > $curl_err
31 wait
34 t_begin "worker is no longer running" && {
35 nr=30
36 while kill -0 $worker_pid 2>/dev/null && test $nr -gt 0
38 nr=$(( $nr - 1))
39 sleep 1
40 done
41 kill -0 $worker_pid 2> $tmp && false
42 test -s $tmp
45 t_begin "sleepy curl request is no longer running" && {
46 kill -0 $curl_pid 2> $tmp && false
47 test -s $tmp
50 t_begin "sleepy curl request completed gracefully" && {
51 test x$(cat $curl_out) = x$worker_pid
52 dbgcat curl_err
55 t_done