about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-05-03 01:05:11 +0000
committerEric Wong <normalperson@yhbt.net>2011-05-03 01:05:11 +0000
commita7f5f17ba2047ef7143465f612007ea81871a79e (patch)
treefa93430a846c83dd1c79c41f193e4dd73a08f516 /t
parent01381ab4dfeb032c85e72724df889c7aa381aa32 (diff)
downloadrainbows-a7f5f17ba2047ef7143465f612007ea81871a79e.tar.gz
We're changing our default to 1K buffers to save memory.  This
should reduce memory usage of idle clients and lower pressure on
the MRI GC.  Rails applications using session cookies (the
default) may want to up this to 2K or more.
Diffstat (limited to 't')
-rw-r--r--t/client_header_buffer_size.ru3
-rw-r--r--t/t0042-client_header_buffer_size.sh65
2 files changed, 68 insertions, 0 deletions
diff --git a/t/client_header_buffer_size.ru b/t/client_header_buffer_size.ru
new file mode 100644
index 0000000..0831944
--- /dev/null
+++ b/t/client_header_buffer_size.ru
@@ -0,0 +1,3 @@
+use Rack::ContentLength
+use Rack::ContentType, "text/plain"
+run lambda { |env| [ 200, {}, [ "#{Rainbows.client_header_buffer_size}\n" ] ] }
diff --git a/t/t0042-client_header_buffer_size.sh b/t/t0042-client_header_buffer_size.sh
new file mode 100644
index 0000000..0e19361
--- /dev/null
+++ b/t/t0042-client_header_buffer_size.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+. ./test-lib.sh
+
+t_plan 8 "client_header_buffer_size tests for $model"
+
+t_begin "setup and startup" && {
+        rainbows_setup $model
+}
+
+t_begin "fails with zero buffer size" && {
+        ed -s $unicorn_config <<EOF
+,s/^  client_max_body_size.*/  client_header_buffer_size 0/
+w
+EOF
+        grep "client_header_buffer_size 0" $unicorn_config
+        rainbows -D client_header_buffer_size.ru -c $unicorn_config || \
+                echo err=$? > $ok
+        test x"$(cat $ok)" = "xerr=1"
+}
+
+t_begin "fails with negative value" && {
+        ed -s $unicorn_config <<EOF
+,s/^  client_header_buffer_size.*/  client_header_buffer_size -1/
+w
+EOF
+        grep "client_header_buffer_size -1" $unicorn_config
+        rainbows -D client_header_buffer_size.ru -c $unicorn_config || \
+                echo err=$? > $ok
+        test x"$(cat $ok)" = "xerr=1"
+}
+
+t_begin "fails with negative value" && {
+        ed -s $unicorn_config <<EOF
+,s/^  client_header_buffer_size.*/  client_header_buffer_size -1/
+w
+EOF
+        grep "client_header_buffer_size -1" $unicorn_config
+        rainbows -D client_header_buffer_size.ru -c $unicorn_config || \
+                echo err=$? > $ok
+        test x"$(cat $ok)" = "xerr=1"
+}
+
+t_begin "starts with correct value" && {
+        ed -s $unicorn_config <<EOF
+,s/^  client_header_buffer_size.*/  client_header_buffer_size 16399/
+w
+EOF
+        grep "client_header_buffer_size 16399" $unicorn_config
+        rainbows -D client_header_buffer_size.ru -c $unicorn_config
+        rainbows_wait_start
+}
+
+t_begin "regular TCP request works right" && {
+        test x$(curl -sSfv http://$listen/) = x16399
+}
+
+t_begin "no errors in stderr" && {
+        check_stderr
+}
+
+t_begin "shutdown" && {
+        kill $rainbows_pid
+}
+
+t_done