summary refs log tree commit homepage
path: root/t/t0043-quit-keepalive-disconnect.sh
blob: a98ce7eae1e11911b164fca2a30a2ce551ae9986 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
. ./test-lib.sh
case $model in
Coolio|CoolioThreadSpawn|CoolioThreadPool|EventMachine) ;;
Epoll|XEpoll|XEpollThreadPool|XEpollThreadSpawn) ;;
*)
	t_info "$0 not supported for $model"
	exit 0
	;;
esac

t_plan 7 "keepalive clients disconnected on SIGQUIT for $model"

t_begin "setup and start" && {
	rainbows_setup $model 50 30
	rainbows -E none -D env.ru -c $unicorn_config
	rainbows_wait_start
}

t_begin "start a keepalive request" && {
	(
		cat < $fifo > $tmp &
		printf 'GET / HTTP/1.1\r\nHost: example.com\r\n\r\n'
		wait
	) | socat - TCP4:$listen > $fifo &
}

t_begin "wait for response" && {
	while ! tail -1 < $tmp | grep '}$' >/dev/null
	do
		sleep 1
	done
}

t_begin "stop Rainbows! gracefully" && {
	t0=$(unix_time)
	kill -QUIT $rainbows_pid
}

t_begin "keepalive client disconnected quickly" && {
	wait
	diff=$(( $(unix_time) - $t0 ))
	test $diff -le 2 || die "client diff=$diff > 2"
}

t_begin "wait for termination" && {
	while kill -0 $rainbows_pid
	do
		sleep 1
	done
	diff=$(( $(unix_time) - $t0 ))
	test $diff -le 4 || die "server diff=$diff > 4"
}

t_begin "check stderr" && {
	check_stderr
}

t_done