test_isolate: bump versions and simplify
[rainbows.git] / t / t0402-em-async-keepalive.sh
blob24eb67817ee1e4948255c87030fea61a3366f72b
1 #!/bin/sh
2 . ./test-lib.sh
3 case $model in
4 NeverBlock|EventMachine) ;;
5 *)
6 t_info "skipping $T since it's not compatible with $model"
7 exit 0
8 ;;
9 esac
11 t_plan 9 "async_chunk_app test for test for EM"
13 CONFIG_RU=async_chunk_app.ru
15 t_begin "setup and start" && {
16 rainbows_setup
17 rtmpfiles a b c curl_err expect
19 # this does not does not support Rack::Lint
20 rainbows -E none -D $CONFIG_RU -c $unicorn_config
21 rainbows_wait_start
23 echo 'Hello World /0' >> $expect
24 echo 'Hello World /1' >> $expect
25 echo 'Hello World /2' >> $expect
28 t_begin "async.callback supports pipelining" && {
29 rm -f $tmp
30 t0=$(date +%s)
32 cat $fifo > $tmp &
33 printf 'GET /0 HTTP/1.1\r\nHost: example.com\r\n\r\n'
34 printf 'GET /1 HTTP/1.1\r\nHost: example.com\r\n\r\n'
35 printf 'GET /2 HTTP/1.0\r\nHost: example.com\r\n\r\n'
36 wait
37 ) | socat - TCP:$listen > $fifo
38 t1=$(date +%s)
39 elapsed=$(( $t1 - $t0 ))
40 t_info "elapsed=$elapsed $model.$0 ($t_current)"
41 test 3 -eq "$(fgrep 'HTTP/1.1 200 OK' $tmp | wc -l)"
44 t_begin "async.callback supports keepalive" && {
45 t0=$(date +%s)
46 curl -v --no-buffer -sSf http://$listen/[0-2] > $tmp 2>> $curl_err
47 t1=$(date +%s)
48 elapsed=$(( $t1 - $t0 ))
49 t_info "elapsed=$elapsed $model.$0 ($t_current)"
50 cmp $expect $tmp
51 test 2 -eq "$(fgrep 'Re-using existing connection!' $curl_err |wc -l)"
52 rm -f $curl_err
55 t_begin "send async requests off in parallel" && {
56 t0=$(date +%s)
57 curl --no-buffer -sSf http://$listen/[0-2] > $a 2>> $curl_err &
58 curl --no-buffer -sSf http://$listen/[0-2] > $b 2>> $curl_err &
59 curl --no-buffer -sSf http://$listen/[0-2] > $c 2>> $curl_err &
62 t_begin "wait for curl terminations" && {
63 wait
64 t1=$(date +%s)
65 elapsed=$(( $t1 - $t0 ))
66 t_info "elapsed=$elapsed"
69 t_begin "termination signal sent" && {
70 kill $rainbows_pid
73 t_begin "no errors from curl" && {
74 test ! -s $curl_err
77 t_begin "no errors in stderr" && check_stderr
79 t_begin "responses match expected" && {
80 cmp $expect $a
81 cmp $expect $b
82 cmp $expect $c
85 t_done