unicorn.git  about / heads / tags
Rack HTTP server for Unix and fast clients
blob c9e17c75544b3a4dad474fa4d87b7849601f35ae 2078 bytes (raw)
$ git show no-kgio-wip:t/t0116-client_body_buffer_size.sh	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
 
#!/bin/sh
. ./test-lib.sh
t_plan 12 "client_body_buffer_size settings"

t_begin "setup and start" && {
	unicorn_setup
	rtmpfiles unicorn_config_tmp one_meg
	dd if=/dev/zero bs=1M count=1 of=$one_meg
	cat >> $unicorn_config <<EOF
after_fork do |server, worker|
  File.open("$fifo", "wb") { |fp| fp.syswrite "START" }
end
EOF
	cat $unicorn_config > $unicorn_config_tmp
	echo client_body_buffer_size 0 >> $unicorn_config
	unicorn -D -c $unicorn_config t0116.ru
	unicorn_wait_start
	fs_class=Unicorn::TmpIO
	mem_class=StringIO

	test x"$(cat $fifo)" = xSTART
}

t_begin "class for a zero-byte file should be StringIO" && {
	> $tmp
	test xStringIO = x"$(curl -T $tmp -sSf http://$listen/input_class)"
}

t_begin "class for a 1 byte file should be filesystem-backed" && {
	echo > $tmp
	test x$fs_class = x"$(curl -T $tmp -sSf http://$listen/tmp_class)"
}

t_begin "reload with default client_body_buffer_size" && {
	mv $unicorn_config_tmp $unicorn_config
	kill -HUP $unicorn_pid
	test x"$(cat $fifo)" = xSTART
}

t_begin "class for a 1 byte file should be memory-backed" && {
	echo > $tmp
	test x$mem_class = x"$(curl -T $tmp -sSf http://$listen/tmp_class)"
}

t_begin "class for a random blob file should be filesystem-backed" && {
	resp="$(curl -T random_blob -sSf http://$listen/tmp_class)"
	test x$fs_class = x"$resp"
}

t_begin "one megabyte file should be filesystem-backed" && {
	resp="$(curl -T $one_meg -sSf http://$listen/tmp_class)"
	test x$fs_class = x"$resp"
}

t_begin "reload with a big client_body_buffer_size" && {
	echo "client_body_buffer_size(1024 * 1024)" >> $unicorn_config
	kill -HUP $unicorn_pid
	test x"$(cat $fifo)" = xSTART
}

t_begin "one megabyte file should be memory-backed" && {
	resp="$(curl -T $one_meg -sSf http://$listen/tmp_class)"
	test x$mem_class = x"$resp"
}

t_begin "one megabyte + 1 byte file should be filesystem-backed" && {
	echo >> $one_meg
	resp="$(curl -T $one_meg -sSf http://$listen/tmp_class)"
	test x$fs_class = x"$resp"
}

t_begin "killing succeeds" && {
	kill $unicorn_pid
}

t_begin "check stderr" && {
	check_stderr
}

t_done

git clone https://yhbt.net/unicorn.git