support for Rack hijack in request and response
[unicorn.git] / t / t0116-client_body_buffer_size.sh
blobc9e17c75544b3a4dad474fa4d87b7849601f35ae
1 #!/bin/sh
2 . ./test-lib.sh
3 t_plan 12 "client_body_buffer_size settings"
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
21 test x"$(cat $fifo)" = xSTART
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)"
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)"
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
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)"
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"
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"
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
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"
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"
72 t_begin "killing succeeds" && {
73 kill $unicorn_pid
76 t_begin "check stderr" && {
77 check_stderr
80 t_done