initial edge-triggered epoll model
[rainbows.git] / t / t0035-kgio-pipe-response.sh
blobc4b1096967f2373503dd52864e0ede3abd128d81
1 #!/bin/sh
2 . ./test-lib.sh
3 test -r random_blob || die "random_blob required, run with 'make $0'"
4 case $model in
5 *Fiber*|Epoll) ;;
6 *)
7 t_info "skipping $T since it's not compatible with $model"
8 exit 0
9 ;;
10 esac
12 t_plan 10 "fast Kgio pipe response for $model"
14 t_begin "setup and startup" && {
15 rtmpfiles err out
16 rainbows_setup $model
17 rainbows -E none -D kgio-pipe-response.ru -c $unicorn_config
18 rainbows_wait_start
21 t_begin "read random blob sha1" && {
22 random_blob_sha1=$(rsha1 < random_blob)
23 three_sha1=$(cat random_blob random_blob random_blob | rsha1)
26 t_begin "single request matches" && {
27 sha1=$(curl -sSfv 2> $err http://$listen/ | rsha1)
28 test -n "$sha1"
29 test x"$sha1" = x"$random_blob_sha1"
32 t_begin "Content-Length header preserved in response" && {
33 grep "^< Content-Length:" $err
36 t_begin "send three keep-alive requests" && {
37 sha1=$(curl -vsSf 2> $err \
38 http://$listen/ http://$listen/ http://$listen/ | rsha1)
39 test -n "$sha1"
40 test x"$sha1" = x"$three_sha1"
43 t_begin "ensure responses were all keep-alive" && {
44 test 3 -eq $(grep '< Connection: keep-alive' < $err | wc -l)
47 t_begin "HTTP/1.0 test" && {
48 sha1=$(curl -0 -v 2> $err -sSf http://$listen/ | rsha1)
49 test $sha1 = $random_blob_sha1
50 grep '< Connection: close' < $err
53 t_begin "HTTP/0.9 test" && {
55 printf 'GET /\r\n'
56 rsha1 < $fifo > $tmp &
57 wait
58 echo ok > $ok
59 ) | socat - TCP:$listen > $fifo
60 test $(cat $tmp) = $random_blob_sha1
61 test xok = x$(cat $ok)
64 t_begin "shutdown server" && {
65 kill -QUIT $rainbows_pid
68 t_begin "check stderr" && check_stderr
70 t_done