http_server: explicitly disable close-on-exec for listeners
[unicorn.git] / t / t0006-reopen-logs.sh
blob430959cce2cdc60ac15188ba7715c86fc14c1cea
1 #!/bin/sh
2 . ./test-lib.sh
4 t_plan 15 "reopen rotated logs"
6 t_begin "setup and startup" && {
7 rtmpfiles curl_out curl_err r_rot
8 unicorn_setup
9 unicorn -D t0006.ru -c $unicorn_config
10 unicorn_wait_start
13 t_begin "ensure server is responsive" && {
14 test xtrue = x$(curl -sSf http://$listen/ 2> $curl_err)
17 t_begin "ensure stderr log is clean" && check_stderr
19 t_begin "external log rotation" && {
20 rm -f $r_rot
21 mv $r_err $r_rot
24 t_begin "send reopen log signal (USR1)" && {
25 kill -USR1 $unicorn_pid
28 t_begin "wait for rotated log to reappear" && {
29 nr=60
30 while ! test -f $r_err && test $nr -ge 0
32 sleep 1
33 nr=$(( $nr - 1 ))
34 done
37 t_begin "ensure server is still responsive" && {
38 test xtrue = x$(curl -sSf http://$listen/ 2> $curl_err)
41 t_begin "wait for worker to reopen logs" && {
42 nr=60
43 re="worker=.* done reopening logs"
44 while ! grep "$re" < $r_err >/dev/null && test $nr -ge 0
46 sleep 1
47 nr=$(( $nr - 1 ))
48 done
51 dbgcat r_rot
52 dbgcat r_err
54 t_begin "ensure no errors from curl" && {
55 test ! -s $curl_err
58 t_begin "current server stderr is clean" && check_stderr
60 t_begin "rotated stderr is clean" && {
61 check_stderr $r_rot
64 t_begin "server is now writing logs to new stderr" && {
65 before_rot=$(wc -c < $r_rot)
66 before_err=$(wc -c < $r_err)
67 test xtrue = x$(curl -sSf http://$listen/ 2> $curl_err)
68 after_rot=$(wc -c < $r_rot)
69 after_err=$(wc -c < $r_err)
70 test $after_rot -eq $before_rot
71 test $after_err -gt $before_err
74 t_begin "stop server" && {
75 kill $unicorn_pid
78 dbgcat r_err
80 t_begin "current server stderr is clean" && check_stderr
81 t_begin "rotated stderr is clean" && check_stderr $r_rot
83 t_done