efc3a9c995bc3cb1df04db03b1574d214bdd1594
[rainbows.git] / t / t0100-rack-input-hammer-chunked.sh
blobefc3a9c995bc3cb1df04db03b1574d214bdd1594
1 nr_client=${nr_client-4}
2 . ./test-lib.sh
3 test -r random_blob || die "random_blob required, run with 'make $0'"
5 # basically we don't trust our own implementation of content-md5-put
6 # nor our Ruby 1.9 knowledge nor proper use of encodings in Ruby.
7 # So we try to use things like curl and sha1sum that are implemented
8 # without the Ruby interpreter to validate our own Ruby internals.
10 t_plan 7 "concurrent rack.input hammer stress test (chunked)"
12 t_begin "setup and startup" && {
13 rtmpfiles curl_out curl_err
14 rainbows_setup $model
15 rainbows -D sha1.ru -c $unicorn_config
16 rainbows_wait_start
19 t_begin "send $nr_client concurrent requests" && {
20 start=$(unix_time)
21 for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" </dev/null)
24 curl -sSf -T- http://$listen/$i \
25 < random_blob >> $curl_out 2>> $curl_err
26 ) &
27 done
28 wait
29 t_info elapsed=$(( $(unix_time) - $start ))
32 t_begin "kill server" && kill $rainbows_pid
34 t_begin "got $nr_client responses" && {
35 test $nr_client -eq $(wc -l < $curl_out)
38 t_begin "all responses identical" && {
39 test 1 -eq $(sort < $curl_out | uniq | wc -l)
42 t_begin "sha1 matches on-disk sha1" && {
43 blob_sha1=$(rsha1 < random_blob)
44 t_info blob_sha1=$blob_sha1
45 test x"$blob_sha1" = x"$(sort < $curl_out | uniq)"
48 t_begin "no errors in stderr log" && check_stderr
50 t_done