3 skip_models StreamResponseEpoll
4 test -r random_blob || die
"random_blob required, run with 'make $0'"
6 if ! grep -v ^VmRSS
: /proc
/self
/status
>/dev
/null
2>&1
8 t_info
"skipping, can't read RSS from /proc/self/status"
12 t_plan
10 "large file response slurp avoidance for $model"
14 t_begin
"setup and startup" && {
16 rainbows_setup
$model 1
17 # can't load Rack::Lint here since it'll cause Rev to slurp
18 rainbows
-E none
-D large-file-response.ru
-c $unicorn_config
22 t_begin
"read random blob sha1 and size" && {
23 random_blob_sha1
=$
(rsha1
< random_blob
)
24 random_blob_size
=$
(count_bytes
< random_blob
)
27 t_begin
"read current RSS" && {
28 curl
-v http
://$listen/rss
30 rss_before
=$
(curl
-sSfv http
://$listen/rss
)
31 t_info
"rss_before=$rss_before"
34 t_begin
"send a series HTTP/1.1 requests sequentially" && {
37 sha1
=$
( (curl
-sSfv http
://$listen/random_blob
&&
38 echo ok
>$ok) | rsha1
)
39 test $sha1 = $random_blob_sha1
40 test xok
= x$
(cat $ok)
44 # this was a problem during development
45 t_begin
"HTTP/1.0 test" && {
46 sha1
=$
( (curl
-0 -sSfv http
://$listen/random_blob
&&
47 echo ok
>$ok) | rsha1
)
48 test $sha1 = $random_blob_sha1
49 test xok
= x$
(cat $ok)
52 t_begin
"HTTP/0.9 test" && {
54 printf 'GET /random_blob\r\n'
55 rsha1
< $fifo > $tmp &
58 ) | socat
- TCP
:$listen > $fifo
59 test $
(cat $tmp) = $random_blob_sha1
60 test xok
= x$
(cat $ok)
65 t_begin
"read RSS again" && {
66 curl
-v http
://$listen/rss
67 rss_after
=$
(curl
-sSfv http
://$listen/rss
)
68 t_info
"rss_after=$rss_after"
71 t_begin
"shutdown server" && {
72 kill -QUIT $rainbows_pid
75 t_begin
"compare RSS before and after" && {
76 diff=$
(( $rss_after - $rss_before ))
78 # default GC malloc limit in MRI:
79 fudge
=$
(( 8 * 1024 * 1024 ))
81 t_info
"test diff=$diff < orig=$random_blob_size"
82 test $diff -le $
(( $random_blob_size + $fudge ))
87 t_begin
"check stderr" && check_stderr