unicorn-lb-patch 4.3.1.11.g21b8.dirty
Sign up to get free protection for your applications and to get access to all the features.
- data/.CHANGELOG.old +25 -0
- data/.document +29 -0
- data/.gitignore +25 -0
- data/.mailmap +26 -0
- data/.wrongdoc.yml +10 -0
- data/Application_Timeouts +77 -0
- data/CONTRIBUTORS +35 -0
- data/COPYING +674 -0
- data/DESIGN +97 -0
- data/Documentation/.gitignore +5 -0
- data/Documentation/GNUmakefile +30 -0
- data/Documentation/unicorn.1.txt +174 -0
- data/Documentation/unicorn_rails.1.txt +175 -0
- data/FAQ +53 -0
- data/GIT-VERSION-GEN +40 -0
- data/GNUmakefile +294 -0
- data/HACKING +134 -0
- data/ISSUES +36 -0
- data/KNOWN_ISSUES +79 -0
- data/LICENSE +64 -0
- data/Links +56 -0
- data/PHILOSOPHY +145 -0
- data/README +149 -0
- data/Rakefile +97 -0
- data/SIGNALS +114 -0
- data/Sandbox +96 -0
- data/TODO +5 -0
- data/TUNING +98 -0
- data/bin/unicorn +121 -0
- data/bin/unicorn_rails +209 -0
- data/examples/big_app_gc.rb +2 -0
- data/examples/echo.ru +27 -0
- data/examples/git.ru +13 -0
- data/examples/init.sh +74 -0
- data/examples/logger_mp_safe.rb +25 -0
- data/examples/logrotate.conf +29 -0
- data/examples/nginx.conf +156 -0
- data/examples/unicorn.conf.minimal.rb +13 -0
- data/examples/unicorn.conf.rb +94 -0
- data/ext/unicorn_http/CFLAGS +13 -0
- data/ext/unicorn_http/c_util.h +124 -0
- data/ext/unicorn_http/common_field_optimization.h +111 -0
- data/ext/unicorn_http/ext_help.h +86 -0
- data/ext/unicorn_http/extconf.rb +10 -0
- data/ext/unicorn_http/global_variables.h +97 -0
- data/ext/unicorn_http/httpdate.c +82 -0
- data/ext/unicorn_http/unicorn_http.rl +1036 -0
- data/ext/unicorn_http/unicorn_http_common.rl +76 -0
- data/lib/unicorn.rb +107 -0
- data/lib/unicorn/app/exec_cgi.rb +154 -0
- data/lib/unicorn/app/inetd.rb +109 -0
- data/lib/unicorn/app/old_rails.rb +35 -0
- data/lib/unicorn/app/old_rails/static.rb +59 -0
- data/lib/unicorn/cgi_wrapper.rb +147 -0
- data/lib/unicorn/configurator.rb +630 -0
- data/lib/unicorn/const.rb +40 -0
- data/lib/unicorn/http_request.rb +77 -0
- data/lib/unicorn/http_response.rb +45 -0
- data/lib/unicorn/http_server.rb +755 -0
- data/lib/unicorn/launcher.rb +62 -0
- data/lib/unicorn/oob_gc.rb +71 -0
- data/lib/unicorn/preread_input.rb +33 -0
- data/lib/unicorn/socket_helper.rb +208 -0
- data/lib/unicorn/ssl_client.rb +11 -0
- data/lib/unicorn/ssl_configurator.rb +104 -0
- data/lib/unicorn/ssl_server.rb +42 -0
- data/lib/unicorn/stream_input.rb +149 -0
- data/lib/unicorn/tee_input.rb +126 -0
- data/lib/unicorn/tmpio.rb +29 -0
- data/lib/unicorn/util.rb +68 -0
- data/lib/unicorn/worker.rb +88 -0
- data/local.mk.sample +59 -0
- data/script/isolate_for_tests +50 -0
- data/setup.rb +1586 -0
- data/t/.gitignore +5 -0
- data/t/GNUmakefile +82 -0
- data/t/README +42 -0
- data/t/bin/content-md5-put +36 -0
- data/t/bin/sha1sum.rb +17 -0
- data/t/bin/unused_listen +40 -0
- data/t/bin/utee +12 -0
- data/t/broken-app.ru +12 -0
- data/t/detach.ru +11 -0
- data/t/env.ru +3 -0
- data/t/heartbeat-timeout.ru +12 -0
- data/t/listener_names.ru +4 -0
- data/t/my-tap-lib.sh +201 -0
- data/t/oob_gc.ru +21 -0
- data/t/oob_gc_path.ru +21 -0
- data/t/pid.ru +3 -0
- data/t/preread_input.ru +17 -0
- data/t/rack-input-tests.ru +21 -0
- data/t/rails3-app/.gitignore +4 -0
- data/t/rails3-app/Gemfile +26 -0
- data/t/rails3-app/Rakefile +10 -0
- data/t/rails3-app/app/controllers/application_controller.rb +4 -0
- data/t/rails3-app/app/helpers/application_helper.rb +2 -0
- data/t/rails3-app/app/views/layouts/application.html.erb +14 -0
- data/t/rails3-app/config.ru +4 -0
- data/t/rails3-app/config/application.rb +46 -0
- data/t/rails3-app/config/boot.rb +6 -0
- data/t/rails3-app/config/database.yml +22 -0
- data/t/rails3-app/config/environment.rb +5 -0
- data/t/rails3-app/config/environments/development.rb +19 -0
- data/t/rails3-app/config/environments/production.rb +42 -0
- data/t/rails3-app/config/environments/test.rb +32 -0
- data/t/rails3-app/config/initializers/backtrace_silencers.rb +7 -0
- data/t/rails3-app/config/initializers/inflections.rb +10 -0
- data/t/rails3-app/config/initializers/mime_types.rb +5 -0
- data/t/rails3-app/config/initializers/secret_token.rb +7 -0
- data/t/rails3-app/config/initializers/session_store.rb +8 -0
- data/t/rails3-app/config/locales/en.yml +5 -0
- data/t/rails3-app/config/routes.rb +58 -0
- data/t/rails3-app/db/seeds.rb +7 -0
- data/t/rails3-app/doc/README_FOR_APP +2 -0
- data/t/rails3-app/lib/tasks/.gitkeep +0 -0
- data/t/rails3-app/public/404.html +1 -0
- data/t/rails3-app/public/500.html +1 -0
- data/t/rails3-app/public/x.txt +1 -0
- data/t/rails3-app/script/rails +9 -0
- data/t/rails3-app/test/performance/browsing_test.rb +9 -0
- data/t/rails3-app/test/test_helper.rb +13 -0
- data/t/rails3-app/vendor/plugins/.gitkeep +0 -0
- data/t/sslgen.sh +71 -0
- data/t/t0000-http-basic.sh +50 -0
- data/t/t0001-reload-bad-config.sh +53 -0
- data/t/t0002-config-conflict.sh +49 -0
- data/t/t0002-parser-error.sh +94 -0
- data/t/t0003-working_directory.sh +51 -0
- data/t/t0004-heartbeat-timeout.sh +69 -0
- data/t/t0004-working_directory_broken.sh +24 -0
- data/t/t0005-working_directory_app.rb.sh +37 -0
- data/t/t0006-reopen-logs.sh +83 -0
- data/t/t0006.ru +13 -0
- data/t/t0007-working_directory_no_embed_cli.sh +44 -0
- data/t/t0008-back_out_of_upgrade.sh +110 -0
- data/t/t0009-broken-app.sh +56 -0
- data/t/t0009-winch_ttin.sh +59 -0
- data/t/t0010-reap-logging.sh +55 -0
- data/t/t0011-active-unix-socket.sh +79 -0
- data/t/t0012-reload-empty-config.sh +85 -0
- data/t/t0013-rewindable-input-false.sh +24 -0
- data/t/t0013.ru +12 -0
- data/t/t0014-rewindable-input-true.sh +24 -0
- data/t/t0014.ru +12 -0
- data/t/t0015-configurator-internals.sh +25 -0
- data/t/t0016-trust-x-forwarded-false.sh +30 -0
- data/t/t0017-trust-x-forwarded-true.sh +30 -0
- data/t/t0018-write-on-close.sh +23 -0
- data/t/t0019-max_header_len.sh +49 -0
- data/t/t0020-at_exit-handler.sh +49 -0
- data/t/t0021-process_detach.sh +29 -0
- data/t/t0022-listener-names-preload_app.sh +32 -0
- data/t/t0100-rack-input-tests.sh +124 -0
- data/t/t0116-client_body_buffer_size.sh +80 -0
- data/t/t0116.ru +16 -0
- data/t/t0300-rails3-basic.sh +28 -0
- data/t/t0301-rails3-missing-config-ru.sh +33 -0
- data/t/t0302-rails3-alt-working_directory.sh +32 -0
- data/t/t0303-rails3-alt-working_directory_config.ru.sh +56 -0
- data/t/t0304-rails3-alt-working_directory_no_embed_cli.sh +52 -0
- data/t/t0600-https-server-basic.sh +48 -0
- data/t/t9000-preread-input.sh +48 -0
- data/t/t9001-oob_gc.sh +47 -0
- data/t/t9002-oob_gc-path.sh +75 -0
- data/t/test-lib.sh +113 -0
- data/t/test-rails3.sh +27 -0
- data/t/write-on-close.ru +11 -0
- data/test/aggregate.rb +15 -0
- data/test/benchmark/README +50 -0
- data/test/benchmark/dd.ru +18 -0
- data/test/benchmark/stack.ru +8 -0
- data/test/exec/README +5 -0
- data/test/exec/test_exec.rb +1055 -0
- data/test/rails/app-1.2.3/.gitignore +2 -0
- data/test/rails/app-1.2.3/Rakefile +7 -0
- data/test/rails/app-1.2.3/app/controllers/application.rb +6 -0
- data/test/rails/app-1.2.3/app/controllers/foo_controller.rb +36 -0
- data/test/rails/app-1.2.3/app/helpers/application_helper.rb +4 -0
- data/test/rails/app-1.2.3/config/boot.rb +11 -0
- data/test/rails/app-1.2.3/config/database.yml +12 -0
- data/test/rails/app-1.2.3/config/environment.rb +13 -0
- data/test/rails/app-1.2.3/config/environments/development.rb +9 -0
- data/test/rails/app-1.2.3/config/environments/production.rb +5 -0
- data/test/rails/app-1.2.3/config/routes.rb +6 -0
- data/test/rails/app-1.2.3/db/.gitignore +0 -0
- data/test/rails/app-1.2.3/public/404.html +1 -0
- data/test/rails/app-1.2.3/public/500.html +1 -0
- data/test/rails/app-2.0.2/.gitignore +2 -0
- data/test/rails/app-2.0.2/Rakefile +7 -0
- data/test/rails/app-2.0.2/app/controllers/application.rb +4 -0
- data/test/rails/app-2.0.2/app/controllers/foo_controller.rb +36 -0
- data/test/rails/app-2.0.2/app/helpers/application_helper.rb +4 -0
- data/test/rails/app-2.0.2/config/boot.rb +11 -0
- data/test/rails/app-2.0.2/config/database.yml +12 -0
- data/test/rails/app-2.0.2/config/environment.rb +17 -0
- data/test/rails/app-2.0.2/config/environments/development.rb +8 -0
- data/test/rails/app-2.0.2/config/environments/production.rb +5 -0
- data/test/rails/app-2.0.2/config/routes.rb +6 -0
- data/test/rails/app-2.0.2/db/.gitignore +0 -0
- data/test/rails/app-2.0.2/public/404.html +1 -0
- data/test/rails/app-2.0.2/public/500.html +1 -0
- data/test/rails/app-2.1.2/.gitignore +2 -0
- data/test/rails/app-2.1.2/Rakefile +7 -0
- data/test/rails/app-2.1.2/app/controllers/application.rb +4 -0
- data/test/rails/app-2.1.2/app/controllers/foo_controller.rb +36 -0
- data/test/rails/app-2.1.2/app/helpers/application_helper.rb +4 -0
- data/test/rails/app-2.1.2/config/boot.rb +111 -0
- data/test/rails/app-2.1.2/config/database.yml +12 -0
- data/test/rails/app-2.1.2/config/environment.rb +17 -0
- data/test/rails/app-2.1.2/config/environments/development.rb +7 -0
- data/test/rails/app-2.1.2/config/environments/production.rb +5 -0
- data/test/rails/app-2.1.2/config/routes.rb +6 -0
- data/test/rails/app-2.1.2/db/.gitignore +0 -0
- data/test/rails/app-2.1.2/public/404.html +1 -0
- data/test/rails/app-2.1.2/public/500.html +1 -0
- data/test/rails/app-2.2.2/.gitignore +2 -0
- data/test/rails/app-2.2.2/Rakefile +7 -0
- data/test/rails/app-2.2.2/app/controllers/application.rb +4 -0
- data/test/rails/app-2.2.2/app/controllers/foo_controller.rb +36 -0
- data/test/rails/app-2.2.2/app/helpers/application_helper.rb +4 -0
- data/test/rails/app-2.2.2/config/boot.rb +111 -0
- data/test/rails/app-2.2.2/config/database.yml +12 -0
- data/test/rails/app-2.2.2/config/environment.rb +17 -0
- data/test/rails/app-2.2.2/config/environments/development.rb +7 -0
- data/test/rails/app-2.2.2/config/environments/production.rb +5 -0
- data/test/rails/app-2.2.2/config/routes.rb +6 -0
- data/test/rails/app-2.2.2/db/.gitignore +0 -0
- data/test/rails/app-2.2.2/public/404.html +1 -0
- data/test/rails/app-2.2.2/public/500.html +1 -0
- data/test/rails/test_rails.rb +287 -0
- data/test/test_helper.rb +300 -0
- data/test/unit/test_configurator.rb +158 -0
- data/test/unit/test_droplet.rb +28 -0
- data/test/unit/test_http_parser.rb +860 -0
- data/test/unit/test_http_parser_ng.rb +716 -0
- data/test/unit/test_http_parser_xftrust.rb +38 -0
- data/test/unit/test_request.rb +197 -0
- data/test/unit/test_response.rb +99 -0
- data/test/unit/test_server.rb +289 -0
- data/test/unit/test_signals.rb +207 -0
- data/test/unit/test_sni_hostnames.rb +47 -0
- data/test/unit/test_socket_helper.rb +192 -0
- data/test/unit/test_stream_input.rb +204 -0
- data/test/unit/test_tee_input.rb +296 -0
- data/test/unit/test_upload.rb +306 -0
- data/test/unit/test_util.rb +100 -0
- data/unicorn-lb-patch.gemspec +27 -0
- metadata +561 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
. ./test-lib.sh
|
3
|
+
t_plan 11 "existing UNIX domain socket check"
|
4
|
+
|
5
|
+
read_pid_unix () {
|
6
|
+
x=$(printf 'GET / HTTP/1.0\r\n\r\n' | \
|
7
|
+
socat - UNIX:$unix_socket | \
|
8
|
+
tail -1)
|
9
|
+
test -n "$x"
|
10
|
+
y="$(expr "$x" : '\([0-9][0-9]*\)')"
|
11
|
+
test x"$x" = x"$y"
|
12
|
+
test -n "$y"
|
13
|
+
echo "$y"
|
14
|
+
}
|
15
|
+
|
16
|
+
t_begin "setup and start" && {
|
17
|
+
rtmpfiles unix_socket unix_config
|
18
|
+
rm -f $unix_socket
|
19
|
+
unicorn_setup
|
20
|
+
grep -v ^listen < $unicorn_config > $unix_config
|
21
|
+
echo "listen '$unix_socket'" >> $unix_config
|
22
|
+
unicorn -D -c $unix_config pid.ru
|
23
|
+
unicorn_wait_start
|
24
|
+
orig_master_pid=$unicorn_pid
|
25
|
+
}
|
26
|
+
|
27
|
+
t_begin "get pid of worker" && {
|
28
|
+
worker_pid=$(read_pid_unix)
|
29
|
+
t_info "worker_pid=$worker_pid"
|
30
|
+
}
|
31
|
+
|
32
|
+
t_begin "fails to start with existing pid file" && {
|
33
|
+
rm -f $ok
|
34
|
+
unicorn -D -c $unix_config pid.ru || echo ok > $ok
|
35
|
+
test x"$(cat $ok)" = xok
|
36
|
+
}
|
37
|
+
|
38
|
+
t_begin "worker pid unchanged" && {
|
39
|
+
test x"$(read_pid_unix)" = x$worker_pid
|
40
|
+
> $r_err
|
41
|
+
}
|
42
|
+
|
43
|
+
t_begin "fails to start with listening UNIX domain socket bound" && {
|
44
|
+
rm $ok $pid
|
45
|
+
unicorn -D -c $unix_config pid.ru || echo ok > $ok
|
46
|
+
test x"$(cat $ok)" = xok
|
47
|
+
> $r_err
|
48
|
+
}
|
49
|
+
|
50
|
+
t_begin "worker pid unchanged (again)" && {
|
51
|
+
test x"$(read_pid_unix)" = x$worker_pid
|
52
|
+
}
|
53
|
+
|
54
|
+
t_begin "nuking the existing Unicorn succeeds" && {
|
55
|
+
kill -9 $unicorn_pid $worker_pid
|
56
|
+
while kill -0 $unicorn_pid
|
57
|
+
do
|
58
|
+
sleep 1
|
59
|
+
done
|
60
|
+
check_stderr
|
61
|
+
}
|
62
|
+
|
63
|
+
t_begin "succeeds in starting with leftover UNIX domain socket bound" && {
|
64
|
+
test -S $unix_socket
|
65
|
+
unicorn -D -c $unix_config pid.ru
|
66
|
+
unicorn_wait_start
|
67
|
+
}
|
68
|
+
|
69
|
+
t_begin "worker pid changed" && {
|
70
|
+
test x"$(read_pid_unix)" != x$worker_pid
|
71
|
+
}
|
72
|
+
|
73
|
+
t_begin "killing succeeds" && {
|
74
|
+
kill $unicorn_pid
|
75
|
+
}
|
76
|
+
|
77
|
+
t_begin "no errors" && check_stderr
|
78
|
+
|
79
|
+
t_done
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
. ./test-lib.sh
|
3
|
+
t_plan 9 "reloading unset config resets defaults"
|
4
|
+
|
5
|
+
t_begin "setup and start" && {
|
6
|
+
unicorn_setup
|
7
|
+
rtmpfiles unicorn_config_orig before_reload after_reload
|
8
|
+
cat $unicorn_config > $unicorn_config_orig
|
9
|
+
cat >> $unicorn_config <<EOF
|
10
|
+
logger Logger.new(STDOUT)
|
11
|
+
preload_app true
|
12
|
+
timeout 0x7fffffff
|
13
|
+
worker_processes 2
|
14
|
+
after_fork { |s,w| }
|
15
|
+
\$dump_cfg = lambda { |fp,srv|
|
16
|
+
defaults = Unicorn::Configurator::DEFAULTS
|
17
|
+
defaults.keys.map { |x| x.to_s }.sort.each do |key|
|
18
|
+
next if key =~ %r{\Astd(?:err|out)_path\z}
|
19
|
+
key = key.to_sym
|
20
|
+
def_value = defaults[key]
|
21
|
+
srv_value = srv.__send__(key)
|
22
|
+
fp << "#{key}|#{srv_value}|#{def_value}\\n"
|
23
|
+
end
|
24
|
+
}
|
25
|
+
before_fork { |s,w|
|
26
|
+
File.open("$before_reload", "a") { |fp| \$dump_cfg.call(fp, s) }
|
27
|
+
}
|
28
|
+
before_exec { |s| }
|
29
|
+
EOF
|
30
|
+
unicorn -D -c $unicorn_config env.ru
|
31
|
+
unicorn_wait_start
|
32
|
+
}
|
33
|
+
|
34
|
+
t_begin "ensure worker is started" && {
|
35
|
+
curl -sSf http://$listen/ > $tmp
|
36
|
+
}
|
37
|
+
|
38
|
+
t_begin "replace config file with original(-ish)" && {
|
39
|
+
grep -v ^pid < $unicorn_config_orig > $unicorn_config
|
40
|
+
cat >> $unicorn_config <<EOF
|
41
|
+
before_fork { |s,w|
|
42
|
+
File.open("$after_reload", "a") { |fp| \$dump_cfg.call(fp, s) }
|
43
|
+
}
|
44
|
+
EOF
|
45
|
+
}
|
46
|
+
|
47
|
+
t_begin "reload signal succeeds" && {
|
48
|
+
kill -HUP $unicorn_pid
|
49
|
+
while ! egrep '(done|error) reloading' $r_err >/dev/null
|
50
|
+
do
|
51
|
+
sleep 1
|
52
|
+
done
|
53
|
+
while ! grep reaped < $r_err >/dev/null
|
54
|
+
do
|
55
|
+
sleep 1
|
56
|
+
done
|
57
|
+
grep 'done reloading' $r_err >/dev/null
|
58
|
+
}
|
59
|
+
|
60
|
+
t_begin "ensure worker is started" && {
|
61
|
+
curl -sSf http://$listen/ > $tmp
|
62
|
+
}
|
63
|
+
|
64
|
+
t_begin "pid file no longer exists" && {
|
65
|
+
if test -f $pid
|
66
|
+
then
|
67
|
+
die "pid=$pid should not exist"
|
68
|
+
fi
|
69
|
+
}
|
70
|
+
|
71
|
+
t_begin "killing succeeds" && {
|
72
|
+
kill $unicorn_pid
|
73
|
+
}
|
74
|
+
|
75
|
+
t_begin "check stderr" && {
|
76
|
+
check_stderr
|
77
|
+
}
|
78
|
+
|
79
|
+
t_begin "ensure reloading restored settings" && {
|
80
|
+
awk < $after_reload -F'|' '
|
81
|
+
$1 != "before_fork" && $2 != $3 { print $0; exit(1) }
|
82
|
+
'
|
83
|
+
}
|
84
|
+
|
85
|
+
t_done
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
. ./test-lib.sh
|
3
|
+
t_plan 4 "rewindable_input toggled to false"
|
4
|
+
|
5
|
+
t_begin "setup and start" && {
|
6
|
+
unicorn_setup
|
7
|
+
echo rewindable_input false >> $unicorn_config
|
8
|
+
unicorn -D -c $unicorn_config t0013.ru
|
9
|
+
unicorn_wait_start
|
10
|
+
}
|
11
|
+
|
12
|
+
t_begin "ensure worker is started" && {
|
13
|
+
test xOK = x$(curl -T t0013.ru -H Expect: -vsSf http://$listen/)
|
14
|
+
}
|
15
|
+
|
16
|
+
t_begin "killing succeeds" && {
|
17
|
+
kill $unicorn_pid
|
18
|
+
}
|
19
|
+
|
20
|
+
t_begin "check stderr" && {
|
21
|
+
check_stderr
|
22
|
+
}
|
23
|
+
|
24
|
+
t_done
|
data/t/t0013.ru
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
. ./test-lib.sh
|
3
|
+
t_plan 4 "rewindable_input toggled to true"
|
4
|
+
|
5
|
+
t_begin "setup and start" && {
|
6
|
+
unicorn_setup
|
7
|
+
echo rewindable_input true >> $unicorn_config
|
8
|
+
unicorn -D -c $unicorn_config t0014.ru
|
9
|
+
unicorn_wait_start
|
10
|
+
}
|
11
|
+
|
12
|
+
t_begin "ensure worker is started" && {
|
13
|
+
test xOK = x$(curl -T t0014.ru -sSf http://$listen/)
|
14
|
+
}
|
15
|
+
|
16
|
+
t_begin "killing succeeds" && {
|
17
|
+
kill $unicorn_pid
|
18
|
+
}
|
19
|
+
|
20
|
+
t_begin "check stderr" && {
|
21
|
+
check_stderr
|
22
|
+
}
|
23
|
+
|
24
|
+
t_done
|
data/t/t0014.ru
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
. ./test-lib.sh
|
3
|
+
t_plan 4 "configurator internals tests (from FAQ)"
|
4
|
+
|
5
|
+
t_begin "setup and start" && {
|
6
|
+
unicorn_setup
|
7
|
+
cat >> $unicorn_config <<EOF
|
8
|
+
HttpRequest::DEFAULTS["rack.url_scheme"] = "https"
|
9
|
+
Configurator::DEFAULTS[:logger].formatter = Logger::Formatter.new
|
10
|
+
EOF
|
11
|
+
unicorn -D -c $unicorn_config env.ru
|
12
|
+
unicorn_wait_start
|
13
|
+
}
|
14
|
+
|
15
|
+
t_begin "single request" && {
|
16
|
+
curl -sSfv http://$listen/ | grep '"rack.url_scheme"=>"https"'
|
17
|
+
}
|
18
|
+
|
19
|
+
t_begin "killing succeeds" && {
|
20
|
+
kill $unicorn_pid
|
21
|
+
}
|
22
|
+
|
23
|
+
t_begin "no errors" && check_stderr
|
24
|
+
|
25
|
+
t_done
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
. ./test-lib.sh
|
3
|
+
t_plan 5 "trust_x_forwarded=false configuration test"
|
4
|
+
|
5
|
+
t_begin "setup and start" && {
|
6
|
+
unicorn_setup
|
7
|
+
echo "trust_x_forwarded false" >> $unicorn_config
|
8
|
+
unicorn -D -c $unicorn_config env.ru
|
9
|
+
unicorn_wait_start
|
10
|
+
}
|
11
|
+
|
12
|
+
t_begin "spoofed request with X-Forwarded-Proto does not trigger" && {
|
13
|
+
curl -H 'X-Forwarded-Proto: https' http://$listen/ | \
|
14
|
+
grep -F '"rack.url_scheme"=>"http"'
|
15
|
+
}
|
16
|
+
|
17
|
+
t_begin "spoofed request with X-Forwarded-SSL does not trigger" && {
|
18
|
+
curl -H 'X-Forwarded-SSL: on' http://$listen/ | \
|
19
|
+
grep -F '"rack.url_scheme"=>"http"'
|
20
|
+
}
|
21
|
+
|
22
|
+
t_begin "killing succeeds" && {
|
23
|
+
kill $unicorn_pid
|
24
|
+
}
|
25
|
+
|
26
|
+
t_begin "check stderr has no errors" && {
|
27
|
+
check_stderr
|
28
|
+
}
|
29
|
+
|
30
|
+
t_done
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
. ./test-lib.sh
|
3
|
+
t_plan 5 "trust_x_forwarded=true configuration test"
|
4
|
+
|
5
|
+
t_begin "setup and start" && {
|
6
|
+
unicorn_setup
|
7
|
+
echo "trust_x_forwarded true " >> $unicorn_config
|
8
|
+
unicorn -D -c $unicorn_config env.ru
|
9
|
+
unicorn_wait_start
|
10
|
+
}
|
11
|
+
|
12
|
+
t_begin "spoofed request with X-Forwarded-Proto sets 'https'" && {
|
13
|
+
curl -H 'X-Forwarded-Proto: https' http://$listen/ | \
|
14
|
+
grep -F '"rack.url_scheme"=>"https"'
|
15
|
+
}
|
16
|
+
|
17
|
+
t_begin "spoofed request with X-Forwarded-SSL sets 'https'" && {
|
18
|
+
curl -H 'X-Forwarded-SSL: on' http://$listen/ | \
|
19
|
+
grep -F '"rack.url_scheme"=>"https"'
|
20
|
+
}
|
21
|
+
|
22
|
+
t_begin "killing succeeds" && {
|
23
|
+
kill $unicorn_pid
|
24
|
+
}
|
25
|
+
|
26
|
+
t_begin "check stderr has no errors" && {
|
27
|
+
check_stderr
|
28
|
+
}
|
29
|
+
|
30
|
+
t_done
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
. ./test-lib.sh
|
3
|
+
t_plan 4 "write-on-close tests for funky response-bodies"
|
4
|
+
|
5
|
+
t_begin "setup and start" && {
|
6
|
+
unicorn_setup
|
7
|
+
unicorn -D -c $unicorn_config write-on-close.ru
|
8
|
+
unicorn_wait_start
|
9
|
+
}
|
10
|
+
|
11
|
+
t_begin "write-on-close response body succeeds" && {
|
12
|
+
test xGoodbye = x"$(curl -sSf http://$listen/)"
|
13
|
+
}
|
14
|
+
|
15
|
+
t_begin "killing succeeds" && {
|
16
|
+
kill $unicorn_pid
|
17
|
+
}
|
18
|
+
|
19
|
+
t_begin "check stderr" && {
|
20
|
+
check_stderr
|
21
|
+
}
|
22
|
+
|
23
|
+
t_done
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
. ./test-lib.sh
|
3
|
+
t_plan 5 "max_header_len setting (only intended for Rainbows!)"
|
4
|
+
|
5
|
+
t_begin "setup and start" && {
|
6
|
+
unicorn_setup
|
7
|
+
req='GET / HTTP/1.0\r\n\r\n'
|
8
|
+
len=$(printf "$req" | wc -c)
|
9
|
+
echo Unicorn::HttpParser.max_header_len = $len >> $unicorn_config
|
10
|
+
unicorn -D -c $unicorn_config env.ru
|
11
|
+
unicorn_wait_start
|
12
|
+
}
|
13
|
+
|
14
|
+
t_begin "minimal request succeeds" && {
|
15
|
+
rm -f $tmp
|
16
|
+
(
|
17
|
+
cat $fifo > $tmp &
|
18
|
+
printf "$req"
|
19
|
+
wait
|
20
|
+
echo ok > $ok
|
21
|
+
) | socat - TCP:$listen > $fifo
|
22
|
+
test xok = x$(cat $ok)
|
23
|
+
|
24
|
+
fgrep "HTTP/1.1 200 OK" $tmp
|
25
|
+
}
|
26
|
+
|
27
|
+
t_begin "big request fails" && {
|
28
|
+
rm -f $tmp
|
29
|
+
(
|
30
|
+
cat $fifo > $tmp &
|
31
|
+
printf 'GET /xxxxxx HTTP/1.0\r\n\r\n'
|
32
|
+
wait
|
33
|
+
echo ok > $ok
|
34
|
+
) | socat - TCP:$listen > $fifo
|
35
|
+
test xok = x$(cat $ok)
|
36
|
+
fgrep "HTTP/1.1 413" $tmp
|
37
|
+
}
|
38
|
+
|
39
|
+
dbgcat tmp
|
40
|
+
|
41
|
+
t_begin "killing succeeds" && {
|
42
|
+
kill $unicorn_pid
|
43
|
+
}
|
44
|
+
|
45
|
+
t_begin "check stderr" && {
|
46
|
+
check_stderr
|
47
|
+
}
|
48
|
+
|
49
|
+
t_done
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
. ./test-lib.sh
|
3
|
+
|
4
|
+
t_plan 5 "at_exit/END handlers work as expected"
|
5
|
+
|
6
|
+
t_begin "setup and startup" && {
|
7
|
+
unicorn_setup
|
8
|
+
cat >> $unicorn_config <<EOF
|
9
|
+
at_exit { \$stdout.syswrite("#{Process.pid} BOTH\\n") }
|
10
|
+
END { \$stdout.syswrite("#{Process.pid} END BOTH\\n") }
|
11
|
+
after_fork do |_,_|
|
12
|
+
at_exit { \$stdout.syswrite("#{Process.pid} WORKER ONLY\\n") }
|
13
|
+
END { \$stdout.syswrite("#{Process.pid} END WORKER ONLY\\n") }
|
14
|
+
end
|
15
|
+
EOF
|
16
|
+
|
17
|
+
unicorn -D pid.ru -c $unicorn_config
|
18
|
+
unicorn_wait_start
|
19
|
+
}
|
20
|
+
|
21
|
+
t_begin "read worker PID" && {
|
22
|
+
worker_pid=$(curl -sSf http://$listen/)
|
23
|
+
t_info "worker_pid=$worker_pid"
|
24
|
+
}
|
25
|
+
|
26
|
+
t_begin "issue graceful shutdown (SIGQUIT) and wait for termination" && {
|
27
|
+
kill -QUIT $unicorn_pid
|
28
|
+
|
29
|
+
while kill -0 $unicorn_pid >/dev/null 2>&1
|
30
|
+
do
|
31
|
+
sleep 1
|
32
|
+
done
|
33
|
+
}
|
34
|
+
|
35
|
+
t_begin "check stderr" && check_stderr
|
36
|
+
|
37
|
+
dbgcat r_err
|
38
|
+
dbgcat r_out
|
39
|
+
|
40
|
+
t_begin "all at_exit handlers ran" && {
|
41
|
+
grep "$worker_pid BOTH" $r_out
|
42
|
+
grep "$unicorn_pid BOTH" $r_out
|
43
|
+
grep "$worker_pid END BOTH" $r_out
|
44
|
+
grep "$unicorn_pid END BOTH" $r_out
|
45
|
+
grep "$worker_pid WORKER ONLY" $r_out
|
46
|
+
grep "$worker_pid END WORKER ONLY" $r_out
|
47
|
+
}
|
48
|
+
|
49
|
+
t_done
|