doc: recommend io_splice 4.1.1 or later
[rainbows.git] / t / t0001-unix-http.sh
blobe9bc919cdb243a78bdcb71a45afbf6fdf8420835
1 #!/bin/sh
2 . ./test-lib.sh
3 t_plan 19 "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 t_begin "handles client EOF gracefully" && {
27 printf 'GET / HTTP/1.1\r\nHost: example.com\r\n\r\n' | \
28 socat - UNIX:$unix_socket > $tmp
29 dbgcat tmp
30 if grep 'HTTP.* 500' $tmp
31 then
32 die "500 error returned on client shutdown(SHUT_WR)"
34 check_stderr
37 dbgcat r_err
39 t_begin "pipelining partial requests" && {
40 req='GET / HTTP/1.1\r\nHost: example.com\r\n'
42 cat $fifo > $tmp &
43 printf "$req"'\r\n'"$req"
44 sleep 1
45 printf 'Connection: close\r\n\r\n'
46 wait
47 echo ok > $ok
48 ) | socat - UNIX:$unix_socket > $fifo
50 dbgcat tmp
52 t_begin "two HTTP/1.1 responses" && {
53 test 2 -eq $(grep '^HTTP/1.1' $tmp | wc -l)
56 t_begin "two HTTP/1.1 200 OK responses" && {
57 test 2 -eq $(grep '^HTTP/1.1 200 OK' $tmp | wc -l)
60 t_begin 'one "Connection: keep-alive" response' && {
61 test 1 -eq $(grep '^Connection: keep-alive' $tmp | wc -l)
64 t_begin 'one "Connection: close" response' && {
65 test 1 -eq $(grep '^Connection: close' $tmp | wc -l)
68 t_begin 'check subshell success' && {
69 test x"$(cat $ok)" = xok
73 t_begin "check stderr" && {
74 check_stderr
77 t_begin "burst pipelining requests" && {
78 req='GET / HTTP/1.1\r\nHost: example.com\r\n'
80 cat $fifo > $tmp &
81 printf "$req"'\r\n'"$req"'Connection: close\r\n\r\n'
82 wait
83 echo ok > $ok
84 ) | socat - UNIX:$unix_socket > $fifo
87 dbgcat tmp
88 dbgcat r_err
90 t_begin "two HTTP/1.1 responses" && {
91 test 2 -eq $(grep '^HTTP/1.1' $tmp | wc -l)
94 t_begin "two HTTP/1.1 200 OK responses" && {
95 test 2 -eq $(grep '^HTTP/1.1 200 OK' $tmp | wc -l)
98 t_begin 'one "Connection: keep-alive" response' && {
99 test 1 -eq $(grep '^Connection: keep-alive' $tmp | wc -l)
102 t_begin 'one "Connection: close" response' && {
103 test 1 -eq $(grep '^Connection: close' $tmp | wc -l)
106 t_begin 'check subshell success' && {
107 test x"$(cat $ok)" = xok
110 t_begin "killing succeeds" && {
111 kill $rainbows_pid
114 t_done