2 # Copyright (c) 2009 Rainbows! developers
8 # defaulting to Base would unfortunately fail some concurrency tests
10 t_info
"model undefined, defaulting to $model"
15 RUBY_VERSION
=${RUBY_VERSION-$($RUBY -e 'puts RUBY_VERSION')}
16 t_pfx
=$PWD/trash
/$model.
$T-$RUBY_VERSION
22 test -x $PWD/bin
/unused_listen || die
"must be run in 't' directory"
27 while ! test -s "$path" && test $nr -gt 0
34 # requires $1 and prints out the value of $2
38 if ! $RUBY -r$lib -e "puts $const" >/dev
/null
2>&1
40 t_info
"skipping $T since we don't have $lib"
45 # given a list of variable names, create temporary files and assign
46 # the pathnames to those variables
58 T_RM_LIST
="$T_RM_LIST $_tmp"
62 T_RM_LIST
="$T_RM_LIST $_tmp"
66 T_OK_RM_LIST
="$T_OK_RM_LIST $_tmp"
76 sed -e "s/^/$id:/" < $_file
83 if grep -i Error
$_r_err
85 die
"Errors found in $_r_err"
86 elif grep SIGKILL
$_r_err
88 die
"SIGKILL found in $_r_err"
92 # rainbows_setup [ MODEL [ WORKER_CONNECTIONS ] ]
95 rtmpfiles unicorn_config pid r_err r_out fifo tmp ok
96 cat > $unicorn_config <<EOF
102 # close my-tap-lib.sh FDs
103 unless ENV['UNICORN_FD']
104 IO.for_fd(3).close rescue nil
105 IO.for_fd(4).close rescue nil
108 before_fork do |server, worker|
109 # test script will block while reading from $fifo,
110 # so notify the script on the first worker we spawn
111 # by opening the FIFO
113 File.open("$fifo", "wb") { |fp| fp.syswrite "START" }
118 # set a higher default for tests since we run heavily-loaded
119 # boxes and sometimes sleep 1s in tests
125 test $# -eq 2 && echo " worker_connections $2"
128 echo " keepalive_timeout $3"
130 echo " keepalive_timeout $kato"
134 echo " keepalive_timeout $kato"
140 rainbows_wait_start
() {
141 # "cat $fifo" will block until the before_fork hook is called in
142 # the Unicorn config file
143 test xSTART
= x
"$(cat $fifo)"
144 rainbows_pid
=$
(cat $pid)
148 _cmd
="$(which sha1sum 2>/dev/null || :)"
149 test -n "$_cmd" || _cmd
="$(which openssl 2>/dev/null || :) sha1"
150 test "$_cmd" != " sha1" || _cmd
="$(which gsha1sum 2>/dev/null || :)"
152 # last resort, see comments in sha1sum.rb for reasoning
153 test -n "$_cmd" || _cmd
=sha1sum.rb
154 expr "$($_cmd < random_blob)" : '\([a-f0-9]\{40\}\)'
158 Rev
) require_check
rev Rev
::VERSION
;;
159 Revactor
) require_check revactor Revactor
::VERSION
;;
160 EventMachine
) require_check eventmachine EventMachine
::VERSION
;;