From 2f8ed953decce975307a6c5b39330af816e184bc Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 24 Oct 2009 12:20:58 -0700 Subject: tests: common setup and wait_start functions Instead of sleeping and waiting for a PID file to appear, just use a named-pipe and block on it in the test scripts since we know Unicorn won't attempt to fork until sockets are already bound. --- t/lib-async-response.sh | 16 +++------------- t/lib-graceful.sh | 16 +++------------- t/lib-input-trailer.sh | 14 ++------------ t/lib-large-file-response.sh | 13 ++----------- t/lib-parser-error.sh | 14 ++------------ t/lib-rack-input-hammer.sh | 17 +++-------------- t/lib-reopen-logs.sh | 16 +++------------- t/lib-simple-http.sh | 17 ++--------------- t/t9000-rack-app-pool.sh | 19 +++---------------- t/test-lib.sh | 40 +++++++++++++++++++++++++++++++++++++++- 10 files changed, 62 insertions(+), 120 deletions(-) diff --git a/t/lib-async-response.sh b/t/lib-async-response.sh index 285751d..65c6056 100644 --- a/t/lib-async-response.sh +++ b/t/lib-async-response.sh @@ -1,20 +1,11 @@ CONFIG_RU=${CONFIG_RU-'async-response.ru'} . ./test-lib.sh echo "async response for model=$model" -eval $(unused_listen) -rtmpfiles unicorn_config a b c r_err r_out pid curl_err - -cat > $unicorn_config <> $curl_err | utee $a) & @@ -23,7 +14,6 @@ t0=$(date +%s) wait t1=$(date +%s) -rainbows_pid=$(cat $pid) kill -QUIT $rainbows_pid elapsed=$(( $t1 - $t0 )) echo "elapsed=$elapsed < 30" diff --git a/t/lib-graceful.sh b/t/lib-graceful.sh index 097bdbe..3bc3590 100644 --- a/t/lib-graceful.sh +++ b/t/lib-graceful.sh @@ -1,20 +1,10 @@ . ./test-lib.sh echo "graceful test for model=$model" -eval $(unused_listen) -rtmpfiles unicorn_config curl_out pid r_err r_out fifo - -cat > $unicorn_config < $curl_out 2> $fifo & diff --git a/t/lib-input-trailer.sh b/t/lib-input-trailer.sh index 072dd60..08331b1 100644 --- a/t/lib-input-trailer.sh +++ b/t/lib-input-trailer.sh @@ -2,19 +2,9 @@ test -r random_blob || die "random_blob required, run with 'make $0'" echo "input trailer test model=$model" -eval $(unused_listen) -rtmpfiles unicorn_config tmp r_err r_out pid fifo ok - -cat > $unicorn_config < $unicorn_config < $unicorn_config < $unicorn_config < $unicorn_config </dev/null diff --git a/t/lib-simple-http.sh b/t/lib-simple-http.sh index 410cc9a..235f4e3 100644 --- a/t/lib-simple-http.sh +++ b/t/lib-simple-http.sh @@ -6,22 +6,9 @@ echo "simple HTTP connection keepalive/pipelining tests for $model" tbase=$(expr "$T" : '^\(t....\)-').ru test -f "$tbase" || die "$tbase missing for $T" -eval $(unused_listen) -rtmpfiles unicorn_config pid r_err r_out tmp fifo ok - -cat > $unicorn_config <> $unicorn_config -fi - +rainbows_setup rainbows -D $tbase -c $unicorn_config -wait_for_pid $pid +rainbows_wait_start echo "single request" curl -sSfv http://$listen/ diff --git a/t/t9000-rack-app-pool.sh b/t/t9000-rack-app-pool.sh index 5530b9d..6c82ff8 100755 --- a/t/t9000-rack-app-pool.sh +++ b/t/t9000-rack-app-pool.sh @@ -1,25 +1,12 @@ #!/bin/sh . ./test-lib.sh -eval $(unused_listen) -rtmpfiles unicorn_config pid r_err r_out curl_out curl_err - nr_client=30 - -cat > $unicorn_config < $unicorn_config <> $unicorn_config +} + +rainbows_wait_start () { + # "cat $fifo" will block until the before_fork hook is called in + # the Unicorn config file + test x = x"$(cat $fifo)" + rainbows_pid=$(cat $pid) +} + case $model in Rev) require_check rev Rev::VERSION ;; Revactor) require_check revactor Revactor::VERSION ;; -- cgit v1.2.3-24-ge0c7