5 Coolio|NeverBlock|EventMachine
) ;;
7 t_info
"skipping $T since it's not compatible with $model"
12 t_plan
12 "async_chunk_app test for test for $model"
14 CONFIG_RU
=async_chunk_app.ru
16 t_begin
"setup and start" && {
18 rtmpfiles a b c curl_err expect
20 # this does not does not support Rack::Lint
21 rainbows
-E none
-D $CONFIG_RU -c $unicorn_config
24 echo 'Hello World /0' >> $expect
25 echo 'Hello World /1' >> $expect
26 echo 'Hello World /2' >> $expect
29 t_begin
"async.callback supports pipelining" && {
34 printf 'GET /0 HTTP/1.1\r\nHost: example.com\r\n\r\n'
35 printf 'GET /1 HTTP/1.1\r\nHost: example.com\r\n\r\n'
36 printf 'GET /2 HTTP/1.0\r\nHost: example.com\r\n\r\n'
38 ) | socat
- TCP
:$listen > $fifo
40 elapsed
=$
(( $t1 - $t0 ))
41 t_info
"elapsed=$elapsed $model.$0 ($t_current)"
42 test 3 -eq "$(fgrep 'HTTP/1.1 200 OK' $tmp | wc -l)"
43 test 3 -eq "$(grep '^Hello ' $tmp | wc -l)"
44 test 3 -eq "$(grep 'World ' $tmp | wc -l)"
47 t_begin
"async.callback supports delayed pipelining" && {
52 printf 'GET /0 HTTP/1.1\r\nHost: example.com\r\n\r\n'
54 printf 'GET /1 HTTP/1.1\r\nHost: example.com\r\n\r\n'
56 printf 'GET /2 HTTP/1.0\r\nHost: example.com\r\n\r\n'
58 ) | socat
- TCP
:$listen > $fifo
60 elapsed
=$
(( $t1 - $t0 ))
61 t_info
"elapsed=$elapsed $model.$0 ($t_current)"
62 test 3 -eq "$(fgrep 'HTTP/1.1 200 OK' $tmp | wc -l)"
63 test 3 -eq "$(grep '^Hello ' $tmp | wc -l)"
64 test 3 -eq "$(grep 'World ' $tmp | wc -l)"
67 t_begin
"async.callback supports pipelining with delay $DELAY" && {
72 printf 'GET /0 HTTP/1.1\r\nX-Delay: %d\r\n' $DELAY
73 printf 'Host: example.com\r\n\r\n'
74 printf 'GET /1 HTTP/1.1\r\nX-Delay: %d\r\n' $DELAY
75 printf 'Host: example.com\r\n\r\n'
76 printf 'GET /2 HTTP/1.0\r\nX-Delay: %d\r\n' $DELAY
77 printf 'Host: example.com\r\n\r\n'
79 ) | socat
- TCP
:$listen > $fifo
81 elapsed
=$
(( $t1 - $t0 ))
83 t_info
"elapsed=$elapsed $model.$0 ($t_current) min=$min"
84 test $elapsed -ge $min
85 test 3 -eq "$(fgrep 'HTTP/1.1 200 OK' $tmp | wc -l)"
86 test 3 -eq "$(grep '^Hello ' $tmp | wc -l)"
87 test 3 -eq "$(grep 'World ' $tmp | wc -l)"
90 t_begin
"async.callback supports keepalive" && {
92 curl
-v --no-buffer -sSf http
://$listen/[0-2] > $tmp 2>> $curl_err
94 elapsed
=$
(( $t1 - $t0 ))
95 t_info
"elapsed=$elapsed $model.$0 ($t_current)"
97 test 2 -eq "$(fgrep 'Re-using existing connection!' $curl_err |wc -l)"
101 t_begin
"async.callback supports keepalive with delay $DELAY" && {
103 curl
-v --no-buffer -sSf -H "X-Delay: $DELAY" \
104 http
://$listen/[0-2] > $tmp 2>> $curl_err
106 elapsed
=$
(( $t1 - $t0 ))
107 min
=$
(( $DELAY * 3 ))
108 t_info
"elapsed=$elapsed $model.$0 ($t_current) min=$min"
109 test $elapsed -ge $min
111 test 2 -eq "$(fgrep 'Re-using existing connection!' $curl_err |wc -l)"
115 t_begin
"send async requests off in parallel" && {
117 curl
--no-buffer -sSf http
://$listen/[0-2] > $a 2>> $curl_err &
118 curl
--no-buffer -sSf http
://$listen/[0-2] > $b 2>> $curl_err &
119 curl
--no-buffer -sSf http
://$listen/[0-2] > $c 2>> $curl_err &
122 t_begin
"wait for curl terminations" && {
125 elapsed
=$
(( $t1 - $t0 ))
126 t_info
"elapsed=$elapsed"
129 t_begin
"termination signal sent" && {
133 t_begin
"no errors from curl" && {
137 t_begin
"no errors in stderr" && check_stderr
139 t_begin
"responses match expected" && {