diff options
Diffstat (limited to 't/t0027-nil-copy_stream.sh')
-rw-r--r-- | t/t0027-nil-copy_stream.sh | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/t/t0027-nil-copy_stream.sh b/t/t0027-nil-copy_stream.sh new file mode 100644 index 0000000..03c7f0a --- /dev/null +++ b/t/t0027-nil-copy_stream.sh @@ -0,0 +1,68 @@ +#!/bin/sh +. ./test-lib.sh +test -r random_blob || die "random_blob required, run with 'make $0'" + +case $model in +ThreadSpawn|WriterThreadSpawn|ThreadPool|WriterThreadPool|Base) ;; +XEpollThreadSpawn) ;; +*) + t_info "skipping $T since it doesn't use copy_stream" + exit 0 + ;; +esac + +t_plan 7 "large file 'copy_stream nil' test for $model" + +t_begin "setup and startup" && { + rtmpfiles curl_out + rainbows_setup $model + cat >> $unicorn_config <<EOF +Rainbows! do + copy_stream nil +end +EOF + rainbows -E none -D large-file-response.ru -c $unicorn_config + rainbows_wait_start +} + +t_begin "read random blob sha1 and size" && { + random_blob_sha1=$(rsha1 < random_blob) + random_blob_size=$(wc -c < random_blob) +} + +t_begin "send a series HTTP/1.1 requests sequentially" && { + for i in a b c + do + sha1=$( (curl -sSfv http://$listen/random_blob && + echo ok >$ok) | rsha1) + test $sha1 = $random_blob_sha1 + test xok = x$(cat $ok) + done +} + +# this was a problem during development +t_begin "HTTP/1.0 test" && { + sha1=$( (curl -0 -sSfv http://$listen/random_blob && + echo ok >$ok) | rsha1) + test $sha1 = $random_blob_sha1 + test xok = x$(cat $ok) +} + +t_begin "HTTP/0.9 test" && { + ( + printf 'GET /random_blob\r\n' + rsha1 < $fifo > $tmp & + wait + echo ok > $ok + ) | socat - TCP:$listen > $fifo + test $(cat $tmp) = $random_blob_sha1 + test xok = x$(cat $ok) +} + +t_begin "shutdown server" && { + kill -QUIT $rainbows_pid +} + +t_begin "check stderr" && check_stderr + +t_done |