tests: factor out a common parser error "library"
[rainbows.git] / t / t4000-rev-basic.sh
blobe5cfcad09976db4e6834f3e10cb0a4cdca54f590
1 #!/bin/sh
2 . ./test-lib.sh
3 require_rev
5 eval $(unused_listen)
6 rtmpfiles unicorn_config pid r_err r_out tmp fifo ok
7 rm -f $fifo
8 mkfifo $fifo
10 nr_client=30
12 cat > $unicorn_config <<EOF
13 listen "$listen"
14 pid "$pid"
15 stderr_path "$r_err"
16 stdout_path "$r_out"
17 Rainbows! do
18 use :Rev
19 worker_connections 50
20 end
21 EOF
23 rainbows -D t4000.ru -c $unicorn_config
24 wait_for_pid $pid
26 echo "single request"
27 curl -sSfv http://$listen/
29 echo "two requests with keepalive"
30 curl -sSfv http://$listen/a http://$listen/b > $tmp 2>&1
31 grep 'Re-using existing connection' < $tmp
33 echo "pipelining partial requests"
34 req='GET / HTTP/1.1\r\nHost: example.com\r\n'
36 printf "$req"'\r\n'"$req"
37 cat $fifo > $tmp &
38 sleep 1
39 printf 'Connection: close\r\n\r\n'
40 wait
41 echo ok > $ok
42 ) | socat - TCP:$listen > $fifo
44 kill $(cat $pid)
46 test 2 -eq $(grep '^HTTP/1.1' $tmp | wc -l)
47 test 2 -eq $(grep '^HTTP/1.1 200 OK' $tmp | wc -l)
48 test 1 -eq $(grep '^Connection: keep-alive' $tmp | wc -l)
49 test 1 -eq $(grep '^Connection: close' $tmp | wc -l)
50 test x"$(cat $ok)" = xok
51 ! grep Error $r_err