stream_response_epoll: our most "special" concurrency option yet
[rainbows.git] / t / t0050-response-body-close-has-env.sh
blobe7e6a68d9ed9232546263f1166ab35eadeef90e1
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
20 cat $fifo > $tmp &
21 printf 'GET /%s/1 HTTP/1.1\r\n' $pfx
22 printf 'Host: example.com\r\n\r\n'
23 printf 'GET /%s/2 HTTP/1.1\r\n' $pfx
24 printf 'Host: example.com\r\n\r\n'
25 printf 'GET /%s/3 HTTP/1.1\r\n' $pfx
26 printf 'Host: example.com\r\n'
27 printf 'Connection: close\r\n\r\n'
28 wait
29 echo ok > $ok
30 ) | socat - TCP4:$listen > $fifo
31 test xok = x$(cat $ok)
35 reload () {
36 t_begin 'reloading Rainbows! to ensure writeout' && {
37 # ensure worker is loaded before HUP
38 curl -s http://$listen/ >/dev/null
39 # reload to ensure everything is flushed
40 kill -HUP $rainbows_pid
41 test xSTART = x"$(cat $fifo)"
45 check_log () {
46 pfx="$1"
47 t_begin "check body close messages" && {
48 < $r_out awk '
49 /^path_info=\/'$pfx'\/[1-3]$/ { next }
50 { exit(2) }
51 END { exit(NR == 3 ? 0 : 1) }
56 req_keepalive () {
57 pfx="$1"
58 t_begin "make keepalive requests to trigger $pfx response body" && {
59 > $r_out
60 rm -f $curl_err $curl_out
61 curl -vsSf http://$listen/$pfx/[1-3] 2> $curl_err > $curl_out
65 req_keepalive file
66 reload
67 check_log file
69 req_pipelined file
70 reload
71 check_log file
73 req_keepalive blob
74 reload
75 check_log blob
77 req_pipelined blob
78 reload
79 check_log blob
81 req_keepalive pipe
82 reload
83 check_log pipe
85 req_pipelined pipe
86 reload
87 check_log pipe
89 t_begin "enable sendfile gem" && {
90 echo "require 'sendfile'" >> $unicorn_config
93 reload
95 req_keepalive file
96 reload
97 check_log file
99 req_pipelined file
100 reload
101 check_log file
103 t_begin "killing succeeds" && {
104 kill $rainbows_pid
107 t_begin "check stderr" && {
108 check_stderr
111 t_done