3 test -r random_blob || die
"random_blob required, run with 'make $0'"
7 t_info
"skipping $T since it can't load the sendfile gem, yet"
12 t_plan
12 "large sendfile response for $model"
14 t_begin
"setup and startup" && {
15 rtmpfiles curl_out a b c slow_a slow_b
17 echo 'require "sendfile"' >> $unicorn_config
18 echo 'def (::IO).copy_stream(*x); abort "NO"; end' >> $unicorn_config
20 # can't load Rack::Lint here since it clobbers body#to_path
21 rainbows
-E none
-D large-file-response.ru
-c $unicorn_config
25 t_begin
"read random blob sha1" && {
26 random_blob_sha1
=$
(rsha1
< random_blob
)
27 three_sha1
=$
(cat random_blob random_blob random_blob | rsha1
)
30 t_begin
"send keepalive HTTP/1.1 requests in parallel" && {
31 for i
in $a $b $c $slow_a $slow_b
33 curl
-sSf http
://$listen/random_blob \
34 http
://$listen/random_blob \
35 http
://$listen/random_blob | rsha1
> $i &
38 for i
in $a $b $c $slow_a $slow_b
40 test x$
(cat $i) = x
$three_sha1
44 t_begin
"send a batch of abortive HTTP/1.1 requests in parallel" && {
45 for i
in $a $b $c $slow_a $slow_b
49 curl
-sSf --max-time 2 --limit-rate 1K \
50 http
://$listen/random_blob
>/dev
/null ||
echo ok
> $i
56 t_begin
"all requests timed out" && {
57 for i
in $a $b $c $slow_a $slow_b
63 s
='$NF ~ /worker_connections=[0-9]+/{gsub(/[^0-9]/,"",$3); print $3; exit}'
64 t_begin
"check proc to ensure file is closed properly (Linux only)" && {
65 worker_pid
=$
(awk "$s" < $r_err)
67 if test -d /proc
/$worker_pid/fd
69 if ls -l /proc
/$worker_pid/fd |
grep random_blob
71 t_info
"random_blob file is open ($model)"
74 t_info
"/proc/$worker_pid/fd not found"
78 t_begin
"send a bunch of HTTP/1.1 requests in parallel" && {
80 curl
-sSf --limit-rate 5M http
://$listen/random_blob | \
84 curl
-sSf --limit-rate 6M http
://$listen/random_blob | \
90 curl
-sSf http
://$listen/random_blob | rsha1
> $i
94 for i
in $a $b $c $slow_a $slow_b
96 test x$
(cat $i) = x
$random_blob_sha1
100 # this was a problem during development
101 t_begin
"HTTP/1.0 test" && {
102 sha1
=$
( (curl
-0 -sSf http
://$listen/random_blob
&&
103 echo ok
>$ok) | rsha1
)
104 test $sha1 = $random_blob_sha1
105 test xok
= x$
(cat $ok)
108 t_begin
"HTTP/0.9 test" && {
110 printf 'GET /random_blob\r\n'
111 rsha1
< $fifo > $tmp &
114 ) | socat
- TCP
:$listen > $fifo
115 test $
(cat $tmp) = $random_blob_sha1
116 test xok
= x$
(cat $ok)
119 t_begin
"check proc to ensure file is closed properly (Linux only)" && {
120 worker_pid
=$
(awk "$s" < $r_err)
121 test -n "$worker_pid"
122 if test -d /proc
/$worker_pid/fd
124 if ls -l /proc
/$worker_pid/fd |
grep random_blob
126 t_info
"random_blob file is open ($model)"
129 t_info
"/proc/$worker_pid/fd not found"
133 t_begin
"shutdown server" && {
134 kill -QUIT $rainbows_pid
139 t_begin
"check stderr" && check_stderr