send proper 416 responses
[rainbows.git] / t / t0500-cramp-streaming.sh
blobb97853d8597167e372c7e28229fb7cce708feb9e
1 #!/bin/sh
2 . ./test-lib.sh
3 case $model in
4 EventMachine) ;;
5 *)
6 t_info "skipping $T since it's not compatible with $model"
7 exit 0
8 ;;
9 esac
10 require_check cramp Cramp::VERSION
12 t_plan 7 "streaming test for Cramp"
14 CONFIG_RU=cramp/streaming.ru
16 t_begin "setup and start" && {
17 rainbows_setup
18 rtmpfiles a b c curl_err expect
20 # requiring Rubygems for this test only since Cramp depends on
21 # pre versions of several gems
22 # Like the rest of the EM/async stuff, it's not Rack::Lint compatible
23 rainbows -E deployment -D $CONFIG_RU -c $unicorn_config
24 rainbows_wait_start
27 # this will spew any unexpected input to stdout and be silent on success
28 check () {
30 i=0
31 while read hello world
33 t1=$(date +%s)
34 diff=$(($t1 - $t0))
35 t_info "i=$i diff=$diff hello=$hello world=$world"
36 test $diff -ge 1 || echo "$i: diff: $diff < 1 second"
37 t0=$t1
38 test xHello = x"$hello" || echo "$i: Hello != $hello"
39 test xWorld = x"$world" || echo "$i: World != $world"
40 i=$(($i + 1))
41 test $i -le 3 || echo "$i: $i > 3"
42 done
46 t_begin "send async requests off in parallel" && {
47 t0=$(date +%s)
48 curl --no-buffer -sSf http://$listen/ 2>> $curl_err | check >$a 2>&1 &
49 curl --no-buffer -sSf http://$listen/ 2>> $curl_err | check >$b 2>&1 &
50 curl --no-buffer -sSf http://$listen/ 2>> $curl_err | check >$c 2>&1 &
53 t_begin "wait for curl terminations" && {
54 wait
55 t1=$(date +%s)
56 elapsed=$(( $t1 - $t0 ))
57 t_info "elapsed=$elapsed (should be 4-5s)"
60 t_begin "termination signal sent" && {
61 kill $rainbows_pid
64 t_begin "no errors from curl" && {
65 test ! -s $curl_err
68 t_begin "no errors in stderr" && check_stderr
70 t_begin "silence is golden" && {
71 test ! -s $a
72 test ! -s $b
73 test ! -s $c
76 t_done