2 # don't set nr_client for Rev, only _one_ app running at once :x
3 nr_client
=${nr_client-2}
6 t_plan
19 "reopen rotated logs"
8 t_begin
"setup and startup" && {
9 rtmpfiles curl_out curl_err r_rot
11 rainbows
-D sleep.ru
-c $unicorn_config
15 t_begin
"ensure server is responsive" && {
16 curl
-sSf http
://$listen/ >/dev
/null
19 t_begin
"start $nr_client concurrent requests" && {
21 for i
in $
(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" </dev
/null
)
23 ( curl
-sSf http
://$listen/2 >> $curl_out 2>> $curl_err ) &
27 t_begin
"ensure stderr log is clean" && check_stderr
29 t_begin
"external log rotation" && {
34 t_begin
"send reopen log signal (USR1)" && {
35 kill -USR1 $rainbows_pid
38 t_begin
"wait for rotated log to reappear" && {
40 while ! test -f $r_err && test $nr -ge 0
47 t_begin
"wait for worker to reopen logs" && {
49 re
="worker=.* done reopening logs"
50 while ! grep "$re" < $r_err >/dev
/null
&& test $nr -ge 0
60 t_begin
"wait curl requests to finish" && {
62 t_info elapsed
=$
(( $
(date +%s
) - $start ))
65 t_begin
"ensure no errors from curl" && {
69 t_begin
"curl got $nr_client responses" && {
70 test "$(wc -l < $curl_out)" -eq $nr_client
73 t_begin
"all responses were identical" && {
74 nr
=$
(sort < $curl_out |
uniq |
wc -l)
78 t_begin
'response was "Hello"' && {
79 test x$
(sort < $curl_out |
uniq) = xHello
82 t_begin
"current server stderr is clean" && check_stderr
84 t_begin
"rotated stderr is clean" && {
88 t_begin
"server is now writing logs to new stderr" && {
89 before_rot
=$
(wc -c < $r_rot)
90 before_err
=$
(wc -c < $r_err)
91 curl
-sSfv http
://$listen/
92 after_rot
=$
(wc -c < $r_rot)
93 after_err
=$
(wc -c < $r_err)
94 test $after_rot -eq $before_rot
95 test $after_err -gt $before_err
98 t_begin
"stop server" && {
104 t_begin
"current server stderr is clean" && check_stderr
105 t_begin
"rotated stderr is clean" && check_stderr
$r_rot