coolio+xepoll_thread*: use shutdown() for keepalive timeout
[rainbows.git] / t / t0050-response-body-close-has-env.sh
blobf33a1ac4d411e6887141c5b31b7475a5c2612d9d
1 #!/bin/sh
2 . ./test-lib.sh
3 skip_models StreamResponseEpoll
5 t_plan 29 "keepalive does not clear Rack env prematurely for $model"
7 t_begin "setup and start" && {
8 rainbows_setup
9 rtmpfiles curl_out curl_err
10 echo "preload_app true" >> $unicorn_config
11 rainbows -D close-has-env.ru -c $unicorn_config
12 rainbows_wait_start
15 req_pipelined () {
16 pfx=$1
17 t_begin "make pipelined requests to trigger $pfx response body" && {
18 > $r_out
19 rm -f $ok
21 cat $fifo > $tmp &
22 printf 'GET /%s/1 HTTP/1.1\r\n' $pfx
23 printf 'Host: example.com\r\n\r\n'
24 printf 'GET /%s/2 HTTP/1.1\r\n' $pfx
25 printf 'Host: example.com\r\n\r\n'
26 printf 'GET /%s/3 HTTP/1.1\r\n' $pfx
27 printf 'Host: example.com\r\n'
28 printf 'Connection: close\r\n\r\n'
29 wait
30 echo ok > $ok
31 ) | socat - TCP4:$listen > $fifo
32 test xok = x$(cat $ok)
36 reload () {
37 t_begin 'reloading Rainbows! to ensure writeout' && {
38 # ensure worker is loaded before HUP
39 rm -f $curl_err $curl_out
40 curl -vs http://$listen/ >$curl_out 2> $curl_err
41 # reload to ensure everything is flushed
42 kill -HUP $rainbows_pid
43 test xSTART = x"$(cat $fifo)"
47 check_log () {
48 pfx="$1"
49 t_begin "check body close messages" && {
50 < $r_out awk '
51 /^path_info=\/'$pfx'\/[1-3]$/ { next }
52 { exit(2) }
53 END { exit(NR == 3 ? 0 : 1) }
58 req_keepalive () {
59 pfx="$1"
60 t_begin "make keepalive requests to trigger $pfx response body" && {
61 > $r_out
62 rm -f $curl_err $curl_out
63 curl -vsSf http://$listen/$pfx/[1-3] 2> $curl_err > $curl_out
67 req_keepalive file
68 reload
69 check_log file
71 req_pipelined file
72 reload
73 check_log file
75 req_keepalive blob
76 reload
77 check_log blob
79 req_pipelined blob
80 reload
81 check_log blob
83 req_keepalive pipe
84 reload
85 check_log pipe
87 req_pipelined pipe
88 reload
89 check_log pipe
91 t_begin "enable sendfile gem" && {
92 echo "require 'sendfile'" >> $unicorn_config
95 reload
97 req_keepalive file
98 reload
99 check_log file
101 req_pipelined file
102 reload
103 check_log file
105 t_begin "killing succeeds" && {
106 kill $rainbows_pid
109 t_begin "check stderr" && {
110 check_stderr
113 t_done