diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-12-28 01:14:43 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-12-28 01:34:49 +0000 |
commit | 46d79be0ad3de48ef0a677537becb3508ccad31e (patch) | |
tree | d04ae95b99c7bee6a1e72fb050685403bcdc4a5d /t | |
parent | ef66567984780b2ce8daa155c367bcf7e049ab77 (diff) | |
download | rainbows-46d79be0ad3de48ef0a677537becb3508ccad31e.tar.gz |
This will allow servers to limit the number of keepalive requests that can be made over a single connection to prevent denial-of-service and also to improve fairness in load-balancing.
Diffstat (limited to 't')
-rwxr-xr-x | t/t0040-keepalive_requests-setting.sh | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/t/t0040-keepalive_requests-setting.sh b/t/t0040-keepalive_requests-setting.sh new file mode 100755 index 0000000..aee6cd3 --- /dev/null +++ b/t/t0040-keepalive_requests-setting.sh @@ -0,0 +1,51 @@ +#!/bin/sh +. ./test-lib.sh +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 + ed -s $unicorn_config <<EOF +,s/listen.*/&, :tcp_nodelay => true/ +w +EOF + grep nodelay $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 |