rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob 103b217b1705bbf3651a3febffcd832d67723d07 1146 bytes (raw)
$ git show v4.0.0:t/t0040-keepalive_requests-setting.sh	# shows this blob on the CLI

 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
 
#!/bin/sh
. ./test-lib.sh
skip_models StreamResponseEpoll
t_plan 6 "keepalive_requests limit tests for $model"

t_begin "setup and start" && {
	rainbows_setup $model 50 666
	rtmpfiles curl_out curl_err
	grep 'keepalive_timeout 666' $unicorn_config
	rainbows -E none -D env.ru -c $unicorn_config
	rainbows_wait_start
}

t_begin "curl requests hit default keepalive_requests limit" && {
	curl -sSfv http://$listen/[0-101] > $curl_out 2> $curl_err
	test 1 -eq $(grep 'Connection: close' $curl_err |wc -l)
	test 101 -eq $(grep 'Connection: keep-alive' $curl_err |wc -l)
}

t_begin "reload with smaller keepalive_requests limit" && {
	ed -s $unicorn_config <<EOF
,g/Rainbows!/
a
  keepalive_requests 5
.
w
EOF
	kill -HUP $rainbows_pid
	test x"$(cat $fifo)" = xSTART
}

t_begin "curl requests hit smaller keepalive_requests limit" && {
	rm -f $curl_out $curl_err
	curl -sSfv http://$listen/[1-13] > $curl_out 2> $curl_err
	test 2 -eq $(grep 'Connection: close' $curl_err |wc -l)
	test 11 -eq $(grep 'Connection: keep-alive' $curl_err |wc -l)
}

t_begin "killing succeeds" && {
	kill $rainbows_pid
}

t_begin "check stderr" && {
	check_stderr
}

t_done

git clone https://yhbt.net/rainbows.git