unicorn-shopify 4.8.2.5.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.CHANGELOG.old +25 -0
- data/.document +28 -0
- data/.gitignore +25 -0
- data/.mailmap +26 -0
- data/.olddoc.yml +15 -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 +185 -0
- data/Documentation/unicorn_rails.1.txt +175 -0
- data/FAQ +61 -0
- data/GIT-VERSION-GEN +39 -0
- data/GNUmakefile +252 -0
- data/HACKING +120 -0
- data/ISSUES +100 -0
- data/KNOWN_ISSUES +79 -0
- data/LICENSE +67 -0
- data/Links +59 -0
- data/PHILOSOPHY +145 -0
- data/README +145 -0
- data/Rakefile +16 -0
- data/SIGNALS +123 -0
- data/Sandbox +103 -0
- data/TODO +5 -0
- data/TUNING +101 -0
- data/archive/.gitignore +3 -0
- data/archive/slrnpull.conf +4 -0
- data/bin/unicorn +126 -0
- data/bin/unicorn_rails +209 -0
- data/examples/big_app_gc.rb +2 -0
- data/examples/echo.ru +27 -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 +113 -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 +82 -0
- data/ext/unicorn_http/extconf.rb +10 -0
- data/ext/unicorn_http/global_variables.h +97 -0
- data/ext/unicorn_http/httpdate.c +78 -0
- data/ext/unicorn_http/unicorn_http.rl +934 -0
- data/ext/unicorn_http/unicorn_http_common.rl +76 -0
- data/lib/unicorn.rb +112 -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 +686 -0
- data/lib/unicorn/const.rb +21 -0
- data/lib/unicorn/http_request.rb +125 -0
- data/lib/unicorn/http_response.rb +73 -0
- data/lib/unicorn/http_server.rb +816 -0
- data/lib/unicorn/launcher.rb +62 -0
- data/lib/unicorn/oob_gc.rb +81 -0
- data/lib/unicorn/preread_input.rb +33 -0
- data/lib/unicorn/socket_helper.rb +197 -0
- data/lib/unicorn/stream_input.rb +146 -0
- data/lib/unicorn/tee_input.rb +133 -0
- data/lib/unicorn/tmpio.rb +27 -0
- data/lib/unicorn/util.rb +90 -0
- data/lib/unicorn/worker.rb +140 -0
- data/setup.rb +1586 -0
- data/t/.gitignore +4 -0
- data/t/GNUmakefile +74 -0
- data/t/README +42 -0
- data/t/before_murder.ru +7 -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/broken-app.ru +12 -0
- data/t/detach.ru +11 -0
- data/t/env.ru +3 -0
- data/t/fails-rack-lint.ru +5 -0
- data/t/heartbeat-timeout.ru +12 -0
- data/t/hijack.ru +42 -0
- data/t/listener_names.ru +4 -0
- data/t/my-tap-lib.sh +201 -0
- data/t/oob_gc.ru +20 -0
- data/t/oob_gc_path.ru +20 -0
- data/t/pid.ru +3 -0
- data/t/preread_input.ru +17 -0
- data/t/rack-input-tests.ru +21 -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 +40 -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/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/t0023-before-murder.sh +40 -0
- data/t/t0024-before-murder_once.sh +52 -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/t0200-rack-hijack.sh +27 -0
- data/t/t0300-no-default-middleware.sh +20 -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 +128 -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 +1047 -0
- data/test/test_helper.rb +297 -0
- data/test/unit/test_configurator.rb +175 -0
- data/test/unit/test_droplet.rb +28 -0
- data/test/unit/test_http_parser.rb +854 -0
- data/test/unit/test_http_parser_ng.rb +622 -0
- data/test/unit/test_request.rb +182 -0
- data/test/unit/test_response.rb +93 -0
- data/test/unit/test_server.rb +268 -0
- data/test/unit/test_signals.rb +188 -0
- data/test/unit/test_socket_helper.rb +197 -0
- data/test/unit/test_stream_input.rb +203 -0
- data/test/unit/test_tee_input.rb +304 -0
- data/test/unit/test_upload.rb +306 -0
- data/test/unit/test_util.rb +105 -0
- data/unicorn.gemspec +41 -0
- metadata +311 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
. ./test-lib.sh
|
|
3
|
+
t_plan 5 "before murder is called"
|
|
4
|
+
|
|
5
|
+
t_begin "setup and start" && {
|
|
6
|
+
unicorn_setup
|
|
7
|
+
cat >> $unicorn_config <<EOF
|
|
8
|
+
timeout 5
|
|
9
|
+
after_fork { |s,w| File.open('$fifo','w') { |f| f.write '.' } }
|
|
10
|
+
before_murder do |s, w, p|
|
|
11
|
+
\$stderr.puts "before murder called:"
|
|
12
|
+
end
|
|
13
|
+
EOF
|
|
14
|
+
unicorn -c $unicorn_config before_murder.ru &
|
|
15
|
+
test '.' = $(cat $fifo)
|
|
16
|
+
unicorn_wait_start
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
t_begin "start worker=0" && {
|
|
20
|
+
pid=$(curl http://$listen/) || true
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
t_begin "ensure before murder log is present" && {
|
|
24
|
+
dbgcat r_err
|
|
25
|
+
grep 'before murder called:' $r_err
|
|
26
|
+
dbgcat r_err
|
|
27
|
+
> $r_err
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
t_begin "killing succeeds" && {
|
|
31
|
+
kill $unicorn_pid
|
|
32
|
+
wait
|
|
33
|
+
kill -0 $unicorn_pid && false
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
t_begin "check stderr" && {
|
|
37
|
+
check_stderr
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
t_done
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
. ./test-lib.sh
|
|
3
|
+
t_plan 5 "before murder is called only once"
|
|
4
|
+
|
|
5
|
+
t_begin "setup and start" && {
|
|
6
|
+
unicorn_setup
|
|
7
|
+
cat >> $unicorn_config <<EOF
|
|
8
|
+
timeout 5
|
|
9
|
+
after_fork { |s,w| File.open('$fifo','w') { |f| f.write '.' } }
|
|
10
|
+
class Unicorn::HttpServer
|
|
11
|
+
alias_method :kill_worker_always, :kill_worker
|
|
12
|
+
def kill_worker(signal, wpid)
|
|
13
|
+
@iteration ||= 0
|
|
14
|
+
\$stderr.puts "kill_worker #{signal} #{wpid} #{@iteration}"
|
|
15
|
+
kill_worker_always(signal, wpid) if @iteration > 0
|
|
16
|
+
@iteration += 1
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
before_murder do |s, w, p|
|
|
20
|
+
\$stderr.puts "before murder called:"
|
|
21
|
+
end
|
|
22
|
+
EOF
|
|
23
|
+
unicorn -c $unicorn_config before_murder.ru &
|
|
24
|
+
test '.' = $(cat $fifo)
|
|
25
|
+
unicorn_wait_start
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
t_begin "start worker=0" && {
|
|
29
|
+
pid=$(curl http://$listen/) || true
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
t_begin "ensure before murder log is present once and killing is present twice" && {
|
|
33
|
+
dbgcat r_err
|
|
34
|
+
grep 'before murder called:' $r_err
|
|
35
|
+
test 1 -eq $(grep "before murder called:" $r_err | count_lines)
|
|
36
|
+
test 2 -eq $(grep timeout $r_err | grep killing | count_lines)
|
|
37
|
+
test 2 -eq $(grep "kill_worker KILL" $r_err | count_lines)
|
|
38
|
+
dbgcat r_err
|
|
39
|
+
> $r_err
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
t_begin "killing succeeds" && {
|
|
43
|
+
kill $unicorn_pid
|
|
44
|
+
wait
|
|
45
|
+
kill -0 $unicorn_pid && false
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
t_begin "check stderr" && {
|
|
49
|
+
check_stderr
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
t_done
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
. ./test-lib.sh
|
|
3
|
+
test -r random_blob || die "random_blob required, run with 'make $0'"
|
|
4
|
+
|
|
5
|
+
t_plan 10 "rack.input read tests"
|
|
6
|
+
|
|
7
|
+
t_begin "setup and startup" && {
|
|
8
|
+
rtmpfiles curl_out curl_err
|
|
9
|
+
unicorn_setup
|
|
10
|
+
unicorn -E none -D rack-input-tests.ru -c $unicorn_config
|
|
11
|
+
blob_sha1=$(rsha1 < random_blob)
|
|
12
|
+
blob_size=$(count_bytes < random_blob)
|
|
13
|
+
t_info "blob_sha1=$blob_sha1"
|
|
14
|
+
unicorn_wait_start
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
t_begin "corked identity request" && {
|
|
18
|
+
rm -f $tmp
|
|
19
|
+
(
|
|
20
|
+
cat $fifo > $tmp &
|
|
21
|
+
printf 'PUT / HTTP/1.0\r\n'
|
|
22
|
+
printf 'Content-Length: %d\r\n\r\n' $blob_size
|
|
23
|
+
cat random_blob
|
|
24
|
+
wait
|
|
25
|
+
echo ok > $ok
|
|
26
|
+
) | ( sleep 1 && socat - TCP4:$listen > $fifo )
|
|
27
|
+
test 1 -eq $(grep $blob_sha1 $tmp |count_lines)
|
|
28
|
+
test x"$(cat $ok)" = xok
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
t_begin "corked chunked request" && {
|
|
32
|
+
rm -f $tmp
|
|
33
|
+
(
|
|
34
|
+
cat $fifo > $tmp &
|
|
35
|
+
content-md5-put < random_blob
|
|
36
|
+
wait
|
|
37
|
+
echo ok > $ok
|
|
38
|
+
) | ( sleep 1 && socat - TCP4:$listen > $fifo )
|
|
39
|
+
test 1 -eq $(grep $blob_sha1 $tmp |count_lines)
|
|
40
|
+
test x"$(cat $ok)" = xok
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
t_begin "corked identity request (input#size first)" && {
|
|
44
|
+
rm -f $tmp
|
|
45
|
+
(
|
|
46
|
+
cat $fifo > $tmp &
|
|
47
|
+
printf 'PUT /size_first HTTP/1.0\r\n'
|
|
48
|
+
printf 'Content-Length: %d\r\n\r\n' $blob_size
|
|
49
|
+
cat random_blob
|
|
50
|
+
wait
|
|
51
|
+
echo ok > $ok
|
|
52
|
+
) | ( sleep 1 && socat - TCP4:$listen > $fifo )
|
|
53
|
+
test 1 -eq $(grep $blob_sha1 $tmp |count_lines)
|
|
54
|
+
test x"$(cat $ok)" = xok
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
t_begin "corked identity request (input#rewind first)" && {
|
|
58
|
+
rm -f $tmp
|
|
59
|
+
(
|
|
60
|
+
cat $fifo > $tmp &
|
|
61
|
+
printf 'PUT /rewind_first HTTP/1.0\r\n'
|
|
62
|
+
printf 'Content-Length: %d\r\n\r\n' $blob_size
|
|
63
|
+
cat random_blob
|
|
64
|
+
wait
|
|
65
|
+
echo ok > $ok
|
|
66
|
+
) | ( sleep 1 && socat - TCP4:$listen > $fifo )
|
|
67
|
+
test 1 -eq $(grep $blob_sha1 $tmp |count_lines)
|
|
68
|
+
test x"$(cat $ok)" = xok
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
t_begin "corked chunked request (input#size first)" && {
|
|
72
|
+
rm -f $tmp
|
|
73
|
+
(
|
|
74
|
+
cat $fifo > $tmp &
|
|
75
|
+
printf 'PUT /size_first HTTP/1.1\r\n'
|
|
76
|
+
printf 'Host: example.com\r\n'
|
|
77
|
+
printf 'Transfer-Encoding: chunked\r\n'
|
|
78
|
+
printf 'Trailer: Content-MD5\r\n'
|
|
79
|
+
printf '\r\n'
|
|
80
|
+
content-md5-put --no-headers < random_blob
|
|
81
|
+
wait
|
|
82
|
+
echo ok > $ok
|
|
83
|
+
) | ( sleep 1 && socat - TCP4:$listen > $fifo )
|
|
84
|
+
test 1 -eq $(grep $blob_sha1 $tmp |count_lines)
|
|
85
|
+
test 1 -eq $(grep $blob_sha1 $tmp |count_lines)
|
|
86
|
+
test x"$(cat $ok)" = xok
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
t_begin "corked chunked request (input#rewind first)" && {
|
|
90
|
+
rm -f $tmp
|
|
91
|
+
(
|
|
92
|
+
cat $fifo > $tmp &
|
|
93
|
+
printf 'PUT /rewind_first HTTP/1.1\r\n'
|
|
94
|
+
printf 'Host: example.com\r\n'
|
|
95
|
+
printf 'Transfer-Encoding: chunked\r\n'
|
|
96
|
+
printf 'Trailer: Content-MD5\r\n'
|
|
97
|
+
printf '\r\n'
|
|
98
|
+
content-md5-put --no-headers < random_blob
|
|
99
|
+
wait
|
|
100
|
+
echo ok > $ok
|
|
101
|
+
) | ( sleep 1 && socat - TCP4:$listen > $fifo )
|
|
102
|
+
test 1 -eq $(grep $blob_sha1 $tmp |count_lines)
|
|
103
|
+
test x"$(cat $ok)" = xok
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
t_begin "regular request" && {
|
|
107
|
+
curl -sSf -T random_blob http://$listen/ > $curl_out 2> $curl_err
|
|
108
|
+
test x$blob_sha1 = x$(cat $curl_out)
|
|
109
|
+
test ! -s $curl_err
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
t_begin "chunked request" && {
|
|
113
|
+
curl -sSf -T- < random_blob http://$listen/ > $curl_out 2> $curl_err
|
|
114
|
+
test x$blob_sha1 = x$(cat $curl_out)
|
|
115
|
+
test ! -s $curl_err
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
dbgcat r_err
|
|
119
|
+
|
|
120
|
+
t_begin "shutdown" && {
|
|
121
|
+
kill $unicorn_pid
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
t_done
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
. ./test-lib.sh
|
|
3
|
+
t_plan 12 "client_body_buffer_size settings"
|
|
4
|
+
|
|
5
|
+
t_begin "setup and start" && {
|
|
6
|
+
unicorn_setup
|
|
7
|
+
rtmpfiles unicorn_config_tmp one_meg
|
|
8
|
+
dd if=/dev/zero bs=1M count=1 of=$one_meg
|
|
9
|
+
cat >> $unicorn_config <<EOF
|
|
10
|
+
after_fork do |server, worker|
|
|
11
|
+
File.open("$fifo", "wb") { |fp| fp.syswrite "START" }
|
|
12
|
+
end
|
|
13
|
+
EOF
|
|
14
|
+
cat $unicorn_config > $unicorn_config_tmp
|
|
15
|
+
echo client_body_buffer_size 0 >> $unicorn_config
|
|
16
|
+
unicorn -D -c $unicorn_config t0116.ru
|
|
17
|
+
unicorn_wait_start
|
|
18
|
+
fs_class=Unicorn::TmpIO
|
|
19
|
+
mem_class=StringIO
|
|
20
|
+
|
|
21
|
+
test x"$(cat $fifo)" = xSTART
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
t_begin "class for a zero-byte file should be StringIO" && {
|
|
25
|
+
> $tmp
|
|
26
|
+
test xStringIO = x"$(curl -T $tmp -sSf http://$listen/input_class)"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
t_begin "class for a 1 byte file should be filesystem-backed" && {
|
|
30
|
+
echo > $tmp
|
|
31
|
+
test x$fs_class = x"$(curl -T $tmp -sSf http://$listen/tmp_class)"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
t_begin "reload with default client_body_buffer_size" && {
|
|
35
|
+
mv $unicorn_config_tmp $unicorn_config
|
|
36
|
+
kill -HUP $unicorn_pid
|
|
37
|
+
test x"$(cat $fifo)" = xSTART
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
t_begin "class for a 1 byte file should be memory-backed" && {
|
|
41
|
+
echo > $tmp
|
|
42
|
+
test x$mem_class = x"$(curl -T $tmp -sSf http://$listen/tmp_class)"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
t_begin "class for a random blob file should be filesystem-backed" && {
|
|
46
|
+
resp="$(curl -T random_blob -sSf http://$listen/tmp_class)"
|
|
47
|
+
test x$fs_class = x"$resp"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
t_begin "one megabyte file should be filesystem-backed" && {
|
|
51
|
+
resp="$(curl -T $one_meg -sSf http://$listen/tmp_class)"
|
|
52
|
+
test x$fs_class = x"$resp"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
t_begin "reload with a big client_body_buffer_size" && {
|
|
56
|
+
echo "client_body_buffer_size(1024 * 1024)" >> $unicorn_config
|
|
57
|
+
kill -HUP $unicorn_pid
|
|
58
|
+
test x"$(cat $fifo)" = xSTART
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
t_begin "one megabyte file should be memory-backed" && {
|
|
62
|
+
resp="$(curl -T $one_meg -sSf http://$listen/tmp_class)"
|
|
63
|
+
test x$mem_class = x"$resp"
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
t_begin "one megabyte + 1 byte file should be filesystem-backed" && {
|
|
67
|
+
echo >> $one_meg
|
|
68
|
+
resp="$(curl -T $one_meg -sSf http://$listen/tmp_class)"
|
|
69
|
+
test x$fs_class = x"$resp"
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
t_begin "killing succeeds" && {
|
|
73
|
+
kill $unicorn_pid
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
t_begin "check stderr" && {
|
|
77
|
+
check_stderr
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
t_done
|
data/t/t0116.ru
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#\ -E none
|
|
2
|
+
use Rack::ContentLength
|
|
3
|
+
use Rack::ContentType, 'text/plain'
|
|
4
|
+
app = lambda do |env|
|
|
5
|
+
input = env['rack.input']
|
|
6
|
+
case env["PATH_INFO"]
|
|
7
|
+
when "/tmp_class"
|
|
8
|
+
body = input.instance_variable_get(:@tmp).class.name
|
|
9
|
+
when "/input_class"
|
|
10
|
+
body = input.class.name
|
|
11
|
+
else
|
|
12
|
+
return [ 500, {}, [] ]
|
|
13
|
+
end
|
|
14
|
+
[ 200, {}, [ body ] ]
|
|
15
|
+
end
|
|
16
|
+
run app
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
. ./test-lib.sh
|
|
3
|
+
t_plan 5 "rack.hijack tests (Rack 1.5+ (Rack::VERSION >= [ 1,2]))"
|
|
4
|
+
|
|
5
|
+
t_begin "setup and start" && {
|
|
6
|
+
unicorn_setup
|
|
7
|
+
unicorn -D -c $unicorn_config hijack.ru
|
|
8
|
+
unicorn_wait_start
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
t_begin "check request hijack" && {
|
|
12
|
+
test "xrequest.hijacked" = x"$(curl -sSfv http://$listen/hijack_req)"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
t_begin "check response hijack" && {
|
|
16
|
+
test "xresponse.hijacked" = x"$(curl -sSfv http://$listen/hijack_res)"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
t_begin "killing succeeds" && {
|
|
20
|
+
kill $unicorn_pid
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
t_begin "check stderr" && {
|
|
24
|
+
check_stderr
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
t_done
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
. ./test-lib.sh
|
|
3
|
+
t_plan 3 "test the -N / --no-default-middleware option"
|
|
4
|
+
|
|
5
|
+
t_begin "setup and start" && {
|
|
6
|
+
unicorn_setup
|
|
7
|
+
unicorn -N -D -c $unicorn_config fails-rack-lint.ru
|
|
8
|
+
unicorn_wait_start
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
t_begin "check exit status with Rack::Lint not present" && {
|
|
12
|
+
test 42 -eq "$(curl -sf -o/dev/null -w'%{http_code}' http://$listen/)"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
t_begin "killing succeeds" && {
|
|
16
|
+
kill $unicorn_pid
|
|
17
|
+
check_stderr
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
t_done
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
. ./test-lib.sh
|
|
3
|
+
t_plan 9 "PrereadInput middleware tests"
|
|
4
|
+
|
|
5
|
+
t_begin "setup and start" && {
|
|
6
|
+
random_blob_sha1=$(rsha1 < random_blob)
|
|
7
|
+
unicorn_setup
|
|
8
|
+
unicorn -D -c $unicorn_config preread_input.ru
|
|
9
|
+
unicorn_wait_start
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
t_begin "single identity request" && {
|
|
13
|
+
curl -sSf -T random_blob http://$listen/ > $tmp
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
t_begin "sha1 matches" && {
|
|
17
|
+
test x"$(cat $tmp)" = x"$random_blob_sha1"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
t_begin "single chunked request" && {
|
|
21
|
+
curl -sSf -T- < random_blob http://$listen/ > $tmp
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
t_begin "sha1 matches" && {
|
|
25
|
+
test x"$(cat $tmp)" = x"$random_blob_sha1"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
t_begin "app only dispatched twice" && {
|
|
29
|
+
test 2 -eq "$(grep 'app dispatch:' < $r_err | count_lines )"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
t_begin "aborted chunked request" && {
|
|
33
|
+
rm -f $tmp
|
|
34
|
+
curl -sSf -T- < $fifo http://$listen/ > $tmp &
|
|
35
|
+
curl_pid=$!
|
|
36
|
+
kill -9 $curl_pid
|
|
37
|
+
wait
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
t_begin "app only dispatched twice" && {
|
|
41
|
+
test 2 -eq "$(grep 'app dispatch:' < $r_err | count_lines )"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
t_begin "killing succeeds" && {
|
|
45
|
+
kill -QUIT $unicorn_pid
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
t_done
|
data/t/t9001-oob_gc.sh
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
. ./test-lib.sh
|
|
3
|
+
t_plan 9 "OobGC test"
|
|
4
|
+
|
|
5
|
+
t_begin "setup and start" && {
|
|
6
|
+
unicorn_setup
|
|
7
|
+
unicorn -D -c $unicorn_config oob_gc.ru
|
|
8
|
+
unicorn_wait_start
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
t_begin "test default interval (4 requests)" && {
|
|
12
|
+
test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
|
|
13
|
+
test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
|
|
14
|
+
test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
|
|
15
|
+
test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
t_begin "GC starting-request returns immediately" && {
|
|
19
|
+
test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
t_begin "GC is started after 5 requests" && {
|
|
23
|
+
test xtrue = x$(curl -vsSf http://$listen/ 2>> $tmp)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
t_begin "reset GC" && {
|
|
27
|
+
test xfalse = x$(curl -vsSf -X POST http://$listen/gc_reset 2>> $tmp)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
t_begin "test default interval again (3 requests)" && {
|
|
31
|
+
test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
|
|
32
|
+
test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
|
|
33
|
+
test xfalse = x$(curl -vsSf http://$listen/ 2>> $tmp)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
t_begin "GC is started after 5 requests" && {
|
|
37
|
+
test xtrue = x$(curl -vsSf http://$listen/ 2>> $tmp)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
t_begin "killing succeeds" && {
|
|
41
|
+
kill -QUIT $unicorn_pid
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
t_begin "check_stderr" && check_stderr
|
|
45
|
+
dbgcat r_err
|
|
46
|
+
|
|
47
|
+
t_done
|