stream_response_epoll: our most "special" concurrency option yet
[rainbows.git] / t / t0019-keepalive-cpu-usage.sh
blobb63c3c91bfa7b2f8ead1eba7864690a15b1448db
1 #!/bin/sh
2 if test -z "$V" || test 0 -eq "$V"
3 then
4 exit 0
5 fi
6 . ./test-lib.sh
7 skip_models WriterThreadSpawn WriterThreadPool Base
8 skip_models StreamResponseEpoll
10 t_plan 6 "keepalive_timeout CPU usage tests for $model"
12 t_begin "setup and start" && {
13 rainbows_setup $model 50 666
14 grep 'worker_connections 50' $unicorn_config
15 grep 'keepalive_timeout 666' $unicorn_config
16 rainbows -E deployment -D times.ru -c $unicorn_config
17 rainbows_wait_start
20 t_begin 'read current times' && {
21 eval "$(curl -sSf http://$listen/)"
22 before_utime=$utime
23 before_stime=$stime
24 echo "utime=$utime stime=$stime"
27 t_begin 'keepalive connections' && {
28 listen=$listen $RUBY -rsocket -e '
29 host, port = ENV["listen"].split(/:/)
30 port = port.to_i
31 socks = (1..49).map do |i|
32 s = TCPSocket.new(host, port)
33 # need to write something to get around deferred accepts
34 s.write "GET /#{i} HTTP/1.1\r\nHost: example.com\r\n\r\n"
35 s.readpartial 16384
37 end
38 sleep
39 ' &
40 ruby_pid=$!
41 for i in $(awk 'BEGIN { for(i=0;i<60;++i) print i }' </dev/null)
43 sleep 1
44 eval "$(curl -sSf http://$listen/)"
45 echo "utime[$i] $before_utime => $utime" \
46 "stime[$i] $before_stime => $stime"
47 done
48 kill $ruby_pid
51 t_begin "times not unreasonable" && {
52 echo "utime: $before_utime => $utime" \
53 "stime: $before_stime => $stime"
56 t_begin "killing succeeds" && {
57 kill $rainbows_pid
60 t_begin "check stderr" && {
61 check_stderr
64 t_done