tests: fix issues with non-portable shell constructs
[rainbows.git] / t / t2000-thread-spawn-basic.sh
blob37aa0292949a3b49e370a345253ff7d0dc8cd28f
1 #!/bin/sh
2 . ./test-lib.sh
4 eval $(unused_listen)
5 rtmpfiles unicorn_config curl_out curl_err pid r_err r_out
7 nr_client=30
8 nr_thread=10
10 cat > $unicorn_config <<EOF
11 stderr_path "$r_err"
12 stdout_path "$r_out"
13 listen "$listen"
14 pid "$pid"
15 Rainbows! do
16 use :ThreadSpawn
17 worker_connections $nr_thread
18 end
19 EOF
21 rainbows -D t2000.ru -c $unicorn_config
22 wait_for_pid $pid
24 start=$(date +%s)
25 for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" </dev/null)
27 ( curl -sSf http://$listen/$i >> $curl_out 2>> $curl_err ) &
28 done
29 wait
30 echo elapsed=$(( $(date +%s) - $start ))
32 kill $(cat $pid)
34 ! test -s $curl_err
35 test x"$(wc -l < $curl_out)" = x$nr_client
36 nr=$(sort < $curl_out | uniq | wc -l)
37 test "$nr" -eq $nr_client
38 ! grep Error $r_err