From b64099a18c7a353d2b6f34ad84da8afafd6f873d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 17 Jun 2010 06:46:43 +0000 Subject: tests: extra working_directory integration cases Our fugly code can't handle embedded command-line options in config.ru when using Rubinius yet. So add some related tests to the ones marked RBX_SKIP that don't rely on embedded command-line options. --- t/t0007-working_directory_no_embed_cli.sh | 44 +++++++++++++++++++ ...04-rails3-alt-working_directory_no_embed_cli.sh | 49 ++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100755 t/t0007-working_directory_no_embed_cli.sh create mode 100755 t/t0304-rails3-alt-working_directory_no_embed_cli.sh diff --git a/t/t0007-working_directory_no_embed_cli.sh b/t/t0007-working_directory_no_embed_cli.sh new file mode 100755 index 0000000..77d6707 --- /dev/null +++ b/t/t0007-working_directory_no_embed_cli.sh @@ -0,0 +1,44 @@ +#!/bin/sh +. ./test-lib.sh + +t_plan 4 "config.ru inside alt working_directory (no embedded switches)" + +t_begin "setup and start" && { + unicorn_setup + rm -rf $t_pfx.app + mkdir $t_pfx.app + + cat > $t_pfx.app/config.ru <> $unicorn_config + + # allows ppid to be 1 in before_fork + echo "preload_app true" >> $unicorn_config + cat >> $unicorn_config <<\EOF +before_fork do |server,worker| + $master_ppid = Process.ppid # should be zero to detect daemonization +end +EOF + + cd / + unicorn -D -c $unicorn_config + unicorn_wait_start +} + +t_begin "hit with curl" && { + body=$(curl -sSf http://$listen/) +} + +t_begin "killing succeeds" && { + kill $unicorn_pid +} + +t_begin "response body ppid == 1 (daemonized)" && { + test "$body" -eq 1 +} + +t_done diff --git a/t/t0304-rails3-alt-working_directory_no_embed_cli.sh b/t/t0304-rails3-alt-working_directory_no_embed_cli.sh new file mode 100755 index 0000000..27676cb --- /dev/null +++ b/t/t0304-rails3-alt-working_directory_no_embed_cli.sh @@ -0,0 +1,49 @@ +#!/bin/sh +. ./test-rails3.sh + +t_plan 5 "Rails 3 (beta) inside alt working_directory (no embedded switches)" + +t_begin "setup and start" && { + unicorn_setup + rtmpfiles unicorn_config_tmp usock + rm -f $usock + rails3_app=$(cd rails3-app && pwd) + rm -rf $t_pfx.app + mkdir $t_pfx.app + cd $t_pfx.app + ( cd $rails3_app && tar cf - . ) | tar xf - + $RAKE db:sessions:create + $RAKE db:migrate + unicorn_setup + rm $pid + + grep -v ^pid $unicorn_config > $unicorn_config_tmp + echo "working_directory '$t_pfx.app'" >> $unicorn_config_tmp + cd / + unicorn_rails -c $unicorn_config_tmp \ + --daemonize --host $host --port $port -l $usock +} + +t_begin "pids in the right place" && { + if test -e $pid + then + die "pid=$pid not expected" + fi + + unicorn_rails_pid="$t_pfx.app/tmp/pids/unicorn.pid" + unicorn_pid=$(cat $unicorn_rails_pid) +} + +t_begin "static file serving works" && { + test x"$(curl -sSf http://$listen/x.txt)" = xHELLO +} + +t_begin "socket created" && { + test -S $usock +} + +t_begin "killing succeeds" && { + kill $unicorn_pid +} + +t_done -- cgit v1.2.3-24-ge0c7