tests: replace non-portable "date +%s" with ruby equivalent
[rainbows.git] / t / t0043-quit-keepalive-disconnect.sh
bloba98ce7eae1e11911b164fca2a30a2ce551ae9986
1 #!/bin/sh
2 . ./test-lib.sh
3 case $model in
4 Coolio|CoolioThreadSpawn|CoolioThreadPool|EventMachine) ;;
5 Epoll|XEpoll|XEpollThreadPool|XEpollThreadSpawn) ;;
6 *)
7 t_info "$0 not supported for $model"
8 exit 0
9 ;;
10 esac
12 t_plan 7 "keepalive clients disconnected on SIGQUIT for $model"
14 t_begin "setup and start" && {
15 rainbows_setup $model 50 30
16 rainbows -E none -D env.ru -c $unicorn_config
17 rainbows_wait_start
20 t_begin "start a keepalive request" && {
22 cat < $fifo > $tmp &
23 printf 'GET / HTTP/1.1\r\nHost: example.com\r\n\r\n'
24 wait
25 ) | socat - TCP4:$listen > $fifo &
28 t_begin "wait for response" && {
29 while ! tail -1 < $tmp | grep '}$' >/dev/null
31 sleep 1
32 done
35 t_begin "stop Rainbows! gracefully" && {
36 t0=$(unix_time)
37 kill -QUIT $rainbows_pid
40 t_begin "keepalive client disconnected quickly" && {
41 wait
42 diff=$(( $(unix_time) - $t0 ))
43 test $diff -le 2 || die "client diff=$diff > 2"
46 t_begin "wait for termination" && {
47 while kill -0 $rainbows_pid
49 sleep 1
50 done
51 diff=$(( $(unix_time) - $t0 ))
52 test $diff -le 4 || die "server diff=$diff > 4"
55 t_begin "check stderr" && {
56 check_stderr
59 t_done