support for Rack hijack in request and response
[unicorn.git] / t / t0004-heartbeat-timeout.sh
blobbf73ebea16a25a990104b3c8f1d9ff68dc674423
1 #!/bin/sh
2 . ./test-lib.sh
4 t_plan 11 "heartbeat/timeout test"
6 t_begin "setup and startup" && {
7 unicorn_setup
8 echo timeout 3 >> $unicorn_config
9 echo preload_app true >> $unicorn_config
10 unicorn -D heartbeat-timeout.ru -c $unicorn_config
11 unicorn_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 "we get a fresh new worker process" && {
45 new_worker_pid=$(curl -sSf http://$listen/)
46 test $new_worker_pid -ne $worker_pid
49 t_begin "truncate the server error log" && {
50 > $r_err
53 t_begin "SIGSTOP and SIGCONT on unicorn master does not kill worker" && {
54 kill -STOP $unicorn_pid
55 sleep 4
56 kill -CONT $unicorn_pid
57 sleep 2
58 test $new_worker_pid -eq $(curl -sSf http://$listen/)
61 t_begin "stop server" && {
62 kill -QUIT $unicorn_pid
65 t_begin "check stderr" && check_stderr
67 dbgcat r_err
69 t_done