stream_response_epoll: our most "special" concurrency option yet
[rainbows.git] / t / t0001-unix-http.sh
blob32d54c78f7ca8bd167bd2287071b0950965aed6b
1 #!/bin/sh
2 . ./test-lib.sh
3 skip_models StreamResponseEpoll
4 t_plan 19 "simple HTTP connection keepalive/pipelining tests for $model"
6 t_begin "checking for config.ru for $model" && {
7 tbase=simple-http_$model.ru
8 test -f "$tbase"
11 t_begin "setup and start" && {
12 rtmpfiles unix_socket
13 rainbows_setup
14 echo "listen '$unix_socket'" >> $unicorn_config
15 rainbows -D $tbase -c $unicorn_config
16 rainbows_wait_start
19 t_begin "pid file exists" && {
20 test -f $pid
23 t_begin "single TCP request" && {
24 curl -sSfv http://$listen/
27 t_begin "handles client EOF gracefully" && {
28 printf 'GET / HTTP/1.1\r\nHost: example.com\r\n\r\n' | \
29 socat - UNIX:$unix_socket > $tmp
30 dbgcat tmp
31 if grep 'HTTP.* 500' $tmp
32 then
33 die "500 error returned on client shutdown(SHUT_WR)"
35 check_stderr
38 dbgcat r_err
40 t_begin "pipelining partial requests" && {
41 req='GET / HTTP/1.1\r\nHost: example.com\r\n'
43 cat $fifo > $tmp &
44 printf "$req"'\r\n'"$req"
45 sleep 1
46 printf 'Connection: close\r\n\r\n'
47 wait
48 echo ok > $ok
49 ) | socat - UNIX:$unix_socket > $fifo
51 dbgcat tmp
53 t_begin "two HTTP/1.1 responses" && {
54 test 2 -eq $(grep '^HTTP/1.1' $tmp | wc -l)
57 t_begin "two HTTP/1.1 200 OK responses" && {
58 test 2 -eq $(grep '^HTTP/1.1 200 OK' $tmp | wc -l)
61 t_begin 'one "Connection: keep-alive" response' && {
62 test 1 -eq $(grep '^Connection: keep-alive' $tmp | wc -l)
65 t_begin 'one "Connection: close" response' && {
66 test 1 -eq $(grep '^Connection: close' $tmp | wc -l)
69 t_begin 'check subshell success' && {
70 test x"$(cat $ok)" = xok
74 t_begin "check stderr" && {
75 check_stderr
78 t_begin "burst pipelining requests" && {
79 req='GET / HTTP/1.1\r\nHost: example.com\r\n'
81 cat $fifo > $tmp &
82 printf "$req"'\r\n'"$req"'Connection: close\r\n\r\n'
83 wait
84 echo ok > $ok
85 ) | socat - UNIX:$unix_socket > $fifo
88 dbgcat tmp
89 dbgcat r_err
91 t_begin "two HTTP/1.1 responses" && {
92 test 2 -eq $(grep '^HTTP/1.1' $tmp | wc -l)
95 t_begin "two HTTP/1.1 200 OK responses" && {
96 test 2 -eq $(grep '^HTTP/1.1 200 OK' $tmp | wc -l)
99 t_begin 'one "Connection: keep-alive" response' && {
100 test 1 -eq $(grep '^Connection: keep-alive' $tmp | wc -l)
103 t_begin 'one "Connection: close" response' && {
104 test 1 -eq $(grep '^Connection: close' $tmp | wc -l)
107 t_begin 'check subshell success' && {
108 test x"$(cat $ok)" = xok
111 t_begin "killing succeeds" && {
112 kill $rainbows_pid
115 t_done