tests: make timeout tests reliable under 1.9
[rainbows.git] / t / t0100-rack-input-hammer.sh
blob3e543b38af5f595bfe46cab353576f0caf787fb5
1 nr_client=${nr_client-4}
2 . ./test-lib.sh
3 test -r random_blob || die "random_blob required, run with 'make $0'"
5 t_plan 7 "concurrent rack.input hammer stress test"
7 t_begin "setup and startup" && {
8 rtmpfiles curl_out curl_err
9 rainbows_setup $model
10 rainbows -D sha1.ru -c $unicorn_config
11 rainbows_wait_start
14 t_begin "send $nr_client concurrent requests" && {
15 start=$(date +%s)
16 for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" </dev/null)
19 curl -sSf -T- http://$listen/$i \
20 < random_blob >> $curl_out 2>> $curl_err
21 ) &
22 done
23 wait
24 t_info elapsed=$(( $(date +%s) - $start ))
27 t_begin "kill server" && kill $rainbows_pid
29 t_begin "got $nr_client responses" && {
30 test $nr_client -eq $(wc -l < $curl_out)
33 t_begin "all responses identical" && {
34 test 1 -eq $(sort < $curl_out | uniq | wc -l)
37 t_begin "sha1 matches on-disk sha1" && {
38 blob_sha1=$( expr "$(sha1sum < random_blob)" : '\([a-f0-9]\+\)')
39 t_info blob_sha1=$blob_sha1
40 test x"$blob_sha1" = x"$(sort < $curl_out | uniq)"
43 t_begin "no errors in stderr log" && check_stderr
45 t_done