rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob cb3f8c1f3f94eeb1c03149ff1eb764dea2bb1f29 877 bytes (raw)
$ git show v0.3.0:t/lib-rack-input-hammer.sh	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
nr_client=${nr_client-4}
. ./test-lib.sh
test -r random_blob || die "random_blob required, run with 'make $0'"

eval $(unused_listen)
rtmpfiles unicorn_config curl_out curl_err r_err r_out pid

cat > $unicorn_config <<EOF
listen "$listen"
pid "$pid"
stderr_path "$r_err"
stdout_path "$r_out"
Rainbows! do
  use :$model
end
EOF

rainbows -D sha1.ru -c $unicorn_config
wait_for_pid $pid

start=$(date +%s)
for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" </dev/null)
do
	(
		curl -sSf -T- http://$listen/$i \
		  < random_blob >> $curl_out 2>> $curl_err
	) &
done
wait
echo elapsed=$(( $(date +%s) - $start ))

kill $(cat $pid)
test $nr_client -eq $(wc -l < $curl_out)
test 1 -eq $(sort < $curl_out | uniq | wc -l)
blob_sha1=$( expr "$(sha1sum < random_blob)" : '\([a-f0-9]\+\)')
echo blob_sha1=$blob_sha1
test x"$blob_sha1" = x"$(sort < $curl_out | uniq)"
check_stderr

git clone https://yhbt.net/rainbows.git