about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-10-17 22:42:56 -0700
committerEric Wong <normalperson@yhbt.net>2009-10-17 22:42:56 -0700
commitb32e9240ec68f2493038c5cfbc9ca6859cca6ad8 (patch)
treec5ebde64b9c25568921a0e094531100ae04504da
parent95417ca711a75612da86a25acd20134efdbc0e67 (diff)
downloadrainbows-b32e9240ec68f2493038c5cfbc9ca6859cca6ad8.tar.gz
Just in case we break something.  Also add staggered
blob test to simulate slow client uploads.
-rwxr-xr-xt/bin/content-md5-put2
-rw-r--r--t/lib-input-trailer.sh69
-rwxr-xr-xt/t1101-thread-pool-input-trailer.sh2
-rwxr-xr-xt/t2101-thread-spawn-input-trailer.sh2
-rwxr-xr-xt/t3101-revactor-rack-input-trailer.sh2
-rwxr-xr-xt/t4101-rev-rack-input-trailer.sh51
6 files changed, 77 insertions, 51 deletions
diff --git a/t/bin/content-md5-put b/t/bin/content-md5-put
index c35c92c..4f02a85 100755
--- a/t/bin/content-md5-put
+++ b/t/bin/content-md5-put
@@ -22,7 +22,7 @@ if ARGV.grep("--no-headers").empty?
 end
 
 digest = Digest::MD5.new
-if buf = $stdin.read(bs)
+if buf = $stdin.readpartial(bs)
   begin
     digest.update(buf)
     $stdout.write("%x\r\n" % [ buf.size ])
diff --git a/t/lib-input-trailer.sh b/t/lib-input-trailer.sh
new file mode 100644
index 0000000..4a946d4
--- /dev/null
+++ b/t/lib-input-trailer.sh
@@ -0,0 +1,69 @@
+model=$1
+. ./test-lib.sh
+test -r random_blob || die "random_blob required, run with 'make $0'"
+echo "input trailer test model=$model"
+require_for_model
+
+eval $(unused_listen)
+rtmpfiles unicorn_config tmp r_err r_out pid fifo ok
+rm -f $fifo
+mkfifo $fifo
+
+cat > $unicorn_config <<EOF
+listen "$listen"
+pid "$pid"
+stderr_path "$r_err"
+stdout_path "$r_out"
+Rainbows! { use :$model }
+EOF
+
+rainbows -D content-md5.ru -c $unicorn_config
+wait_for_pid $pid
+
+echo "small blob"
+(
+        echo hello world | content-md5-put
+        cat $fifo > $tmp &
+        wait
+        echo ok > $ok
+) | socat - TCP:$listen | utee $fifo
+
+fgrep 'HTTP/1.1 200 OK' $tmp
+test xok = x"$(cat $ok)"
+! grep Error $r_err
+
+
+echo "big blob"
+(
+        content-md5-put < random_blob
+        cat $fifo > $tmp &
+        wait
+        echo ok > $ok
+) | socat - TCP:$listen | utee $fifo
+
+fgrep 'HTTP/1.1 200 OK' $tmp
+test xok = x"$(cat $ok)"
+! grep Error $r_err
+
+echo "staggered blob"
+(
+        (
+                dd bs=164 count=1 < random_blob
+                sleep 2
+                dd bs=4545 count=1 < random_blob
+                sleep 2
+                dd bs=1234 count=1 < random_blob
+                echo ok > $ok
+        ) 2>/dev/null | content-md5-put
+        test xok = x"$(cat $ok)"
+        cat $fifo > $tmp &
+        wait
+        echo ok > $ok
+) | socat - TCP:$listen | utee $fifo
+
+fgrep 'HTTP/1.1 200 OK' $tmp
+test xok = x"$(cat $ok)"
+! grep Error $r_err
+
+
+kill $(cat $pid)
diff --git a/t/t1101-thread-pool-input-trailer.sh b/t/t1101-thread-pool-input-trailer.sh
new file mode 100755
index 0000000..ba9ef9d
--- /dev/null
+++ b/t/t1101-thread-pool-input-trailer.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. ./lib-input-trailer.sh ThreadPool
diff --git a/t/t2101-thread-spawn-input-trailer.sh b/t/t2101-thread-spawn-input-trailer.sh
new file mode 100755
index 0000000..6839a22
--- /dev/null
+++ b/t/t2101-thread-spawn-input-trailer.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. ./lib-input-trailer.sh ThreadSpawn
diff --git a/t/t3101-revactor-rack-input-trailer.sh b/t/t3101-revactor-rack-input-trailer.sh
new file mode 100755
index 0000000..1da9820
--- /dev/null
+++ b/t/t3101-revactor-rack-input-trailer.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. ./lib-input-trailer.sh Revactor
diff --git a/t/t4101-rev-rack-input-trailer.sh b/t/t4101-rev-rack-input-trailer.sh
index 9dffc43..d360e53 100755
--- a/t/t4101-rev-rack-input-trailer.sh
+++ b/t/t4101-rev-rack-input-trailer.sh
@@ -1,51 +1,2 @@
 #!/bin/sh
-nr_client=${nr_client-25}
-nr=${nr-50}
-
-. ./test-lib.sh
-require_rev
-test -r random_blob || die "random_blob required, run with 'make $0'"
-
-eval $(unused_listen)
-rtmpfiles unicorn_config tmp r_err r_out pid fifo ok
-rm -f $fifo
-mkfifo $fifo
-
-cat > $unicorn_config <<EOF
-listen "$listen"
-pid "$pid"
-stderr_path "$r_err"
-stdout_path "$r_out"
-Rainbows! do
-  use :Rev
-end
-EOF
-
-rainbows -D content-md5.ru -c $unicorn_config
-wait_for_pid $pid
-
-echo "small blob"
-(
-        echo hello world | content-md5-put
-        cat $fifo > $tmp &
-        wait
-        echo ok > $ok
-) | socat - TCP:$listen | tee $fifo
-
-fgrep 'HTTP/1.1 200 OK' $tmp
-test xok = x"$(cat $ok)"
-! grep Error $r_err
-
-
-echo "big blob"
-(
-        content-md5-put < random_blob
-        cat $fifo > $tmp &
-        wait
-        echo ok > $ok
-) | socat - TCP:$listen | tee $fifo
-
-fgrep 'HTTP/1.1 200 OK' $tmp
-test xok = x"$(cat $ok)"
-! grep Error $r_err
-kill $(cat $pid)
+. ./lib-input-trailer.sh Rev