rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob 758da4e4fbba761f53e7a2b029e269059342099c 1185 bytes (raw)
$ git show v0.3.0:t/lib-input-trailer.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 
. ./test-lib.sh
test -r random_blob || die "random_blob required, run with 'make $0'"
echo "input trailer test model=$model"

eval $(unused_listen)
rtmpfiles unicorn_config tmp r_err r_out pid fifo ok

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

rainbows -D content-md5.ru -c $unicorn_config
wait_for_pid $pid

echo "small blob"
(
	echo hello world | content-md5-put
	cat $fifo > $tmp &
	wait
	echo ok > $ok
) | socat - TCP:$listen | utee $fifo

fgrep 'HTTP/1.1 200 OK' $tmp
test xok = x"$(cat $ok)"
check_stderr

echo "big blob"
(
	content-md5-put < random_blob
	cat $fifo > $tmp &
	wait
	echo ok > $ok
) | socat - TCP:$listen | utee $fifo

fgrep 'HTTP/1.1 200 OK' $tmp
test xok = x"$(cat $ok)"
check_stderr

echo "staggered blob"
(
	(
		dd bs=164 count=1 < random_blob
		sleep 2
		dd bs=4545 count=1 < random_blob
		sleep 2
		dd bs=1234 count=1 < random_blob
		echo ok > $ok
	) 2>/dev/null | content-md5-put
	test xok = x"$(cat $ok)"
	cat $fifo > $tmp &
	wait
	echo ok > $ok
) | socat - TCP:$listen | utee $fifo

fgrep 'HTTP/1.1 200 OK' $tmp
test xok = x"$(cat $ok)"
check_stderr

kill $(cat $pid)

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