about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-02-18 19:11:50 -0800
committerEric Wong <normalperson@yhbt.net>2010-02-18 19:29:44 -0800
commit3e80ccb60e2b3632916094ac436806ab1cf03b11 (patch)
tree3995f8dd3532fc490ff42f785c23528b850c0697 /t
parent8963e87841501c8e79b8434f8887e0d3a78b580c (diff)
downloadunicorn-3e80ccb60e2b3632916094ac436806ab1cf03b11.tar.gz
This should make it easier to reuse code in derivative
servers like Rainbows! and Zbatery.  Unfortunately, we
can't depend on Rack::Builder/Rack::Server yet since
Rack 1.1 just got them and notable frameworks (like
Rails 2.3.x) do not fully work with Rack 1.1 yet).

This also fixes subtle issue with config.ru files that could
have variables that conflict with the Unicorn-specific
namespace (this bug still affects "unicorn_rails", which
could use some reworking as well).
Diffstat (limited to 't')
-rwxr-xr-xt/t0002-config-conflict.sh49
1 files changed, 49 insertions, 0 deletions
diff --git a/t/t0002-config-conflict.sh b/t/t0002-config-conflict.sh
new file mode 100755
index 0000000..d7b2181
--- /dev/null
+++ b/t/t0002-config-conflict.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+. ./test-lib.sh
+t_plan 6 "config variables conflict with preload_app"
+
+t_begin "setup and start" && {
+        unicorn_setup
+        rtmpfiles ru rutmp
+
+        cat > $ru <<\EOF
+use Rack::ContentLength
+use Rack::ContentType, "text/plain"
+config = ru = { "hello" => "world" }
+run lambda { |env| [ 200, {}, [ ru.inspect << "\n" ] ] }
+EOF
+        echo 'preload_app true' >> $unicorn_config
+        unicorn -D -c $unicorn_config $ru
+        unicorn_wait_start
+}
+
+t_begin "hit with curl" && {
+        out=$(curl -sSf http://$listen/)
+        test x"$out" = x'{"hello"=>"world"}'
+}
+
+t_begin "modify rackup file" && {
+        sed -e 's/world/WORLD/' < $ru > $rutmp
+        mv $rutmp $ru
+}
+
+t_begin "reload signal succeeds" && {
+        kill -HUP $unicorn_pid
+        while ! egrep '(done|error) reloading' < $r_err >/dev/null
+        do
+                sleep 1
+        done
+
+        grep 'done reloading' $r_err >/dev/null
+}
+
+t_begin "hit with curl" && {
+        out=$(curl -sSf http://$listen/)
+        test x"$out" = x'{"hello"=>"WORLD"}'
+}
+
+t_begin "killing succeeds" && {
+        kill $unicorn_pid
+}
+
+t_done