coolio* + *epoll*: drop keepalive clients on SIGQUIT
[rainbows.git] / t / t0050-response-body-close-has-env.sh
blobbe16a99c262368409304a61c56f57a8531ac8214
1 #!/bin/sh
2 . ./test-lib.sh
4 t_plan 29 "keepalive does not clear Rack env prematurely for $model"
6 t_begin "setup and start" && {
7 rainbows_setup
8 rtmpfiles curl_out curl_err
9 echo "preload_app true" >> $unicorn_config
10 rainbows -D close-has-env.ru -c $unicorn_config
11 rainbows_wait_start
14 req_pipelined () {
15 pfx=$1
16 t_begin "make pipelined requests to trigger $pfx response body" && {
17 > $r_out
19 cat $fifo > $tmp &
20 printf 'GET /%s/1 HTTP/1.1\r\n' $pfx
21 printf 'Host: example.com\r\n\r\n'
22 printf 'GET /%s/2 HTTP/1.1\r\n' $pfx
23 printf 'Host: example.com\r\n\r\n'
24 printf 'GET /%s/3 HTTP/1.1\r\n' $pfx
25 printf 'Host: example.com\r\n'
26 printf 'Connection: close\r\n\r\n'
27 wait
28 echo ok > $ok
29 ) | socat - TCP4:$listen > $fifo
30 test xok = x$(cat $ok)
34 reload () {
35 t_begin 'reloading Rainbows! to ensure writeout' && {
36 # ensure worker is loaded before HUP
37 curl -s http://$listen/ >/dev/null
38 # reload to ensure everything is flushed
39 kill -HUP $rainbows_pid
40 test xSTART = x"$(cat $fifo)"
44 check_log () {
45 pfx="$1"
46 t_begin "check body close messages" && {
47 < $r_out awk '
48 /^path_info=\/'$pfx'\/[1-3]$/ { next }
49 { exit(2) }
50 END { exit(NR == 3 ? 0 : 1) }
55 req_keepalive () {
56 pfx="$1"
57 t_begin "make keepalive requests to trigger $pfx response body" && {
58 > $r_out
59 rm -f $curl_err $curl_out
60 curl -vsSf http://$listen/$pfx/[1-3] 2> $curl_err > $curl_out
64 req_keepalive file
65 reload
66 check_log file
68 req_pipelined file
69 reload
70 check_log file
72 req_keepalive blob
73 reload
74 check_log blob
76 req_pipelined blob
77 reload
78 check_log blob
80 req_keepalive pipe
81 reload
82 check_log pipe
84 req_pipelined pipe
85 reload
86 check_log pipe
88 t_begin "enable sendfile gem" && {
89 echo "require 'sendfile'" >> $unicorn_config
92 reload
94 req_keepalive file
95 reload
96 check_log file
98 req_pipelined file
99 reload
100 check_log file
102 t_begin "killing succeeds" && {
103 kill $rainbows_pid
106 t_begin "check stderr" && {
107 check_stderr
110 t_done