Add -N or --no-default-middleware option.
[rainbows.git] / t / t0401-em-async-tailer.sh
blob2c11cc09aa8879328ea2546ea8cc14a63d069858
1 #!/bin/sh
2 nr=${nr-5}
3 . ./test-lib.sh
4 case $model in
5 NeverBlock|EventMachine) ;;
6 *)
7 t_info "skipping $T since it's not compatible with $model"
8 exit 0
9 ;;
10 esac
12 t_plan 8 "async_tailer test for test for EM"
14 CONFIG_RU=async_examples/async_tailer.ru
16 t_begin "setup and start" && {
17 rainbows_setup
18 rtmpfiles a b c curl_err TAIL_LOG_FILE expect
20 printf '<h1>Async Tailer</h1><pre>' >> $expect
22 export TAIL_LOG_FILE
24 # this does not does not support Rack::Lint
25 rainbows -E deployment -D $CONFIG_RU -c $unicorn_config
26 rainbows_wait_start
29 t_begin "send async requests off in parallel" && {
30 t0=$(date +%s)
31 curl --no-buffer -sSf http://$listen/ > $a 2>> $curl_err &
32 curl_a=$!
33 curl --no-buffer -sSf http://$listen/ > $b 2>> $curl_err &
34 curl_b=$!
35 curl --no-buffer -sSf http://$listen/ > $c 2>> $curl_err &
36 curl_c=$!
39 t_begin "generate log output" && {
40 for i in $(awk "BEGIN {for(i=0;i<$nr;i++) print i}" < /dev/null)
42 date >> $TAIL_LOG_FILE
43 sleep 1
44 done
45 # sometimes tail(1) can be slow
46 sleep 2
49 t_begin "kill curls and wait for termination" && {
50 kill $curl_a $curl_b $curl_c
51 wait
52 t1=$(date +%s)
53 elapsed=$(( $t1 - $t0 ))
54 t_info "elapsed=$elapsed"
57 t_begin "termination signal sent" && {
58 kill -QUIT $rainbows_pid
61 t_begin "no errors from curl" && {
62 test ! -s $curl_err
65 t_begin "no errors in stderr" && check_stderr
67 t_begin "responses match expected" && {
68 cat $TAIL_LOG_FILE >> $expect
69 cmp $expect $a
70 cmp $expect $b
71 cmp $expect $c
74 t_done