From e9152a8463d62e46a772843f66ddedef52cd0b2c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 27 Oct 2009 01:20:47 -0700 Subject: revactor: require 0.1.5, remove 0.1.4 workarounds Also new are added basic HTTP tests for UNIX domain socket handling (for all models, now, of course). --- t/GNUmakefile | 1 + t/t0001-unix-http.sh | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100755 t/t0001-unix-http.sh (limited to 't') diff --git a/t/GNUmakefile b/t/GNUmakefile index 5129944..97f1f82 100644 --- a/t/GNUmakefile +++ b/t/GNUmakefile @@ -31,6 +31,7 @@ $(T): MODELS = $(models) # some tests can be run with all models t0000-simple-http.sh: MODELS = $(all_models) +t0001-unix-http.sh: MODELS = $(all_models) t0002-graceful.sh: MODELS = $(all_models) t0002-parser-error.sh: MODELS = $(all_models) t0003-reopen-logs.sh: MODELS = $(all_models) diff --git a/t/t0001-unix-http.sh b/t/t0001-unix-http.sh new file mode 100755 index 0000000..59f996a --- /dev/null +++ b/t/t0001-unix-http.sh @@ -0,0 +1,103 @@ +#!/bin/sh +. ./test-lib.sh +t_plan 18 "simple HTTP connection keepalive/pipelining tests for $model" + +t_begin "checking for config.ru for $model" && { + tbase=simple-http_$model.ru + test -f "$tbase" +} + +t_begin "setup and start" && { + rtmpfiles unix_socket + rainbows_setup + echo "listen '$unix_socket'" >> $unicorn_config + rainbows -D $tbase -c $unicorn_config + rainbows_wait_start +} + +t_begin "pid file exists" && { + test -f $pid +} + +t_begin "single TCP request" && { + curl -sSfv http://$listen/ +} + +dbgcat r_err + +t_begin "pipelining partial requests" && { + req='GET / HTTP/1.1\r\nHost: example.com\r\n' + ( + cat $fifo > $tmp & + printf "$req"'\r\n'"$req" + sleep 1 + printf 'Connection: close\r\n\r\n' + wait + echo ok > $ok + ) | socat - UNIX:$unix_socket > $fifo +} +dbgcat tmp + +t_begin "two HTTP/1.1 responses" && { + test 2 -eq $(grep '^HTTP/1.1' $tmp | wc -l) +} + +t_begin "two HTTP/1.1 200 OK responses" && { + test 2 -eq $(grep '^HTTP/1.1 200 OK' $tmp | wc -l) +} + +t_begin 'one "Connection: keep-alive" response' && { + test 1 -eq $(grep '^Connection: keep-alive' $tmp | wc -l) +} + +t_begin 'one "Connection: close" response' && { + test 1 -eq $(grep '^Connection: close' $tmp | wc -l) +} + +t_begin 'check subshell success' && { + test x"$(cat $ok)" = xok +} + + +t_begin "check stderr" && { + check_stderr +} + +t_begin "burst pipelining requests" && { + req='GET / HTTP/1.1\r\nHost: example.com\r\n' + ( + cat $fifo > $tmp & + printf "$req"'\r\n'"$req"'Connection: close\r\n\r\n' + wait + echo ok > $ok + ) | socat - UNIX:$unix_socket > $fifo +} + +dbgcat tmp +dbgcat r_err + +t_begin "two HTTP/1.1 responses" && { + test 2 -eq $(grep '^HTTP/1.1' $tmp | wc -l) +} + +t_begin "two HTTP/1.1 200 OK responses" && { + test 2 -eq $(grep '^HTTP/1.1 200 OK' $tmp | wc -l) +} + +t_begin 'one "Connection: keep-alive" response' && { + test 1 -eq $(grep '^Connection: keep-alive' $tmp | wc -l) +} + +t_begin 'one "Connection: close" response' && { + test 1 -eq $(grep '^Connection: close' $tmp | wc -l) +} + +t_begin 'check subshell success' && { + test x"$(cat $ok)" = xok +} + +t_begin "killing succeeds" && { + kill $rainbows_pid +} + +t_done -- cgit v1.2.3-24-ge0c7