t0015: even less racy fix
[rainbows.git] / t / t9100-thread-timeout.sh
blob422052efe3a576329f4ae2259e678e8ada845e85
1 #!/bin/sh
2 . ./test-lib.sh
3 case $model in
4 ThreadSpawn|ThreadPool) ;;
5 RevThreadSpawn|RevThreadPool) ;;
6 CoolioThreadSpawn|CoolioThreadPool) ;;
7 *) t_info "$0 is only compatible with Thread*"; exit 0 ;;
8 esac
10 t_plan 6 "ThreadTimeout Rack middleware test for $model"
12 t_begin "configure and start" && {
13 rtmpfiles curl_err
14 rainbows_setup
15 rainbows -D t9100.ru -c $unicorn_config
16 rainbows_wait_start
19 t_begin "normal request should not timeout" && {
20 test x"HI" = x"$(curl -sSf http://$listen/ 2>> $curl_err)"
23 t_begin "sleepy request times out with 408" && {
24 rm -f $ok
25 curl -sSf http://$listen/2 2>> $curl_err || > $ok
26 test -e $ok
27 grep 408 $curl_err
30 t_begin "short requests do not timeout while making a long one" && {
31 rm -f $ok $curl_err
32 > $ok
33 curl -sSf http://$listen/2 2>$curl_err >/dev/null &
35 for i in $(awk </dev/null 'BEGIN{for(i=20;--i>=0;)print i}')
37 curl -sSf http://$listen/0.1 >> $ok 2>&1 &
38 test x"HI" = x"$(curl -sSf http://$listen/0.05)"
39 done
40 wait
42 test x"HI" = x"$(curl -sSf http://$listen/)"
43 wait
44 test -f $ok
45 test 20 -eq $(grep '^HI$' $ok | wc -l)
46 test x = x"$(grep -v '^HI$' $ok)"
47 grep 408 $curl_err
50 t_begin "kill server" && {
51 kill $rainbows_pid
54 t_begin "no errors in Rainbows! stderr" && {
55 check_stderr
58 t_done