eliminate G constant and just use the Rainbows! module
[rainbows.git] / t / t0300-async_sinatra.sh
bloba623916480a5eaa9d1ad511fd4444ea1147abe39
1 #!/bin/sh
2 . ./test-lib.sh
4 # n - number of seconds to sleep
5 n=10
6 CONFIG_RU=async_sinatra.ru
7 case $model in
8 NeverBlock|EventMachine) ;;
9 *)
10 t_info "skipping $T since it's not compatible with $model"
11 exit 0
13 esac
15 t_plan 7 "async_sinatra test for EM"
17 t_begin "setup and start" && {
18 rainbows_setup
19 rtmpfiles a b c curl_err
21 # Async Sinatra does not support Rack::Lint
22 rainbows -E none -D $CONFIG_RU -c $unicorn_config
23 rainbows_wait_start
26 t_begin "send async requests off in parallel" && {
27 t0=$(date +%s)
28 ( curl --no-buffer -sSf http://$listen/$n 2>> $curl_err | utee $a) &
29 ( curl --no-buffer -sSf http://$listen/$n 2>> $curl_err | utee $b) &
30 ( curl --no-buffer -sSf http://$listen/$n 2>> $curl_err | utee $c) &
33 t_begin "ensure elapsed requests were processed in parallel" && {
34 wait
35 t1=$(date +%s)
36 elapsed=$(( $t1 - $t0 ))
37 echo "elapsed=$elapsed < 30"
38 test $elapsed -lt 30
41 t_begin "termination signal sent" && {
42 kill $rainbows_pid
45 dbgcat a
46 dbgcat b
47 dbgcat c
48 dbgcat r_err
49 dbgcat curl_err
51 t_begin "no errors from curl" && {
52 test ! -s $curl_err
55 t_begin "no errors in stderr" && check_stderr
57 dbgcat r_err
59 t_begin "no responses are chunked" && {
60 test x"$(cat $a)" = x"delayed for $n seconds"
61 test x"$(cat $b)" = x"delayed for $n seconds"
62 test x"$(cat $c)" = x"delayed for $n seconds"
65 t_done