stream_response_epoll: our most "special" concurrency option yet
[rainbows.git] / t / t0200-async-response.sh
blob11917f04bda9a6a99ec396a3104df29a081942ca
1 #!/bin/sh
2 CONFIG_RU=${CONFIG_RU-'async-response.ru'}
3 . ./test-lib.sh
5 skip_models Base WriterThreadPool WriterThreadSpawn
6 skip_models StreamResponseEpoll
8 case $CONFIG_RU in
9 *no-autochunk.ru)
10 t_plan 7 "async response w/o autochunk for $model"
11 skip_autochunk=true
14 t_plan 6 "async response for $model"
15 skip_autochunk=false
17 esac
19 t_begin "setup and start" && {
20 rainbows_setup
21 rtmpfiles a b c curl_err
22 # can't load Rack::Lint here since it'll cause Rev to slurp
23 rainbows -E none -D $CONFIG_RU -c $unicorn_config
24 rainbows_wait_start
27 t_begin "send async requests off in parallel" && {
28 t0=$(date +%s)
29 ( curl --no-buffer -sSf http://$listen/ 2>> $curl_err | utee $a) &
30 ( curl --no-buffer -sSf http://$listen/ 2>> $curl_err | utee $b) &
31 ( curl --no-buffer -sSf http://$listen/ 2>> $curl_err | utee $c) &
32 wait
33 t1=$(date +%s)
36 t_begin "ensure elapsed requests were processed in parallel" && {
37 elapsed=$(( $t1 - $t0 ))
38 echo "elapsed=$elapsed < 30"
39 test $elapsed -lt 30
42 t_begin "termination signal sent" && {
43 kill $rainbows_pid
46 dbgcat a
47 dbgcat b
48 dbgcat c
49 dbgcat r_err
50 dbgcat curl_err
52 t_begin "no errors from curl" && {
53 test ! -s $curl_err
56 t_begin "no errors in stderr" && check_stderr
58 dbgcat r_err
60 if $skip_autochunk
61 then
62 t_begin "no responses are chunked" && {
63 test x"$(cat $a)" = x0123456789
64 test x"$(cat $b)" = x0123456789
65 test x"$(cat $c)" = x0123456789
69 t_done