t/GNUmakefile: cleanup test dependencies
[rainbows.git] / t / t0101-rack-input-trailer.sh
blob1dfae6a81267659d983faf3929eed7ef6f521aa8
1 #!/bin/sh
2 . ./test-lib.sh
3 test -r random_blob || die "random_blob required, run with 'make $0'"
5 t_plan 13 "input trailer test $model"
7 t_begin "setup and startup" && {
8 rtmpfiles curl_out
9 rainbows_setup $model
10 rainbows -D content-md5.ru -c $unicorn_config
11 rainbows_wait_start
14 t_begin "staggered trailer upload" && {
15 zero_md5="1B2M2Y8AsgTpgAmY7PhCfg=="
17 cat $fifo > $tmp &
18 printf 'PUT /s HTTP/1.1\r\n'
19 printf 'Host: example.com\r\n'
20 printf 'Transfer-Encoding: chunked\r\n'
21 printf 'Trailer: Content-MD5\r\n\r\n'
22 printf '0\r\nContent-MD5: '
23 sleep 5
24 printf '%s\r\n\r\n' $zero_md5
25 wait
26 echo ok > $ok
27 ) | socat - TCP:$listen > $fifo
28 test xok = x"$(cat $ok)"
31 t_begin "HTTP response is OK" && {
32 grep 'HTTP/1\.[01] 200 OK' $tmp
35 t_begin "upload small blob" && {
37 cat $fifo > $tmp &
38 echo hello world | content-md5-put
39 wait
40 echo ok > $ok
41 ) | socat - TCP:$listen > $fifo
42 test xok = x"$(cat $ok)"
45 t_begin "HTTP response is OK" && grep 'HTTP/1\.[01] 200 OK' $tmp
46 t_begin "no errors in stderr log" && check_stderr
48 t_begin "big blob request" && {
50 cat $fifo > $tmp &
51 content-md5-put < random_blob
52 wait
53 echo ok > $ok
54 ) | socat - TCP:$listen > $fifo
55 test xok = x"$(cat $ok)"
58 t_begin "HTTP response is OK" && grep 'HTTP/1\.[01] 200 OK' $tmp
59 t_begin "no errors in stderr log" && check_stderr
61 t_begin "staggered blob upload" && {
63 cat $fifo > $tmp &
65 dd bs=164 count=1 < random_blob
66 sleep 2
67 dd bs=4545 count=1 < random_blob
68 sleep 2
69 dd bs=1234 count=1 < random_blob
70 echo subok > $ok
71 ) 2>/dev/null | content-md5-put
72 test xsubok = x"$(cat $ok)"
73 wait
74 echo ok > $ok
75 ) | socat - TCP:$listen > $fifo
76 test xok = x"$(cat $ok)"
79 t_begin "HTTP response is OK" && grep 'HTTP/1\.[01] 200 OK' $tmp
81 t_begin "no errors in stderr log" && check_stderr
83 t_begin "kill server" && {
84 kill $rainbows_pid
87 t_done