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.
Files changed (249) hide show
  1. data/.CHANGELOG.old +25 -0
  2. data/.document +29 -0
  3. data/.gitignore +25 -0
  4. data/.mailmap +26 -0
  5. data/.wrongdoc.yml +10 -0
  6. data/Application_Timeouts +77 -0
  7. data/CONTRIBUTORS +35 -0
  8. data/COPYING +674 -0
  9. data/DESIGN +97 -0
  10. data/Documentation/.gitignore +5 -0
  11. data/Documentation/GNUmakefile +30 -0
  12. data/Documentation/unicorn.1.txt +174 -0
  13. data/Documentation/unicorn_rails.1.txt +175 -0
  14. data/FAQ +53 -0
  15. data/GIT-VERSION-GEN +40 -0
  16. data/GNUmakefile +294 -0
  17. data/HACKING +134 -0
  18. data/ISSUES +36 -0
  19. data/KNOWN_ISSUES +79 -0
  20. data/LICENSE +64 -0
  21. data/Links +56 -0
  22. data/PHILOSOPHY +145 -0
  23. data/README +149 -0
  24. data/Rakefile +97 -0
  25. data/SIGNALS +114 -0
  26. data/Sandbox +96 -0
  27. data/TODO +5 -0
  28. data/TUNING +98 -0
  29. data/bin/unicorn +121 -0
  30. data/bin/unicorn_rails +209 -0
  31. data/examples/big_app_gc.rb +2 -0
  32. data/examples/echo.ru +27 -0
  33. data/examples/git.ru +13 -0
  34. data/examples/init.sh +74 -0
  35. data/examples/logger_mp_safe.rb +25 -0
  36. data/examples/logrotate.conf +29 -0
  37. data/examples/nginx.conf +156 -0
  38. data/examples/unicorn.conf.minimal.rb +13 -0
  39. data/examples/unicorn.conf.rb +94 -0
  40. data/ext/unicorn_http/CFLAGS +13 -0
  41. data/ext/unicorn_http/c_util.h +124 -0
  42. data/ext/unicorn_http/common_field_optimization.h +111 -0
  43. data/ext/unicorn_http/ext_help.h +86 -0
  44. data/ext/unicorn_http/extconf.rb +10 -0
  45. data/ext/unicorn_http/global_variables.h +97 -0
  46. data/ext/unicorn_http/httpdate.c +82 -0
  47. data/ext/unicorn_http/unicorn_http.rl +1036 -0
  48. data/ext/unicorn_http/unicorn_http_common.rl +76 -0
  49. data/lib/unicorn.rb +107 -0
  50. data/lib/unicorn/app/exec_cgi.rb +154 -0
  51. data/lib/unicorn/app/inetd.rb +109 -0
  52. data/lib/unicorn/app/old_rails.rb +35 -0
  53. data/lib/unicorn/app/old_rails/static.rb +59 -0
  54. data/lib/unicorn/cgi_wrapper.rb +147 -0
  55. data/lib/unicorn/configurator.rb +630 -0
  56. data/lib/unicorn/const.rb +40 -0
  57. data/lib/unicorn/http_request.rb +77 -0
  58. data/lib/unicorn/http_response.rb +45 -0
  59. data/lib/unicorn/http_server.rb +755 -0
  60. data/lib/unicorn/launcher.rb +62 -0
  61. data/lib/unicorn/oob_gc.rb +71 -0
  62. data/lib/unicorn/preread_input.rb +33 -0
  63. data/lib/unicorn/socket_helper.rb +208 -0
  64. data/lib/unicorn/ssl_client.rb +11 -0
  65. data/lib/unicorn/ssl_configurator.rb +104 -0
  66. data/lib/unicorn/ssl_server.rb +42 -0
  67. data/lib/unicorn/stream_input.rb +149 -0
  68. data/lib/unicorn/tee_input.rb +126 -0
  69. data/lib/unicorn/tmpio.rb +29 -0
  70. data/lib/unicorn/util.rb +68 -0
  71. data/lib/unicorn/worker.rb +88 -0
  72. data/local.mk.sample +59 -0
  73. data/script/isolate_for_tests +50 -0
  74. data/setup.rb +1586 -0
  75. data/t/.gitignore +5 -0
  76. data/t/GNUmakefile +82 -0
  77. data/t/README +42 -0
  78. data/t/bin/content-md5-put +36 -0
  79. data/t/bin/sha1sum.rb +17 -0
  80. data/t/bin/unused_listen +40 -0
  81. data/t/bin/utee +12 -0
  82. data/t/broken-app.ru +12 -0
  83. data/t/detach.ru +11 -0
  84. data/t/env.ru +3 -0
  85. data/t/heartbeat-timeout.ru +12 -0
  86. data/t/listener_names.ru +4 -0
  87. data/t/my-tap-lib.sh +201 -0
  88. data/t/oob_gc.ru +21 -0
  89. data/t/oob_gc_path.ru +21 -0
  90. data/t/pid.ru +3 -0
  91. data/t/preread_input.ru +17 -0
  92. data/t/rack-input-tests.ru +21 -0
  93. data/t/rails3-app/.gitignore +4 -0
  94. data/t/rails3-app/Gemfile +26 -0
  95. data/t/rails3-app/Rakefile +10 -0
  96. data/t/rails3-app/app/controllers/application_controller.rb +4 -0
  97. data/t/rails3-app/app/helpers/application_helper.rb +2 -0
  98. data/t/rails3-app/app/views/layouts/application.html.erb +14 -0
  99. data/t/rails3-app/config.ru +4 -0
  100. data/t/rails3-app/config/application.rb +46 -0
  101. data/t/rails3-app/config/boot.rb +6 -0
  102. data/t/rails3-app/config/database.yml +22 -0
  103. data/t/rails3-app/config/environment.rb +5 -0
  104. data/t/rails3-app/config/environments/development.rb +19 -0
  105. data/t/rails3-app/config/environments/production.rb +42 -0
  106. data/t/rails3-app/config/environments/test.rb +32 -0
  107. data/t/rails3-app/config/initializers/backtrace_silencers.rb +7 -0
  108. data/t/rails3-app/config/initializers/inflections.rb +10 -0
  109. data/t/rails3-app/config/initializers/mime_types.rb +5 -0
  110. data/t/rails3-app/config/initializers/secret_token.rb +7 -0
  111. data/t/rails3-app/config/initializers/session_store.rb +8 -0
  112. data/t/rails3-app/config/locales/en.yml +5 -0
  113. data/t/rails3-app/config/routes.rb +58 -0
  114. data/t/rails3-app/db/seeds.rb +7 -0
  115. data/t/rails3-app/doc/README_FOR_APP +2 -0
  116. data/t/rails3-app/lib/tasks/.gitkeep +0 -0
  117. data/t/rails3-app/public/404.html +1 -0
  118. data/t/rails3-app/public/500.html +1 -0
  119. data/t/rails3-app/public/x.txt +1 -0
  120. data/t/rails3-app/script/rails +9 -0
  121. data/t/rails3-app/test/performance/browsing_test.rb +9 -0
  122. data/t/rails3-app/test/test_helper.rb +13 -0
  123. data/t/rails3-app/vendor/plugins/.gitkeep +0 -0
  124. data/t/sslgen.sh +71 -0
  125. data/t/t0000-http-basic.sh +50 -0
  126. data/t/t0001-reload-bad-config.sh +53 -0
  127. data/t/t0002-config-conflict.sh +49 -0
  128. data/t/t0002-parser-error.sh +94 -0
  129. data/t/t0003-working_directory.sh +51 -0
  130. data/t/t0004-heartbeat-timeout.sh +69 -0
  131. data/t/t0004-working_directory_broken.sh +24 -0
  132. data/t/t0005-working_directory_app.rb.sh +37 -0
  133. data/t/t0006-reopen-logs.sh +83 -0
  134. data/t/t0006.ru +13 -0
  135. data/t/t0007-working_directory_no_embed_cli.sh +44 -0
  136. data/t/t0008-back_out_of_upgrade.sh +110 -0
  137. data/t/t0009-broken-app.sh +56 -0
  138. data/t/t0009-winch_ttin.sh +59 -0
  139. data/t/t0010-reap-logging.sh +55 -0
  140. data/t/t0011-active-unix-socket.sh +79 -0
  141. data/t/t0012-reload-empty-config.sh +85 -0
  142. data/t/t0013-rewindable-input-false.sh +24 -0
  143. data/t/t0013.ru +12 -0
  144. data/t/t0014-rewindable-input-true.sh +24 -0
  145. data/t/t0014.ru +12 -0
  146. data/t/t0015-configurator-internals.sh +25 -0
  147. data/t/t0016-trust-x-forwarded-false.sh +30 -0
  148. data/t/t0017-trust-x-forwarded-true.sh +30 -0
  149. data/t/t0018-write-on-close.sh +23 -0
  150. data/t/t0019-max_header_len.sh +49 -0
  151. data/t/t0020-at_exit-handler.sh +49 -0
  152. data/t/t0021-process_detach.sh +29 -0
  153. data/t/t0022-listener-names-preload_app.sh +32 -0
  154. data/t/t0100-rack-input-tests.sh +124 -0
  155. data/t/t0116-client_body_buffer_size.sh +80 -0
  156. data/t/t0116.ru +16 -0
  157. data/t/t0300-rails3-basic.sh +28 -0
  158. data/t/t0301-rails3-missing-config-ru.sh +33 -0
  159. data/t/t0302-rails3-alt-working_directory.sh +32 -0
  160. data/t/t0303-rails3-alt-working_directory_config.ru.sh +56 -0
  161. data/t/t0304-rails3-alt-working_directory_no_embed_cli.sh +52 -0
  162. data/t/t0600-https-server-basic.sh +48 -0
  163. data/t/t9000-preread-input.sh +48 -0
  164. data/t/t9001-oob_gc.sh +47 -0
  165. data/t/t9002-oob_gc-path.sh +75 -0
  166. data/t/test-lib.sh +113 -0
  167. data/t/test-rails3.sh +27 -0
  168. data/t/write-on-close.ru +11 -0
  169. data/test/aggregate.rb +15 -0
  170. data/test/benchmark/README +50 -0
  171. data/test/benchmark/dd.ru +18 -0
  172. data/test/benchmark/stack.ru +8 -0
  173. data/test/exec/README +5 -0
  174. data/test/exec/test_exec.rb +1055 -0
  175. data/test/rails/app-1.2.3/.gitignore +2 -0
  176. data/test/rails/app-1.2.3/Rakefile +7 -0
  177. data/test/rails/app-1.2.3/app/controllers/application.rb +6 -0
  178. data/test/rails/app-1.2.3/app/controllers/foo_controller.rb +36 -0
  179. data/test/rails/app-1.2.3/app/helpers/application_helper.rb +4 -0
  180. data/test/rails/app-1.2.3/config/boot.rb +11 -0
  181. data/test/rails/app-1.2.3/config/database.yml +12 -0
  182. data/test/rails/app-1.2.3/config/environment.rb +13 -0
  183. data/test/rails/app-1.2.3/config/environments/development.rb +9 -0
  184. data/test/rails/app-1.2.3/config/environments/production.rb +5 -0
  185. data/test/rails/app-1.2.3/config/routes.rb +6 -0
  186. data/test/rails/app-1.2.3/db/.gitignore +0 -0
  187. data/test/rails/app-1.2.3/public/404.html +1 -0
  188. data/test/rails/app-1.2.3/public/500.html +1 -0
  189. data/test/rails/app-2.0.2/.gitignore +2 -0
  190. data/test/rails/app-2.0.2/Rakefile +7 -0
  191. data/test/rails/app-2.0.2/app/controllers/application.rb +4 -0
  192. data/test/rails/app-2.0.2/app/controllers/foo_controller.rb +36 -0
  193. data/test/rails/app-2.0.2/app/helpers/application_helper.rb +4 -0
  194. data/test/rails/app-2.0.2/config/boot.rb +11 -0
  195. data/test/rails/app-2.0.2/config/database.yml +12 -0
  196. data/test/rails/app-2.0.2/config/environment.rb +17 -0
  197. data/test/rails/app-2.0.2/config/environments/development.rb +8 -0
  198. data/test/rails/app-2.0.2/config/environments/production.rb +5 -0
  199. data/test/rails/app-2.0.2/config/routes.rb +6 -0
  200. data/test/rails/app-2.0.2/db/.gitignore +0 -0
  201. data/test/rails/app-2.0.2/public/404.html +1 -0
  202. data/test/rails/app-2.0.2/public/500.html +1 -0
  203. data/test/rails/app-2.1.2/.gitignore +2 -0
  204. data/test/rails/app-2.1.2/Rakefile +7 -0
  205. data/test/rails/app-2.1.2/app/controllers/application.rb +4 -0
  206. data/test/rails/app-2.1.2/app/controllers/foo_controller.rb +36 -0
  207. data/test/rails/app-2.1.2/app/helpers/application_helper.rb +4 -0
  208. data/test/rails/app-2.1.2/config/boot.rb +111 -0
  209. data/test/rails/app-2.1.2/config/database.yml +12 -0
  210. data/test/rails/app-2.1.2/config/environment.rb +17 -0
  211. data/test/rails/app-2.1.2/config/environments/development.rb +7 -0
  212. data/test/rails/app-2.1.2/config/environments/production.rb +5 -0
  213. data/test/rails/app-2.1.2/config/routes.rb +6 -0
  214. data/test/rails/app-2.1.2/db/.gitignore +0 -0
  215. data/test/rails/app-2.1.2/public/404.html +1 -0
  216. data/test/rails/app-2.1.2/public/500.html +1 -0
  217. data/test/rails/app-2.2.2/.gitignore +2 -0
  218. data/test/rails/app-2.2.2/Rakefile +7 -0
  219. data/test/rails/app-2.2.2/app/controllers/application.rb +4 -0
  220. data/test/rails/app-2.2.2/app/controllers/foo_controller.rb +36 -0
  221. data/test/rails/app-2.2.2/app/helpers/application_helper.rb +4 -0
  222. data/test/rails/app-2.2.2/config/boot.rb +111 -0
  223. data/test/rails/app-2.2.2/config/database.yml +12 -0
  224. data/test/rails/app-2.2.2/config/environment.rb +17 -0
  225. data/test/rails/app-2.2.2/config/environments/development.rb +7 -0
  226. data/test/rails/app-2.2.2/config/environments/production.rb +5 -0
  227. data/test/rails/app-2.2.2/config/routes.rb +6 -0
  228. data/test/rails/app-2.2.2/db/.gitignore +0 -0
  229. data/test/rails/app-2.2.2/public/404.html +1 -0
  230. data/test/rails/app-2.2.2/public/500.html +1 -0
  231. data/test/rails/test_rails.rb +287 -0
  232. data/test/test_helper.rb +300 -0
  233. data/test/unit/test_configurator.rb +158 -0
  234. data/test/unit/test_droplet.rb +28 -0
  235. data/test/unit/test_http_parser.rb +860 -0
  236. data/test/unit/test_http_parser_ng.rb +716 -0
  237. data/test/unit/test_http_parser_xftrust.rb +38 -0
  238. data/test/unit/test_request.rb +197 -0
  239. data/test/unit/test_response.rb +99 -0
  240. data/test/unit/test_server.rb +289 -0
  241. data/test/unit/test_signals.rb +207 -0
  242. data/test/unit/test_sni_hostnames.rb +47 -0
  243. data/test/unit/test_socket_helper.rb +192 -0
  244. data/test/unit/test_stream_input.rb +204 -0
  245. data/test/unit/test_tee_input.rb +296 -0
  246. data/test/unit/test_upload.rb +306 -0
  247. data/test/unit/test_util.rb +100 -0
  248. data/unicorn-lb-patch.gemspec +27 -0
  249. metadata +561 -0
@@ -0,0 +1,29 @@
1
+ #!/bin/sh
2
+ . ./test-lib.sh
3
+
4
+ t_plan 5 "Process.detach on forked background process works"
5
+
6
+ t_begin "setup and startup" && {
7
+ t_fifos process_detach
8
+ unicorn_setup
9
+ TEST_FIFO=$process_detach \
10
+ unicorn -E none -D detach.ru -c $unicorn_config
11
+ unicorn_wait_start
12
+ }
13
+
14
+ t_begin "read detached PID with HTTP/1.0" && {
15
+ detached_pid=$(curl -0 -sSf http://$listen/)
16
+ t_info "detached_pid=$detached_pid"
17
+ }
18
+
19
+ t_begin "read background FIFO" && {
20
+ test xHIHI = x"$(cat $process_detach)"
21
+ }
22
+
23
+ t_begin "killing succeeds" && {
24
+ kill $unicorn_pid
25
+ }
26
+
27
+ t_begin "check stderr" && check_stderr
28
+
29
+ t_done
@@ -0,0 +1,32 @@
1
+ #!/bin/sh
2
+ . ./test-lib.sh
3
+
4
+ # Raindrops::Middleware depends on Unicorn.listener_names,
5
+ # ensure we don't break Raindrops::Middleware when preload_app is true
6
+
7
+ t_plan 4 "Unicorn.listener_names available with preload_app=true"
8
+
9
+ t_begin "setup and startup" && {
10
+ unicorn_setup
11
+ echo preload_app true >> $unicorn_config
12
+ unicorn -E none -D listener_names.ru -c $unicorn_config
13
+ unicorn_wait_start
14
+ }
15
+
16
+ t_begin "read listener names includes listener" && {
17
+ resp=$(curl -sSf http://$listen/)
18
+ ok=false
19
+ t_info "resp=$resp"
20
+ case $resp in
21
+ *\"$listen\"*) ok=true ;;
22
+ esac
23
+ $ok
24
+ }
25
+
26
+ t_begin "killing succeeds" && {
27
+ kill $unicorn_pid
28
+ }
29
+
30
+ t_begin "check stderr" && check_stderr
31
+
32
+ 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=$(wc -c < 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 |wc -l)
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 |wc -l)
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 |wc -l)
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 |wc -l)
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 |wc -l)
85
+ test 1 -eq $(grep $blob_sha1 $tmp |wc -l)
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 |wc -l)
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,28 @@
1
+ #!/bin/sh
2
+ . ./test-rails3.sh
3
+
4
+ t_plan 3 "Rails 3 (beta) tests"
5
+
6
+ t_begin "setup and start" && {
7
+ rails3_app=$(cd rails3-app && pwd)
8
+ rm -rf $t_pfx.app
9
+ mkdir $t_pfx.app
10
+ cd $t_pfx.app
11
+ ( cd $rails3_app && tar cf - . ) | tar xf -
12
+ $RAKE db:sessions:create
13
+ $RAKE db:migrate
14
+ unicorn_setup
15
+ unicorn_rails -D -c $unicorn_config
16
+ unicorn_wait_start
17
+ }
18
+
19
+ # add more tests here
20
+ t_begin "hit with curl" && {
21
+ test xHELLO = x"$(curl -sSf http://$listen/x.txt)"
22
+ }
23
+
24
+ t_begin "killing succeeds" && {
25
+ kill $unicorn_pid
26
+ }
27
+
28
+ t_done
@@ -0,0 +1,33 @@
1
+ #!/bin/sh
2
+ . ./test-rails3.sh
3
+
4
+ t_plan 4 "Rails 3 (beta) tests for config.ru haters"
5
+
6
+ t_begin "setup and start" && {
7
+ rails3_app=$(cd rails3-app && pwd)
8
+ rm -rf $t_pfx.app
9
+ mkdir $t_pfx.app
10
+ cd $t_pfx.app
11
+ ( cd $rails3_app && tar cf - . ) | tar xf -
12
+ rm config.ru
13
+ $RAKE db:sessions:create
14
+ $RAKE db:migrate
15
+ unicorn_setup
16
+ unicorn_rails -D -c $unicorn_config
17
+ unicorn_wait_start
18
+ }
19
+
20
+ t_begin "static file serving works" && {
21
+ test x"$(curl -sSf http://$listen/x.txt)" = xHELLO
22
+ }
23
+
24
+ # add more tests here
25
+ t_begin "hit with curl" && {
26
+ curl -v http://$listen/ || :
27
+ }
28
+
29
+ t_begin "killing succeeds" && {
30
+ kill $unicorn_pid
31
+ }
32
+
33
+ t_done
@@ -0,0 +1,32 @@
1
+ #!/bin/sh
2
+ . ./test-rails3.sh
3
+
4
+ t_plan 3 "Rails 3 (beta) inside alt working_directory (no config.ru)"
5
+
6
+ t_begin "setup and start" && {
7
+ unicorn_setup
8
+ rails3_app=$(cd rails3-app && pwd)
9
+ rm -rf $t_pfx.app
10
+ mkdir $t_pfx.app
11
+ cd $t_pfx.app
12
+ ( cd $rails3_app && tar cf - . ) | tar xf -
13
+ rm config.ru
14
+ $RAKE db:sessions:create
15
+ $RAKE db:migrate
16
+ unicorn_setup
17
+ rm $pid
18
+ echo "working_directory '$t_pfx.app'" >> $unicorn_config
19
+ cd /
20
+ unicorn_rails -D -c $unicorn_config
21
+ unicorn_wait_start
22
+ }
23
+
24
+ t_begin "static file serving works" && {
25
+ test x"$(curl -sSf http://$listen/x.txt)" = xHELLO
26
+ }
27
+
28
+ t_begin "killing succeeds" && {
29
+ kill $unicorn_pid
30
+ }
31
+
32
+ t_done
@@ -0,0 +1,56 @@
1
+ #!/bin/sh
2
+ . ./test-rails3.sh
3
+
4
+ t_plan 5 "Rails 3 (beta) inside alt working_directory (w/ config.ru)"
5
+
6
+ t_begin "setup and start" && {
7
+ unicorn_setup
8
+ rtmpfiles unicorn_config_tmp usocket
9
+ if test -e $usocket
10
+ then
11
+ die "unexpected $usocket"
12
+ fi
13
+ rails3_app=$(cd rails3-app && pwd)
14
+ rm -rf $t_pfx.app
15
+ mkdir $t_pfx.app
16
+ cd $t_pfx.app
17
+ ( cd $rails3_app && tar cf - . ) | tar xf -
18
+ $RAKE db:sessions:create
19
+ $RAKE db:migrate
20
+ unicorn_setup
21
+ rm $pid
22
+
23
+ echo "#\\--daemonize --host $host --port $port -l $usocket" \
24
+ >> $t_pfx.app/config.ru
25
+
26
+ # we have --host/--port in config.ru instead
27
+ grep -v ^listen $unicorn_config |
28
+ grep -v ^pid > $unicorn_config_tmp
29
+ echo "working_directory '$t_pfx.app'" >> $unicorn_config_tmp
30
+ cd /
31
+ unicorn_rails -c $unicorn_config_tmp
32
+ }
33
+
34
+ t_begin "pids in the right place" && {
35
+ if test -e $pid
36
+ then
37
+ die "pid=$pid not expected"
38
+ fi
39
+
40
+ unicorn_rails_pid="$t_pfx.app/tmp/pids/unicorn.pid"
41
+ unicorn_pid=$(cat $unicorn_rails_pid)
42
+ }
43
+
44
+ t_begin "static file serving works" && {
45
+ test x"$(curl -sSf http://$listen/x.txt)" = xHELLO
46
+ }
47
+
48
+ t_begin "socket created" && {
49
+ test -S $usocket
50
+ }
51
+
52
+ t_begin "killing succeeds" && {
53
+ kill $unicorn_pid
54
+ }
55
+
56
+ t_done
@@ -0,0 +1,52 @@
1
+ #!/bin/sh
2
+ . ./test-rails3.sh
3
+
4
+ t_plan 5 "Rails 3 (beta) inside alt working_directory (no embedded switches)"
5
+
6
+ t_begin "setup and start" && {
7
+ unicorn_setup
8
+ rtmpfiles unicorn_config_tmp usocket
9
+ if test -e $usocket
10
+ then
11
+ die "unexpected $usocket"
12
+ fi
13
+ rails3_app=$(cd rails3-app && pwd)
14
+ rm -rf $t_pfx.app
15
+ mkdir $t_pfx.app
16
+ cd $t_pfx.app
17
+ ( cd $rails3_app && tar cf - . ) | tar xf -
18
+ $RAKE db:sessions:create
19
+ $RAKE db:migrate
20
+ unicorn_setup
21
+ rm $pid
22
+
23
+ grep -v ^pid $unicorn_config > $unicorn_config_tmp
24
+ echo "working_directory '$t_pfx.app'" >> $unicorn_config_tmp
25
+ cd /
26
+ unicorn_rails -c $unicorn_config_tmp \
27
+ --daemonize --host $host --port $port -l $usocket
28
+ }
29
+
30
+ t_begin "pids in the right place" && {
31
+ if test -e $pid
32
+ then
33
+ die "pid=$pid not expected"
34
+ fi
35
+
36
+ unicorn_rails_pid="$t_pfx.app/tmp/pids/unicorn.pid"
37
+ unicorn_pid=$(cat $unicorn_rails_pid)
38
+ }
39
+
40
+ t_begin "static file serving works" && {
41
+ test x"$(curl -sSf http://$listen/x.txt)" = xHELLO
42
+ }
43
+
44
+ t_begin "socket created" && {
45
+ test -S $usocket
46
+ }
47
+
48
+ t_begin "killing succeeds" && {
49
+ kill $unicorn_pid
50
+ }
51
+
52
+ t_done