about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-06-28 08:06:32 +0000
committerEric Wong <normalperson@yhbt.net>2010-06-28 08:57:26 +0000
commit8175a52c67fb9dfc9c04a7b0597b680699f43deb (patch)
tree9c50e69b27c271929082aad63d0f1f7e9a4d28fa /t
parent86e9c7013308d77def5fe41b52a35dea60c7361c (diff)
downloadrainbows-8175a52c67fb9dfc9c04a7b0597b680699f43deb.tar.gz
This still needs work and lots of cleanup, but the basics are
there.  The sendfile 1.0.0 RubyGem is now safe to use under MRI
1.8, and is superior to current (1.9.2-preview3) versions of
IO.copy_stream for static files in that it supports more
platforms and doesn't truncate large files on 32-bit platforms.
Diffstat (limited to 't')
-rwxr-xr-xt/t0020-large-sendfile-response.sh72
-rw-r--r--t/test_isolate.rb2
2 files changed, 74 insertions, 0 deletions
diff --git a/t/t0020-large-sendfile-response.sh b/t/t0020-large-sendfile-response.sh
new file mode 100755
index 0000000..822a23f
--- /dev/null
+++ b/t/t0020-large-sendfile-response.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+. ./test-lib.sh
+test -r random_blob || die "random_blob required, run with 'make $0'"
+case $RUBY_ENGINE in
+ruby) ;;
+*)
+        t_info "skipping $T since it can't load the sendfile gem, yet"
+        exit 0
+        ;;
+esac
+
+t_plan 7 "large sendfile response for $model"
+
+t_begin "setup and startup" && {
+        rtmpfiles curl_out a b c
+        rainbows_setup $model 2
+
+        # FIXME: allow "require 'sendfile'" to work in $unicorn_config
+        RUBYOPT="-rsendfile"
+        export RUBYOPT
+
+        # can't load Rack::Lint here since it clobbers body#to_path
+        rainbows -E none -D large-file-response.ru -c $unicorn_config
+        rainbows_wait_start
+}
+
+t_begin "read random blob sha1" && {
+        random_blob_sha1=$(rsha1 < random_blob)
+}
+
+t_begin "send a series of HTTP/1.1 requests in parallel" && {
+        for i in $a $b $c
+        do
+                (
+                        curl -sSf http://$listen/random_blob | rsha1 > $i
+                ) &
+        done
+        wait
+        for i in $a $b $c
+        do
+                test x$(cat $i) = x$random_blob_sha1
+        done
+}
+
+# this was a problem during development
+t_begin "HTTP/1.0 test" && {
+        sha1=$( (curl -0 -sSfv http://$listen/random_blob &&
+                 echo ok >$ok) | rsha1)
+        test $sha1 = $random_blob_sha1
+        test xok = x$(cat $ok)
+}
+
+t_begin "HTTP/0.9 test" && {
+        (
+                printf 'GET /random_blob\r\n'
+                rsha1 < $fifo > $tmp &
+                wait
+                echo ok > $ok
+        ) | socat - TCP:$listen > $fifo
+        test $(cat $tmp) = $random_blob_sha1
+        test xok = x$(cat $ok)
+}
+
+t_begin "shutdown server" && {
+        kill -QUIT $rainbows_pid
+}
+
+dbgcat r_err
+
+t_begin "check stderr" && check_stderr
+
+t_done
diff --git a/t/test_isolate.rb b/t/test_isolate.rb
index 00d57bf..1b6c46d 100644
--- a/t/test_isolate.rb
+++ b/t/test_isolate.rb
@@ -18,6 +18,8 @@ Isolate.now!(opts) do
   gem 'unicorn', '1.0.0'
 
   if engine == "ruby"
+    gem 'sendfile', '1.0.0' # next Rubinius should support this
+
     gem 'iobuffer', '0.1.3'
     gem 'rev', '0.3.2'