diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-24 20:41:15 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-24 20:42:57 -0700 |
commit | 15fe80b3bff7b0d249ee32bcbbe1dfa116d3c629 (patch) | |
tree | 8edf5313e3ef41395b406706dd807b97e6321eb9 /t | |
parent | e77369a6bde35a4e8925d450aac85f328f87d208 (diff) | |
download | rainbows-15fe80b3bff7b0d249ee32bcbbe1dfa116d3c629.tar.gz |
This will make it easier to enable and manage tests for new concurrency models.
Diffstat (limited to 't')
52 files changed, 86 insertions, 80 deletions
diff --git a/t/GNUmakefile b/t/GNUmakefile index 24ce750..0966563 100644 --- a/t/GNUmakefile +++ b/t/GNUmakefile @@ -16,8 +16,25 @@ else endif export RUBYLIB RUBY_VERSION +models := ThreadPool ThreadSpawn Revactor Rev +all_models := $(models) Base + T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh) +MODEL_T := $(foreach m,$(all_models),$(addprefix $(m).,$(T))) +$(T): MODELS = $(models) + +# some tests can be run with all models +t0000-simple-http.sh: MODELS = $(all_models) + +# this test is not compatible with non-Thread models yet +t9000-rack-app-pool.sh: MODELS = ThreadPool ThreadSpawn + +# recursively run per-model tests +# haven't figured out a good way to make make non-recursive here, yet... +$(T): + $(MAKE) $(foreach m,$(MODELS),$(addprefix $(m).,$@)) + all:: $(T) # can't rely on "set -o pipefail" since we don't require bash or ksh93 :< @@ -25,7 +42,6 @@ t_pfx = trash/$@-$(RUBY_VERSION) TEST_OPTS = # TRACER = strace -f -o $(t_pfx).strace -s 100000 # TRACER = /usr/bin/time -o $(t_pfx).time -run_test = $(TRACER) $(SHELL) $(SH_TEST_OPTS) $@ $(TEST_OPTS) ifdef V ifeq ($(V),2) @@ -42,18 +58,19 @@ test-bin-$(RUBY_VERSION)/rainbows: ../bin/rainbows $(RUBY) -i -p -e '$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@+ mv $@+ $@ -req_random_blob := $(wildcard t?1??-*.sh) random_blob: dd if=/dev/urandom bs=1M count=10 of=$@+ mv $@+ $@ -$(req_random_blob): random_blob +$(T): random_blob -$(T): trash/.gitignore -$(T): export RUBY := $(RUBY) -$(T): export PATH := $(CURDIR)/test-bin-$(RUBY_VERSION):$(PATH) -$(T): test-bin-$(RUBY_VERSION)/rainbows - @$(run_test) +$(MODEL_T): export model = $(firstword $(subst ., ,$@)) +$(MODEL_T): script = $(subst $(model).,,$@) +$(MODEL_T): trash/.gitignore +$(MODEL_T): export RUBY := $(RUBY) +$(MODEL_T): export PATH := $(CURDIR)/test-bin-$(RUBY_VERSION):$(PATH) +$(MODEL_T): test-bin-$(RUBY_VERSION)/rainbows + $(TRACER) $(SHELL) $(SH_TEST_OPTS) $(script) $(TEST_OPTS) trash/.gitignore: mkdir -p $(@D) @@ -28,9 +28,13 @@ To run the entire test suite with 8 tests running at once: make -j8 -To run one individual test: +To run one individual test for all concurrency models: - make t0000-basic.sh + make t0000-simple-http.sh + +To run one individual test for one concurrency model: + + make Revactor.t0000-simple-http.sh You may also increase verbosity by setting the "V" variable for GNU make. To disable trapping of stdout/stderr: diff --git a/t/simple-http_Base.ru b/t/simple-http_Base.ru new file mode 100644 index 0000000..c2355da --- /dev/null +++ b/t/simple-http_Base.ru @@ -0,0 +1,3 @@ +use Rack::ContentLength +use Rack::ContentType +run lambda { |env| [ 200, {}, [ env.inspect << "\n" ] ] } diff --git a/t/simple-http_Rev.ru b/t/simple-http_Rev.ru new file mode 100644 index 0000000..a3e2855 --- /dev/null +++ b/t/simple-http_Rev.ru @@ -0,0 +1,9 @@ +use Rack::ContentLength +use Rack::ContentType +run lambda { |env| + if env['rack.multithread'] == false && env['rainbows.model'] == :Rev + [ 200, {}, [ env.inspect << "\n" ] ] + else + raise "rack.multithread is true" + end +} diff --git a/t/simple-http_Revactor.ru b/t/simple-http_Revactor.ru new file mode 100644 index 0000000..9b9c56a --- /dev/null +++ b/t/simple-http_Revactor.ru @@ -0,0 +1,10 @@ +use Rack::ContentLength +use Rack::ContentType +run lambda { |env| + Actor.sleep 1 + if env['rack.multithread'] == false && env['rainbows.model'] == :Revactor + [ 200, {}, [ Thread.current.inspect << "\n" ] ] + else + raise "rack.multithread is true" + end +} diff --git a/t/simple-http_ThreadPool.ru b/t/simple-http_ThreadPool.ru new file mode 100644 index 0000000..4bb7348 --- /dev/null +++ b/t/simple-http_ThreadPool.ru @@ -0,0 +1,10 @@ +use Rack::ContentLength +use Rack::ContentType +run lambda { |env| + sleep 1 + if env['rack.multithread'] && env['rainbows.model'] == :ThreadPool + [ 200, {}, [ Thread.current.inspect << "\n" ] ] + else + raise "rack.multithread is not true" + end +} diff --git a/t/simple-http_ThreadSpawn.ru b/t/simple-http_ThreadSpawn.ru new file mode 100644 index 0000000..aa1accb --- /dev/null +++ b/t/simple-http_ThreadSpawn.ru @@ -0,0 +1,10 @@ +use Rack::ContentLength +use Rack::ContentType +run lambda { |env| + sleep 1 + if env['rack.multithread'] && env['rainbows.model'] == :ThreadSpawn + [ 200, {}, [ Thread.current.inspect << "\n" ] ] + else + raise "rack.multithread is not true" + end +} diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh deleted file mode 100755 index 7942942..0000000 --- a/t/t0000-basic.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-simple-http.sh diff --git a/t/lib-simple-http.sh b/t/t0000-simple-http.sh index cb0b28f..173281b 100644..100755 --- a/t/lib-simple-http.sh +++ b/t/t0000-simple-http.sh @@ -3,7 +3,7 @@ t_plan 24 "simple HTTP connection keepalive/pipelining tests for $model" t_begin "checking for config.ru for $model" && { - tbase=$(expr "$T" : '^\(t....\)-').ru + tbase=simple-http_$model.ru test -f "$tbase" } diff --git a/t/lib-graceful.sh b/t/t0002-graceful.sh index 45008a5..c3ff27e 100644..100755 --- a/t/lib-graceful.sh +++ b/t/t0002-graceful.sh @@ -1,3 +1,4 @@ +#!/bin/sh . ./test-lib.sh t_plan 4 "graceful exit test for $model" diff --git a/t/lib-parser-error.sh b/t/t0002-parser-error.sh index 2b35b17..c4e5ab7 100644..100755 --- a/t/lib-parser-error.sh +++ b/t/t0002-parser-error.sh @@ -1,3 +1,4 @@ +#!/bin/sh . ./test-lib.sh t_plan 5 "parser error test for $model" diff --git a/t/lib-reopen-logs.sh b/t/t0003-reopen-logs.sh index 822de8b..822de8b 100644..100755 --- a/t/lib-reopen-logs.sh +++ b/t/t0003-reopen-logs.sh diff --git a/t/lib-large-file-response.sh b/t/t0005-large-file-response.sh index 9bbd767..7aafd5b 100644..100755 --- a/t/lib-large-file-response.sh +++ b/t/t0005-large-file-response.sh @@ -1,3 +1,4 @@ +#!/bin/sh . ./test-lib.sh test -r random_blob || die "random_blob required, run with 'make $0'" diff --git a/t/lib-rack-input-hammer.sh b/t/t0100-rack-input-hammer.sh index 3e543b3..3e543b3 100644..100755 --- a/t/lib-rack-input-hammer.sh +++ b/t/t0100-rack-input-hammer.sh diff --git a/t/lib-input-trailer.sh b/t/t0101-rack-input-trailer.sh index 9dce292..75528d6 100644..100755 --- a/t/lib-input-trailer.sh +++ b/t/t0101-rack-input-trailer.sh @@ -1,3 +1,4 @@ +#!/bin/sh . ./test-lib.sh test -r random_blob || die "random_blob required, run with 'make $0'" diff --git a/t/lib-async-response.sh b/t/t0200-async-response.sh index 368792b..f3ead0b 100644..100755 --- a/t/lib-async-response.sh +++ b/t/t0200-async-response.sh @@ -1,3 +1,4 @@ +#!/bin/sh CONFIG_RU=${CONFIG_RU-'async-response.ru'} . ./test-lib.sh diff --git a/t/lib-async-response-no-autochunk.sh b/t/t0201-async-response-no-autochunk.sh index c94907a..bb46385 100644..100755 --- a/t/lib-async-response-no-autochunk.sh +++ b/t/t0201-async-response-no-autochunk.sh @@ -1,3 +1,3 @@ #!/bin/sh CONFIG_RU=async-response-no-autochunk.ru -. ./lib-async-response.sh +. ./t0200-async-response.sh diff --git a/t/t1000-thread-pool-basic.sh b/t/t1000-thread-pool-basic.sh deleted file mode 100755 index 7942942..0000000 --- a/t/t1000-thread-pool-basic.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-simple-http.sh diff --git a/t/t1002-thread-pool-graceful.sh b/t/t1002-thread-pool-graceful.sh deleted file mode 100755 index e3c266b..0000000 --- a/t/t1002-thread-pool-graceful.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-graceful.sh diff --git a/t/t1003-thread-pool-reopen-logs.sh b/t/t1003-thread-pool-reopen-logs.sh deleted file mode 100755 index 6bba7ef..0000000 --- a/t/t1003-thread-pool-reopen-logs.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-reopen-logs.sh diff --git a/t/t1004-thread-pool-async-response.sh b/t/t1004-thread-pool-async-response.sh deleted file mode 120000 index 15c27db..0000000 --- a/t/t1004-thread-pool-async-response.sh +++ /dev/null @@ -1 +0,0 @@ -lib-async-response.sh
\ No newline at end of file diff --git a/t/t1005-thread-pool-large-file-response.sh b/t/t1005-thread-pool-large-file-response.sh deleted file mode 120000 index 37d2877..0000000 --- a/t/t1005-thread-pool-large-file-response.sh +++ /dev/null @@ -1 +0,0 @@ -lib-large-file-response.sh
\ No newline at end of file diff --git a/t/t1006-thread-pool-async-response-no-autochunk.sh b/t/t1006-thread-pool-async-response-no-autochunk.sh deleted file mode 120000 index bb87ca9..0000000 --- a/t/t1006-thread-pool-async-response-no-autochunk.sh +++ /dev/null @@ -1 +0,0 @@ -lib-async-response-no-autochunk.sh
\ No newline at end of file diff --git a/t/t1100-thread-pool-rack-input.sh b/t/t1100-thread-pool-rack-input.sh deleted file mode 100755 index 4d6d4c9..0000000 --- a/t/t1100-thread-pool-rack-input.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-rack-input-hammer.sh diff --git a/t/t1101-thread-pool-input-trailer.sh b/t/t1101-thread-pool-input-trailer.sh deleted file mode 100755 index e297cc9..0000000 --- a/t/t1101-thread-pool-input-trailer.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-input-trailer.sh diff --git a/t/t2000-thread-spawn-basic.sh b/t/t2000-thread-spawn-basic.sh deleted file mode 100755 index 7942942..0000000 --- a/t/t2000-thread-spawn-basic.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-simple-http.sh diff --git a/t/t2002-thread-spawn-graceful.sh b/t/t2002-thread-spawn-graceful.sh deleted file mode 100755 index e3c266b..0000000 --- a/t/t2002-thread-spawn-graceful.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-graceful.sh diff --git a/t/t2003-thread-spawn-reopen-logs.sh b/t/t2003-thread-spawn-reopen-logs.sh deleted file mode 100755 index 6bba7ef..0000000 --- a/t/t2003-thread-spawn-reopen-logs.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-reopen-logs.sh diff --git a/t/t2004-thread-spawn-async-response.sh b/t/t2004-thread-spawn-async-response.sh deleted file mode 120000 index 15c27db..0000000 --- a/t/t2004-thread-spawn-async-response.sh +++ /dev/null @@ -1 +0,0 @@ -lib-async-response.sh
\ No newline at end of file diff --git a/t/t2005-thread-spawn-large-file-response.sh b/t/t2005-thread-spawn-large-file-response.sh deleted file mode 120000 index 37d2877..0000000 --- a/t/t2005-thread-spawn-large-file-response.sh +++ /dev/null @@ -1 +0,0 @@ -lib-large-file-response.sh
\ No newline at end of file diff --git a/t/t2006-thread-spawn-async-response-no-autochunk.sh b/t/t2006-thread-spawn-async-response-no-autochunk.sh deleted file mode 120000 index bb87ca9..0000000 --- a/t/t2006-thread-spawn-async-response-no-autochunk.sh +++ /dev/null @@ -1 +0,0 @@ -lib-async-response-no-autochunk.sh
\ No newline at end of file diff --git a/t/t2100-thread-spawn-rack-input.sh b/t/t2100-thread-spawn-rack-input.sh deleted file mode 100755 index 4d6d4c9..0000000 --- a/t/t2100-thread-spawn-rack-input.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-rack-input-hammer.sh diff --git a/t/t2101-thread-spawn-input-trailer.sh b/t/t2101-thread-spawn-input-trailer.sh deleted file mode 100755 index e297cc9..0000000 --- a/t/t2101-thread-spawn-input-trailer.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-input-trailer.sh diff --git a/t/t3000-revactor-basic.sh b/t/t3000-revactor-basic.sh deleted file mode 100755 index 7942942..0000000 --- a/t/t3000-revactor-basic.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-simple-http.sh diff --git a/t/t3002-revactor-graceful.sh b/t/t3002-revactor-graceful.sh deleted file mode 100755 index e3c266b..0000000 --- a/t/t3002-revactor-graceful.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-graceful.sh diff --git a/t/t3003-revactor-reopen-logs.sh b/t/t3003-revactor-reopen-logs.sh deleted file mode 100755 index 6bba7ef..0000000 --- a/t/t3003-revactor-reopen-logs.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-reopen-logs.sh diff --git a/t/t3004-revactor-async-response.sh b/t/t3004-revactor-async-response.sh deleted file mode 120000 index 15c27db..0000000 --- a/t/t3004-revactor-async-response.sh +++ /dev/null @@ -1 +0,0 @@ -lib-async-response.sh
\ No newline at end of file diff --git a/t/t3005-revactor-large-file-response.sh b/t/t3005-revactor-large-file-response.sh deleted file mode 100755 index ef1a4a3..0000000 --- a/t/t3005-revactor-large-file-response.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-large-file-response.sh diff --git a/t/t3006-revactor-async-response-no-autochunk.sh b/t/t3006-revactor-async-response-no-autochunk.sh deleted file mode 120000 index bb87ca9..0000000 --- a/t/t3006-revactor-async-response-no-autochunk.sh +++ /dev/null @@ -1 +0,0 @@ -lib-async-response-no-autochunk.sh
\ No newline at end of file diff --git a/t/t3100-revactor-rack-input.sh b/t/t3100-revactor-rack-input.sh deleted file mode 100755 index 4d6d4c9..0000000 --- a/t/t3100-revactor-rack-input.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-rack-input-hammer.sh diff --git a/t/t3101-revactor-rack-input-trailer.sh b/t/t3101-revactor-rack-input-trailer.sh deleted file mode 100755 index e297cc9..0000000 --- a/t/t3101-revactor-rack-input-trailer.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-input-trailer.sh diff --git a/t/t4000-rev-basic.sh b/t/t4000-rev-basic.sh deleted file mode 100755 index 7942942..0000000 --- a/t/t4000-rev-basic.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-simple-http.sh diff --git a/t/t4002-rev-graceful.sh b/t/t4002-rev-graceful.sh deleted file mode 100755 index e3c266b..0000000 --- a/t/t4002-rev-graceful.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-graceful.sh diff --git a/t/t4003-rev-parser-error.sh b/t/t4003-rev-parser-error.sh deleted file mode 100755 index 04df895..0000000 --- a/t/t4003-rev-parser-error.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-parser-error.sh diff --git a/t/t4003-rev-reopen-logs.sh b/t/t4003-rev-reopen-logs.sh deleted file mode 100755 index 6bba7ef..0000000 --- a/t/t4003-rev-reopen-logs.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-reopen-logs.sh diff --git a/t/t4004-rev-async-response.sh b/t/t4004-rev-async-response.sh deleted file mode 120000 index 15c27db..0000000 --- a/t/t4004-rev-async-response.sh +++ /dev/null @@ -1 +0,0 @@ -lib-async-response.sh
\ No newline at end of file diff --git a/t/t4005-rev-large-file-response.sh b/t/t4005-rev-large-file-response.sh deleted file mode 100755 index ef1a4a3..0000000 --- a/t/t4005-rev-large-file-response.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-large-file-response.sh diff --git a/t/t4006-rev-async-response-no-autochunk.sh b/t/t4006-rev-async-response-no-autochunk.sh deleted file mode 120000 index bb87ca9..0000000 --- a/t/t4006-rev-async-response-no-autochunk.sh +++ /dev/null @@ -1 +0,0 @@ -lib-async-response-no-autochunk.sh
\ No newline at end of file diff --git a/t/t4100-rev-rack-input.sh b/t/t4100-rev-rack-input.sh deleted file mode 100755 index 4d6d4c9..0000000 --- a/t/t4100-rev-rack-input.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-rack-input-hammer.sh diff --git a/t/t4101-rev-rack-input-trailer.sh b/t/t4101-rev-rack-input-trailer.sh deleted file mode 100755 index e297cc9..0000000 --- a/t/t4101-rev-rack-input-trailer.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -. ./lib-input-trailer.sh diff --git a/t/t9000-rack-app-pool.sh b/t/t9000-rack-app-pool.sh index b04564b..994c244 100755 --- a/t/t9000-rack-app-pool.sh +++ b/t/t9000-rack-app-pool.sh @@ -2,11 +2,11 @@ . ./test-lib.sh nr_client=30 APP_POOL_SIZE=4 -t_plan 6 "AppPool Rack middleware test" +t_plan 6 "AppPool Rack middleware test for $model" t_begin "configure and start" && { rtmpfiles curl_out curl_err - rainbows_setup ThreadSpawn 50 + rainbows_setup $model 50 APP_POOL_SIZE=$APP_POOL_SIZE rainbows -D t9000.ru -c $unicorn_config rainbows_wait_start } diff --git a/t/test-lib.sh b/t/test-lib.sh index 5e279a1..39225c6 100755..100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -5,19 +5,15 @@ set +u if test -z "$model" then - case $T in - t1???-thread-pool-*.sh) model=ThreadPool ;; - t2???-thread-spawn-*.sh) model=ThreadSpawn ;; - t3???-revactor-*.sh) model=Revactor ;; - t4???-rev-*.sh) model=Rev ;; - *) model=Base ;; - esac + # defaulting to Base would unfortunately fail some concurrency tests + model=ThreadSpawn + t_info "model undefined, defaulting to $model" fi set -e RUBY="${RUBY-ruby}" RUBY_VERSION=${RUBY_VERSION-$($RUBY -e 'puts RUBY_VERSION')} -t_pfx=$PWD/trash/$T-$RUBY_VERSION +t_pfx=$PWD/trash/$model.$T-$RUBY_VERSION set -u PATH=$PWD/bin:$PATH |