local.mk.sample: add a hint for TMPDIR
[rainbows.git] / t / t0100-rack-input-hammer-content-length.sh
blob181954ee58d35ccb27cfccc90ddce0d63e89e24c
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 (content-length)"
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=$(date +%s)
21 for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" </dev/null)
24 curl -sSf -T random_blob http://$listen/$i \
25 >> $curl_out 2>> $curl_err
26 ) &
27 done
28 wait
29 t_info elapsed=$(( $(date +%s) - $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