tests: rack.input trailer tests for all models
[rainbows.git] / t / lib-input-trailer.sh
blob4a946d481e5661b75a6bbe228df4448c6abac214
1 model=$1
2 . ./test-lib.sh
3 test -r random_blob || die "random_blob required, run with 'make $0'"
4 echo "input trailer test model=$model"
5 require_for_model
7 eval $(unused_listen)
8 rtmpfiles unicorn_config tmp r_err r_out pid fifo ok
9 rm -f $fifo
10 mkfifo $fifo
12 cat > $unicorn_config <<EOF
13 listen "$listen"
14 pid "$pid"
15 stderr_path "$r_err"
16 stdout_path "$r_out"
17 Rainbows! { use :$model }
18 EOF
20 rainbows -D content-md5.ru -c $unicorn_config
21 wait_for_pid $pid
23 echo "small blob"
25 echo hello world | content-md5-put
26 cat $fifo > $tmp &
27 wait
28 echo ok > $ok
29 ) | socat - TCP:$listen | utee $fifo
31 fgrep 'HTTP/1.1 200 OK' $tmp
32 test xok = x"$(cat $ok)"
33 ! grep Error $r_err
36 echo "big blob"
38 content-md5-put < random_blob
39 cat $fifo > $tmp &
40 wait
41 echo ok > $ok
42 ) | socat - TCP:$listen | utee $fifo
44 fgrep 'HTTP/1.1 200 OK' $tmp
45 test xok = x"$(cat $ok)"
46 ! grep Error $r_err
48 echo "staggered blob"
51 dd bs=164 count=1 < random_blob
52 sleep 2
53 dd bs=4545 count=1 < random_blob
54 sleep 2
55 dd bs=1234 count=1 < random_blob
56 echo ok > $ok
57 ) 2>/dev/null | content-md5-put
58 test xok = x"$(cat $ok)"
59 cat $fifo > $tmp &
60 wait
61 echo ok > $ok
62 ) | socat - TCP:$listen | utee $fifo
64 fgrep 'HTTP/1.1 200 OK' $tmp
65 test xok = x"$(cat $ok)"
66 ! grep Error $r_err
69 kill $(cat $pid)