about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-04-19 01:04:47 -0700
committerEric Wong <normalperson@yhbt.net>2010-04-19 01:23:04 -0700
commit72fdcf1c39c2a143d7abd8d2609e92311edff341 (patch)
tree2fa0c957811f6a1c5ee1deb68f351e9399c44f0c /t
parent98622a1c291277ff124a586929c675e9ae67692e (diff)
downloadrainbows-72fdcf1c39c2a143d7abd8d2609e92311edff341.tar.gz
Although advertised as being Thin-only, the rack-fiber_pool gem
works with our EventMachine concurrency model as well.

Note that it's impossible to expose the streaming "rack.input"
behavior of the native FiberSpawn/FiberPool models via
middleware, but most people don't need streaming a "rack.input"

See http://github.com/mperham/rack-fiber_pool for more details
on the rack-fiber_pool gem.
Diffstat (limited to 't')
-rw-r--r--t/rack-fiber_pool/app.ru5
-rwxr-xr-xt/t0600-rack-fiber_pool.sh49
2 files changed, 54 insertions, 0 deletions
diff --git a/t/rack-fiber_pool/app.ru b/t/rack-fiber_pool/app.ru
new file mode 100644
index 0000000..a4777ca
--- /dev/null
+++ b/t/rack-fiber_pool/app.ru
@@ -0,0 +1,5 @@
+require 'rack/fiber_pool'
+use Rack::FiberPool
+use Rack::ContentLength
+use Rack::ContentType, 'text/plain'
+run lambda { |env| [ 200, {}, [ "#{Fiber.current}\n" ] ] }
diff --git a/t/t0600-rack-fiber_pool.sh b/t/t0600-rack-fiber_pool.sh
new file mode 100755
index 0000000..01f28b5
--- /dev/null
+++ b/t/t0600-rack-fiber_pool.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+. ./test-lib.sh
+case $model in
+EventMachine) ;;
+*)
+        t_info "skipping $T since it's not compatible with $model"
+        exit 0
+        ;;
+esac
+
+require_check rack/fiber_pool Rack::FiberPool
+
+t_plan 7 "basic test with rack-fiber_pool gem"
+
+CONFIG_RU=rack-fiber_pool/app.ru
+
+t_begin "setup and start" && {
+        rainbows_setup
+        rtmpfiles curl_err curl_out
+
+        rainbows -D -c $unicorn_config $CONFIG_RU
+        rainbows_wait_start
+}
+
+t_begin "send requests off in parallel" && {
+        curl --no-buffer -sSf http://$listen/ >> $curl_out 2>> $curl_err &
+        curl --no-buffer -sSf http://$listen/ >> $curl_out 2>> $curl_err &
+        curl --no-buffer -sSf http://$listen/ >> $curl_out 2>> $curl_err &
+}
+
+t_begin "wait for curl terminations" && {
+        wait
+}
+
+t_begin "termination signal sent" && {
+        kill $rainbows_pid
+}
+
+t_begin "no errors from curl" && {
+        test ! -s $curl_err
+}
+
+t_begin "no errors in stderr" && check_stderr
+
+t_begin "ensure we hit 3 separate fibers" && {
+        test x3 = x"$(sort < $curl_out | uniq | wc -l)"
+}
+
+t_done