4 t_plan
6 "pipelined pipe response for $model"
6 t_begin
"setup and startup" && {
7 rtmpfiles err out dd_fifo
10 # can't load Rack::Lint here since it clobbers body#to_path
11 rainbows
-E none
-D fast-pipe-response.ru
-c $unicorn_config
15 t_begin
"read random blob sha1" && {
16 random_blob_sha1
=$
(rsha1
< random_blob
)
23 expect = ENV["random_blob_sha1"]
24 kcar = Kcar::Response.new($stdin, {})
27 status, headers, body = kcar.rack
28 dig = Digest::SHA1.new
29 body.each { |buf| dig << buf ; nr += buf.size }
31 sha1 == expect or abort "mismatch: sha1=#{sha1} != expect=#{expect}"
34 $stdout.syswrite("ok\n")
37 t_begin
"staggered pipeline of 3 HTTP requests" && {
38 req
='GET /random_blob HTTP/1.1\r\nHost: example.com\r\n'
41 export random_blob_sha1
42 $RUBY -e "$script" < $fifo >> $ok &
43 printf "$req"'X-Req:0\r\n\r\n'
49 printf 'X-Req:1\r\n\r\n' >&6
53 printf 'X-Req:2\r\n' >&6
55 printf 'Connection: close\r\n\r' >&6
59 ) < $dd_fifo > $fifo &
62 ) | socat
- TCP
:$listen > $dd_fifo
63 test 2 -eq $
(grep '^ok$' $ok |
wc -l)
66 t_begin
"pipeline 3 HTTP requests" && {
68 req
='GET /random_blob HTTP/1.1\r\nHost: example.com\r\n'
69 req
="$req"'\r\n'"$req"'\r\n'"$req"
70 req
="$req"'Connection: close\r\n\r\n'
72 export random_blob_sha1
73 $RUBY -e "$script" < $fifo >> $ok &
77 ) | socat
- TCP
:$listen > $fifo
78 test 2 -eq $
(grep '^ok$' $ok |
wc -l)
81 t_begin
"shutdown server" && {
82 kill -QUIT $rainbows_pid
85 t_begin
"check stderr" && check_stderr