http_server: kill a warning
[rainbows.git] / t / t0004-heartbeat-timeout.sh
blob53f2bd3dffc82a3cf3533097a8b37867bb813809
1 #!/bin/sh
2 . ./test-lib.sh
4 t_plan 12 "heartbeat/timeout test for $model"
6 t_begin "setup and startup" && {
7 rainbows_setup $model
8 echo timeout 3 >> $unicorn_config
9 echo preload_app true >> $unicorn_config
10 rainbows -D heartbeat-timeout.ru -c $unicorn_config
11 rainbows_wait_start
14 t_begin "read worker PID" && {
15 worker_pid=$(curl -sSf http://$listen/)
16 t_info "worker_pid=$worker_pid"
19 t_begin "sleep for a bit, ensure worker PID does not change" && {
20 sleep 4
21 test $(curl -sSf http://$listen/) -eq $worker_pid
24 t_begin "block the worker process to force it to die" && {
25 rm $ok
26 t0=$(date +%s)
27 err="$(curl -sSf http://$listen/block-forever 2>&1 || > $ok)"
28 t1=$(date +%s)
29 elapsed=$(($t1 - $t0))
30 t_info "elapsed=$elapsed err=$err"
31 test x"$err" != x"Should never get here"
32 test x"$err" != x"$worker_pid"
35 t_begin "ensure worker was killed" && {
36 test -e $ok
37 test 1 -eq $(grep timeout $r_err | grep killing | wc -l)
40 t_begin "ensure timeout took at least 3 seconds" && {
41 test $elapsed -ge 3
44 t_begin "wait for new worker to start up" && {
45 test xSTART = x"$(cat $fifo)"
48 t_begin "we get a fresh new worker process" && {
49 new_worker_pid=$(curl -sSf http://$listen/)
50 test $new_worker_pid -ne $worker_pid
53 t_begin "truncate the server error log" && {
54 > $r_err
57 t_begin "SIGSTOP and SIGCONT on rainbows master does not kill worker" && {
58 kill -STOP $rainbows_pid
59 sleep 4
60 kill -CONT $rainbows_pid
61 sleep 2
62 test $new_worker_pid -eq $(curl -sSf http://$listen/)
65 t_begin "stop server" && {
66 kill -QUIT $rainbows_pid
69 t_begin "check stderr" && check_stderr
71 dbgcat r_err
73 t_done