From 798f5e3a507c20b4abf03aa8313659d3f632a0fa Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 3 May 2010 15:19:53 -0700 Subject: t0100: rack-input-hammer tests identity encodings, too It turns out we were painfully lacking in tests for HTTP requests where the Content-Length header _is_ set. --- t/t0100-rack-input-hammer-chunked.sh | 50 +++++++++++++++++++++++++++++ t/t0100-rack-input-hammer-content-length.sh | 50 +++++++++++++++++++++++++++++ t/t0100-rack-input-hammer.sh | 50 ----------------------------- 3 files changed, 100 insertions(+), 50 deletions(-) create mode 100755 t/t0100-rack-input-hammer-chunked.sh create mode 100755 t/t0100-rack-input-hammer-content-length.sh delete mode 100755 t/t0100-rack-input-hammer.sh (limited to 't') diff --git a/t/t0100-rack-input-hammer-chunked.sh b/t/t0100-rack-input-hammer-chunked.sh new file mode 100755 index 0000000..42fe68d --- /dev/null +++ b/t/t0100-rack-input-hammer-chunked.sh @@ -0,0 +1,50 @@ +nr_client=${nr_client-4} +. ./test-lib.sh +test -r random_blob || die "random_blob required, run with 'make $0'" + +# basically we don't trust our own implementation of content-md5-put +# nor our Ruby 1.9 knowledge nor proper use of encodings in Ruby. +# So we try to use things like curl and sha1sum that are implemented +# without the Ruby interpreter to validate our own Ruby internals. + +t_plan 7 "concurrent rack.input hammer stress test (chunked)" + +t_begin "setup and startup" && { + rtmpfiles curl_out curl_err + rainbows_setup $model + rainbows -D sha1.ru -c $unicorn_config + rainbows_wait_start +} + +t_begin "send $nr_client concurrent requests" && { + start=$(date +%s) + for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" > $curl_out 2>> $curl_err + ) & + done + wait + t_info elapsed=$(( $(date +%s) - $start )) +} + +t_begin "kill server" && kill $rainbows_pid + +t_begin "got $nr_client responses" && { + test $nr_client -eq $(wc -l < $curl_out) +} + +t_begin "all responses identical" && { + test 1 -eq $(sort < $curl_out | uniq | wc -l) +} + +t_begin "sha1 matches on-disk sha1" && { + blob_sha1=$(rsha1 < random_blob) + t_info blob_sha1=$blob_sha1 + test x"$blob_sha1" = x"$(sort < $curl_out | uniq)" +} + +t_begin "no errors in stderr log" && check_stderr + +t_done diff --git a/t/t0100-rack-input-hammer-content-length.sh b/t/t0100-rack-input-hammer-content-length.sh new file mode 100755 index 0000000..181954e --- /dev/null +++ b/t/t0100-rack-input-hammer-content-length.sh @@ -0,0 +1,50 @@ +nr_client=${nr_client-4} +. ./test-lib.sh +test -r random_blob || die "random_blob required, run with 'make $0'" + +# basically we don't trust our own implementation of content-md5-put +# nor our Ruby 1.9 knowledge nor proper use of encodings in Ruby. +# So we try to use things like curl and sha1sum that are implemented +# without the Ruby interpreter to validate our own Ruby internals. + +t_plan 7 "concurrent rack.input hammer stress test (content-length)" + +t_begin "setup and startup" && { + rtmpfiles curl_out curl_err + rainbows_setup $model + rainbows -D sha1.ru -c $unicorn_config + rainbows_wait_start +} + +t_begin "send $nr_client concurrent requests" && { + start=$(date +%s) + for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" > $curl_out 2>> $curl_err + ) & + done + wait + t_info elapsed=$(( $(date +%s) - $start )) +} + +t_begin "kill server" && kill $rainbows_pid + +t_begin "got $nr_client responses" && { + test $nr_client -eq $(wc -l < $curl_out) +} + +t_begin "all responses identical" && { + test 1 -eq $(sort < $curl_out | uniq | wc -l) +} + +t_begin "sha1 matches on-disk sha1" && { + blob_sha1=$(rsha1 < random_blob) + t_info blob_sha1=$blob_sha1 + test x"$blob_sha1" = x"$(sort < $curl_out | uniq)" +} + +t_begin "no errors in stderr log" && check_stderr + +t_done diff --git a/t/t0100-rack-input-hammer.sh b/t/t0100-rack-input-hammer.sh deleted file mode 100755 index c871913..0000000 --- a/t/t0100-rack-input-hammer.sh +++ /dev/null @@ -1,50 +0,0 @@ -nr_client=${nr_client-4} -. ./test-lib.sh -test -r random_blob || die "random_blob required, run with 'make $0'" - -# basically we don't trust our own implementation of content-md5-put -# nor our Ruby 1.9 knowledge nor proper use of encodings in Ruby. -# So we try to use things like curl and sha1sum that are implemented -# without the Ruby interpreter to validate our own Ruby internals. - -t_plan 7 "concurrent rack.input hammer stress test" - -t_begin "setup and startup" && { - rtmpfiles curl_out curl_err - rainbows_setup $model - rainbows -D sha1.ru -c $unicorn_config - rainbows_wait_start -} - -t_begin "send $nr_client concurrent requests" && { - start=$(date +%s) - for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" > $curl_out 2>> $curl_err - ) & - done - wait - t_info elapsed=$(( $(date +%s) - $start )) -} - -t_begin "kill server" && kill $rainbows_pid - -t_begin "got $nr_client responses" && { - test $nr_client -eq $(wc -l < $curl_out) -} - -t_begin "all responses identical" && { - test 1 -eq $(sort < $curl_out | uniq | wc -l) -} - -t_begin "sha1 matches on-disk sha1" && { - blob_sha1=$(rsha1 < random_blob) - t_info blob_sha1=$blob_sha1 - test x"$blob_sha1" = x"$(sort < $curl_out | uniq)" -} - -t_begin "no errors in stderr log" && check_stderr - -t_done -- cgit v1.2.3-24-ge0c7