4 t_plan
11 "heartbeat/timeout test"
6 t_begin
"setup and startup" && {
8 echo timeout
3 >> $unicorn_config
9 echo preload_app true
>> $unicorn_config
10 unicorn
-D heartbeat-timeout.ru
-c $unicorn_config
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" && {
21 test $
(curl
-sSf http
://$listen/) -eq $worker_pid
24 t_begin
"block the worker process to force it to die" && {
27 err
="$(curl -sSf http://$listen/block-forever 2>&1 || > $ok)"
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" && {
37 test 1 -eq $
(grep timeout
$r_err |
grep killing | count_lines
)
40 t_begin
"ensure timeout took at least 3 seconds" && {
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" && {
53 t_begin
"SIGSTOP and SIGCONT on unicorn master does not kill worker" && {
54 kill -STOP $unicorn_pid
56 kill -CONT $unicorn_pid
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