4 t_plan
6 "pipelined sendfile response for $model"
6 t_begin
"setup and startup" && {
7 rtmpfiles err out dd_fifo
9 echo 'require "sendfile"' >> $unicorn_config
10 echo 'def (::IO).copy_stream(*x); abort "NO"; end' >> $unicorn_config
12 # can't load Rack::Lint here since it clobbers body#to_path
13 rainbows
-E none
-D large-file-response.ru
-c $unicorn_config
17 t_begin
"read random blob sha1" && {
18 random_blob_sha1
=$
(rsha1
< random_blob
)
25 expect = ENV["random_blob_sha1"]
26 kcar = Kcar::Response.new($stdin, {})
29 status, headers, body = kcar.rack
30 dig = Digest::SHA1.new
31 body.each { |buf| dig << buf ; nr += buf.size }
33 sha1 == expect or abort "mismatch: sha1=#{sha1} != expect=#{expect}"
36 $stdout.syswrite("ok\n")
39 t_begin
"staggered pipeline of 3 HTTP requests" && {
40 req
='GET /random_blob HTTP/1.1\r\nHost: example.com\r\n'
43 export random_blob_sha1
44 $RUBY -e "$script" < $fifo >> $ok &
45 printf "$req"'X-Req:0\r\n\r\n'
51 printf 'X-Req:1\r\n\r\n' >&6
55 printf 'X-Req:2\r\n' >&6
57 printf 'Connection: close\r\n\r' >&6
61 ) < $dd_fifo > $fifo &
64 ) | socat
- TCP
:$listen > $dd_fifo
65 test 2 -eq $
(grep '^ok$' $ok |
wc -l)
68 t_begin
"pipeline 3 HTTP requests" && {
70 req
='GET /random_blob HTTP/1.1\r\nHost: example.com\r\n'
71 req
="$req"'\r\n'"$req"'\r\n'"$req"
72 req
="$req"'Connection: close\r\n\r\n'
74 export random_blob_sha1
75 $RUBY -e "$script" < $fifo >> $ok &
79 ) | socat
- TCP
:$listen > $fifo
80 test 2 -eq $
(grep '^ok$' $ok |
wc -l)
83 t_begin
"shutdown server" && {
84 kill -QUIT $rainbows_pid
87 t_begin
"check stderr" && check_stderr