RevThreadSpawn is still experimental
[rainbows.git] / t / t0001-unix-http.sh
blob59f996abbeeea2c3fe7e1e61d7d8a022e210ca25
1 #!/bin/sh
2 . ./test-lib.sh
3 t_plan 18 "simple HTTP connection keepalive/pipelining tests for $model"
5 t_begin "checking for config.ru for $model" && {
6 tbase=simple-http_$model.ru
7 test -f "$tbase"
10 t_begin "setup and start" && {
11 rtmpfiles unix_socket
12 rainbows_setup
13 echo "listen '$unix_socket'" >> $unicorn_config
14 rainbows -D $tbase -c $unicorn_config
15 rainbows_wait_start
18 t_begin "pid file exists" && {
19 test -f $pid
22 t_begin "single TCP request" && {
23 curl -sSfv http://$listen/
26 dbgcat r_err
28 t_begin "pipelining partial requests" && {
29 req='GET / HTTP/1.1\r\nHost: example.com\r\n'
31 cat $fifo > $tmp &
32 printf "$req"'\r\n'"$req"
33 sleep 1
34 printf 'Connection: close\r\n\r\n'
35 wait
36 echo ok > $ok
37 ) | socat - UNIX:$unix_socket > $fifo
39 dbgcat tmp
41 t_begin "two HTTP/1.1 responses" && {
42 test 2 -eq $(grep '^HTTP/1.1' $tmp | wc -l)
45 t_begin "two HTTP/1.1 200 OK responses" && {
46 test 2 -eq $(grep '^HTTP/1.1 200 OK' $tmp | wc -l)
49 t_begin 'one "Connection: keep-alive" response' && {
50 test 1 -eq $(grep '^Connection: keep-alive' $tmp | wc -l)
53 t_begin 'one "Connection: close" response' && {
54 test 1 -eq $(grep '^Connection: close' $tmp | wc -l)
57 t_begin 'check subshell success' && {
58 test x"$(cat $ok)" = xok
62 t_begin "check stderr" && {
63 check_stderr
66 t_begin "burst pipelining requests" && {
67 req='GET / HTTP/1.1\r\nHost: example.com\r\n'
69 cat $fifo > $tmp &
70 printf "$req"'\r\n'"$req"'Connection: close\r\n\r\n'
71 wait
72 echo ok > $ok
73 ) | socat - UNIX:$unix_socket > $fifo
76 dbgcat tmp
77 dbgcat r_err
79 t_begin "two HTTP/1.1 responses" && {
80 test 2 -eq $(grep '^HTTP/1.1' $tmp | wc -l)
83 t_begin "two HTTP/1.1 200 OK responses" && {
84 test 2 -eq $(grep '^HTTP/1.1 200 OK' $tmp | wc -l)
87 t_begin 'one "Connection: keep-alive" response' && {
88 test 1 -eq $(grep '^Connection: keep-alive' $tmp | wc -l)
91 t_begin 'one "Connection: close" response' && {
92 test 1 -eq $(grep '^Connection: close' $tmp | wc -l)
95 t_begin 'check subshell success' && {
96 test x"$(cat $ok)" = xok
99 t_begin "killing succeeds" && {
100 kill $rainbows_pid
103 t_done