3 test -r random_blob || die
"random_blob required, run with 'make $0'"
5 if ! grep -v ^VmRSS
: /proc
/self
/status
>/dev
/null
2>&1
7 t_info
"skipping, can't read RSS from /proc/self/status"
11 t_plan
10 "large file response slurp avoidance for $model"
13 t_begin
"setup and startup" && {
15 rainbows_setup
$model 1
16 # can't load Rack::Lint here since it'll cause Rev to slurp
17 rainbows
-E none
-D large-file-response.ru
-c $unicorn_config
21 t_begin
"read random blob sha1 and size" && {
22 random_blob_sha1
=$
(rsha1
< random_blob
)
23 random_blob_size
=$
(wc -c < random_blob
)
26 t_begin
"read current RSS" && {
27 curl
-v http
://$listen/rss
29 rss_before
=$
(curl
-sSfv http
://$listen/rss
)
30 t_info
"rss_before=$rss_before"
33 t_begin
"send a series HTTP/1.1 requests sequentially" && {
36 sha1
=$
( (curl
-sSfv http
://$listen/random_blob
&&
37 echo ok
>$ok) | rsha1
)
38 test $sha1 = $random_blob_sha1
39 test xok
= x$
(cat $ok)
43 # this was a problem during development
44 t_begin
"HTTP/1.0 test" && {
45 sha1
=$
( (curl
-0 -sSfv http
://$listen/random_blob
&&
46 echo ok
>$ok) | rsha1
)
47 test $sha1 = $random_blob_sha1
48 test xok
= x$
(cat $ok)
51 t_begin
"HTTP/0.9 test" && {
53 printf 'GET /random_blob\r\n'
54 rsha1
< $fifo > $tmp &
57 ) | socat
- TCP
:$listen > $fifo
58 test $
(cat $tmp) = $random_blob_sha1
59 test xok
= x$
(cat $ok)
64 t_begin
"read RSS again" && {
65 curl
-v http
://$listen/rss
66 rss_after
=$
(curl
-sSfv http
://$listen/rss
)
67 t_info
"rss_after=$rss_after"
70 t_begin
"shutdown server" && {
71 kill -QUIT $rainbows_pid
74 t_begin
"compare RSS before and after" && {
75 diff=$
(( $rss_after - $rss_before ))
77 # default GC malloc limit in MRI:
78 fudge
=$
(( 8 * 1024 * 1024 ))
80 t_info
"test diff=$diff < orig=$random_blob_size"
81 test $diff -le $
(( $random_blob_size + $fudge ))
86 t_begin
"check stderr" && check_stderr