3 skip_models StreamResponseEpoll
4 test -r random_blob || die
"random_blob required, run with 'make $0'"
8 t_info
"skipping $T since it can't load the sendfile gem, yet"
13 t_plan
12 "large sendfile response for $model"
15 t_begin
"setup and startup" && {
16 rtmpfiles curl_out a b c slow_a slow_b
18 echo 'require "sendfile"' >> $unicorn_config
19 echo 'def (::IO).copy_stream(*x); abort "NO"; end' >> $unicorn_config
21 # can't load Rack::Lint here since it clobbers body#to_path
22 rainbows
-E none
-D large-file-response.ru
-c $unicorn_config
26 t_begin
"read random blob sha1" && {
27 random_blob_sha1
=$
(rsha1
< random_blob
)
28 three_sha1
=$
(cat random_blob random_blob random_blob | rsha1
)
31 t_begin
"send keepalive HTTP/1.1 requests in parallel" && {
32 for i
in $a $b $c $slow_a $slow_b
34 curl
-sSf http
://$listen/random_blob \
35 http
://$listen/random_blob \
36 http
://$listen/random_blob | rsha1
> $i &
39 for i
in $a $b $c $slow_a $slow_b
41 test x$
(cat $i) = x
$three_sha1
45 t_begin
"send a batch of abortive HTTP/1.1 requests in parallel" && {
46 for i
in $a $b $c $slow_a $slow_b
50 curl
-sSf --max-time 2 --limit-rate 1K \
51 http
://$listen/random_blob
>/dev
/null ||
echo ok
> $i
57 t_begin
"all requests timed out" && {
58 for i
in $a $b $c $slow_a $slow_b
64 s
='$NF ~ /worker_connections=[0-9]+/{gsub(/[^0-9]/,"",$3); print $3; exit}'
65 t_begin
"check proc to ensure file is closed properly (Linux only)" && {
66 worker_pid
=$
(awk "$s" < $r_err)
68 if test -d /proc
/$worker_pid/fd
70 if ls -l /proc
/$worker_pid/fd |
grep random_blob
72 t_info
"random_blob file is open ($model)"
75 t_info
"/proc/$worker_pid/fd not found"
79 t_begin
"send a bunch of HTTP/1.1 requests in parallel" && {
81 curl
-sSf --limit-rate 5M http
://$listen/random_blob | \
85 curl
-sSf --limit-rate 6M http
://$listen/random_blob | \
91 curl
-sSf http
://$listen/random_blob | rsha1
> $i
95 for i
in $a $b $c $slow_a $slow_b
97 test x$
(cat $i) = x
$random_blob_sha1
101 # this was a problem during development
102 t_begin
"HTTP/1.0 test" && {
103 sha1
=$
( (curl
-0 -sSf http
://$listen/random_blob
&&
104 echo ok
>$ok) | rsha1
)
105 test $sha1 = $random_blob_sha1
106 test xok
= x$
(cat $ok)
109 t_begin
"HTTP/0.9 test" && {
111 printf 'GET /random_blob\r\n'
112 rsha1
< $fifo > $tmp &
115 ) | socat
- TCP
:$listen > $fifo
116 test $
(cat $tmp) = $random_blob_sha1
117 test xok
= x$
(cat $ok)
120 t_begin
"check proc to ensure file is closed properly (Linux only)" && {
121 worker_pid
=$
(awk "$s" < $r_err)
122 test -n "$worker_pid"
123 if test -d /proc
/$worker_pid/fd
125 if ls -l /proc
/$worker_pid/fd |
grep random_blob
127 t_info
"random_blob file is open ($model)"
130 t_info
"/proc/$worker_pid/fd not found"
134 t_begin
"shutdown server" && {
135 kill -QUIT $rainbows_pid
140 t_begin
"check stderr" && check_stderr