REGTEST: add a few HTTP messaging tests

These tests send GET/HEAD/POST requests in H1 and H2, with and without
HTX, with and without a body, and verify that the behaviour is the expected
one. For now HEAD requests have been commented out because in H1 they are
not really testable as varnishtest expects to read a body, and in H2 the
behaviour depends on HTX/legacy, indicating a bug in haproxy (it looks
like we can deliver some data in response to HEAD in legacy mode).
This commit is contained in:
Willy Tarreau 2018-12-13 19:35:29 +01:00
parent 3ec7bfbc7e
commit 7b8d203876
4 changed files with 890 additions and 0 deletions

View File

@ -0,0 +1,172 @@
varnishtest "HTTP request tests: H1 to H1, legacy mode"
#REQUIRE_VERSION=1.6
# Run it with HAPROXY_PROGRAM=$PWD/haproxy varnishtest -l -k -t 1 "$1"
feature ignore_unknown_macro
server s1 {
rxreq
txresp \
-status 200 \
-body "response 1"
rxreq
txresp \
-status 200 \
-body "response 2"
rxreq
txresp \
-status 200 \
-body "response 3"
rxreq
txresp \
-status 200 \
-body "response 4"
} -repeat 2 -start
haproxy h1 -conf {
defaults
mode http
#option http-use-htx
timeout connect 1s
timeout client 1s
timeout server 1s
listen feh1
bind "fd@${feh1}"
#bind "fd@${feh2}" proto h2
server s1 ${s1_addr}:${s1_port}
} -start
# GET requests
client c1h1 -connect ${h1_feh1_sock} {
# first request is valid
txreq \
-req "GET" \
-url "/test1.html"
rxresp
expect resp.status == 200
# second request is valid and advertises C-L:0
txreq \
-req "GET" \
-url "/test2.html" \
-hdr "content-length: 0"
rxresp
expect resp.status == 200
# third request sends a body with a GET
txreq \
-req "GET" \
-url "/test3.html" \
-body "this must be delivered, like it or not"
rxresp
expect resp.status == 200
# fourth request is valid and advertises C-L:0, and close, and is
# followed by a string "this is not sent\r\n\r\n" which must be
# dropped.
txreq \
-req "GET" \
-url "/test4.html" \
-hdr "content-length: 0" \
-hdr "connection: close"
# "this is not sent"
sendhex "74787973207973206E6F742073656E740D0A0D0A"
rxresp
expect resp.status == 200
# the connection is expected to be closed and no more response must
# arrive here.
expect_close
} -run
# HEAD requests
# Note: for now they fail with varnishtest, which expects the amount of
# data advertised in the content-length response.
#client c2h1 -connect ${h1_feh1_sock} {
# # first request is valid
# txreq \
# -req "HEAD" \
# -url "/test11.html"
# rxresp
# expect resp.status == 200
#
# # second request is valid and advertises C-L:0
# txreq \
# -req "HEAD" \
# -url "/test12.html" \
# -hdr "content-length: 0"
# rxresp
# expect resp.status == 200
#
# # third request sends a body with a GET
# txreq \
# -req "GET" \
# -url "/test13.html" \
# -body "this must be delivered, like it or not"
# rxresp
# expect resp.status == 200
#
# # fourth request is valid and advertises C-L:0, and close, and is
# # followed by a string "this is not sent\r\n\r\n" which must be
# # dropped.
# txreq \
# -req "HEAD" \
# -url "/test14.html" \
# -hdr "content-length: 0" \
# -hdr "connection: close"
# # "this is not sent"
# sendhex "74787973207973206E6F742073656E740D0A0D0A"
# rxresp
# expect resp.status == 200
#
# # the connection is expected to be closed and no more response must
# # arrive here.
# expect_close
#} -run
client c1h1 -connect ${h1_feh1_sock} {
# first request is valid
txreq \
-req "POST" \
-url "/test21.html"
rxresp
expect resp.status == 200
# second request is valid and advertises C-L:0
txreq \
-req "POST" \
-url "/test22.html" \
-hdr "content-length: 0"
rxresp
expect resp.status == 200
# third request is valid and advertises (and sends) somme contents
txreq \
-req "POST" \
-url "/test23.html" \
-body "this is sent"
rxresp
expect resp.status == 200
# fourth request is valid and advertises C-L:0, and close, and is
# followed by a string "this is not sent\r\n\r\n" which must be
# dropped.
txreq \
-req "POST" \
-url "/test24.html" \
-hdr "content-length: 0" \
-hdr "connection: close"
# "this is not sent"
sendhex "74787973207973206E6F742073656E740D0A0D0A"
rxresp
expect resp.status == 200
# the connection is expected to be closed and no more response must
# arrive here.
expect_close
} -run

View File

@ -0,0 +1,172 @@
varnishtest "HTTP request tests: H1 to H1, HTX mode"
#REQUIRE_VERSION=1.9
# Run it with HAPROXY_PROGRAM=$PWD/haproxy varnishtest -l -k -t 1 "$1"
feature ignore_unknown_macro
server s1 {
rxreq
txresp \
-status 200 \
-body "response 1"
rxreq
txresp \
-status 200 \
-body "response 2"
rxreq
txresp \
-status 200 \
-body "response 3"
rxreq
txresp \
-status 200 \
-body "response 4"
} -repeat 2 -start
haproxy h1 -conf {
defaults
mode http
option http-use-htx
timeout connect 1s
timeout client 1s
timeout server 1s
listen feh1
bind "fd@${feh1}"
#bind "fd@${feh2}" proto h2
server s1 ${s1_addr}:${s1_port}
} -start
# GET requests
client c1h1 -connect ${h1_feh1_sock} {
# first request is valid
txreq \
-req "GET" \
-url "/test1.html"
rxresp
expect resp.status == 200
# second request is valid and advertises C-L:0
txreq \
-req "GET" \
-url "/test2.html" \
-hdr "content-length: 0"
rxresp
expect resp.status == 200
# third request sends a body with a GET
txreq \
-req "GET" \
-url "/test3.html" \
-body "this must be delivered, like it or not"
rxresp
expect resp.status == 200
# fourth request is valid and advertises C-L:0, and close, and is
# followed by a string "this is not sent\r\n\r\n" which must be
# dropped.
txreq \
-req "GET" \
-url "/test4.html" \
-hdr "content-length: 0" \
-hdr "connection: close"
# "this is not sent"
sendhex "74787973207973206E6F742073656E740D0A0D0A"
rxresp
expect resp.status == 200
# the connection is expected to be closed and no more response must
# arrive here.
expect_close
} -run
# HEAD requests
# Note: for now they fail with varnishtest, which expects the amount of
# data advertised in the content-length response.
#client c2h1 -connect ${h1_feh1_sock} {
# # first request is valid
# txreq \
# -req "HEAD" \
# -url "/test11.html"
# rxresp
# expect resp.status == 200
#
# # second request is valid and advertises C-L:0
# txreq \
# -req "HEAD" \
# -url "/test12.html" \
# -hdr "content-length: 0"
# rxresp
# expect resp.status == 200
#
# # third request sends a body with a GET
# txreq \
# -req "GET" \
# -url "/test13.html" \
# -body "this must be delivered, like it or not"
# rxresp
# expect resp.status == 200
#
# # fourth request is valid and advertises C-L:0, and close, and is
# # followed by a string "this is not sent\r\n\r\n" which must be
# # dropped.
# txreq \
# -req "HEAD" \
# -url "/test14.html" \
# -hdr "content-length: 0" \
# -hdr "connection: close"
# # "this is not sent"
# sendhex "74787973207973206E6F742073656E740D0A0D0A"
# rxresp
# expect resp.status == 200
#
# # the connection is expected to be closed and no more response must
# # arrive here.
# expect_close
#} -run
client c1h1 -connect ${h1_feh1_sock} {
# first request is valid
txreq \
-req "POST" \
-url "/test21.html"
rxresp
expect resp.status == 200
# second request is valid and advertises C-L:0
txreq \
-req "POST" \
-url "/test22.html" \
-hdr "content-length: 0"
rxresp
expect resp.status == 200
# third request is valid and advertises (and sends) somme contents
txreq \
-req "POST" \
-url "/test23.html" \
-body "this is sent"
rxresp
expect resp.status == 200
# fourth request is valid and advertises C-L:0, and close, and is
# followed by a string "this is not sent\r\n\r\n" which must be
# dropped.
txreq \
-req "POST" \
-url "/test24.html" \
-hdr "content-length: 0" \
-hdr "connection: close"
# "this is not sent"
sendhex "74787973207973206E6F742073656E740D0A0D0A"
rxresp
expect resp.status == 200
# the connection is expected to be closed and no more response must
# arrive here.
expect_close
} -run

View File

@ -0,0 +1,273 @@
varnishtest "HTTP request tests: H2 to H1, legacy mode"
#REQUIRE_VERSION=1.9
# Run it with HAPROXY_PROGRAM=$PWD/haproxy varnishtest -l -k -t 1 "$1"
feature ignore_unknown_macro
# synchronize requests between streams
barrier b1 cond 2 -cyclic
barrier b2 cond 2 -cyclic
barrier b3 cond 2 -cyclic
barrier b4 cond 2 -cyclic
server s1 {
rxreq
txresp \
-status 200 \
-body "response 1"
barrier b2 sync
rxreq
txresp \
-status 200 \
-body "response 2"
barrier b3 sync
rxreq
txresp \
-status 200 \
-body "response 3"
barrier b4 sync
rxreq
txresp \
-status 200 \
-body "response 4"
} -repeat 2 -start
haproxy h1 -conf {
defaults
#log stdout format raw daemon
mode http
#option http-use-htx
timeout connect 1s
timeout client 1s
timeout server 1s
listen feh1
bind "fd@${feh1}"
bind "fd@${feh2}" proto h2
server s1 ${s1_addr}:${s1_port}
} -start
client c1h2 -connect ${h1_feh2_sock} {
txpri
stream 0 {
txsettings
rxsettings
txsettings -ack
rxwinup
rxsettings
expect settings.ack == true
} -run
# first request is valid
stream 1 {
txreq \
-req "GET" \
-scheme "https" \
-url "/test1.html"
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 1"
} -run
# second request is valid and advertises C-L:0
stream 3 {
barrier b2 sync
txreq \
-req "GET" \
-scheme "https" \
-url "/test2.html" \
-hdr "content-length" "0"
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 2"
} -run
# third request sends a body with a GET
stream 5 {
barrier b3 sync
txreq \
-req "GET" \
-scheme "https" \
-url "/test3.html" \
-nostrend \
-body "this must be delivered, like it or not"
rxwinup
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 3"
} -run
# fourth request is valid and advertises C-L:0, and close, and is
# followed by a string "this is not sent\r\n\r\n" which must be
# dropped.
stream 7 {
barrier b4 sync
txreq \
-req "GET" \
-scheme "https" \
-url "/test4.html" \
-hdr "content-length" "0" \
-nostrend
txdata -data "this is sent and ignored"
rxwinup
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 4"
} -run
} -run
# HEAD requests : don't work well yet
#client c2h2 -connect ${h1_feh2_sock} {
# txpri
# stream 0 {
# txsettings
# rxsettings
# txsettings -ack
# rxwinup
# rxsettings
# expect settings.ack == true
# } -run
#
# # first request is valid
# stream 1 {
# txreq \
# -req "HEAD" \
# -scheme "https" \
# -url "/test11.html"
# rxhdrs
# expect resp.status == 200
# rxdata -all
# expect resp.bodylen == 0
# } -run
#
# # second request is valid and advertises C-L:0
# stream 3 {
# barrier b2 sync
# txreq \
# -req "HEAD" \
# -scheme "https" \
# -url "/test12.html" \
# -hdr "content-length" "0"
# rxhdrs
# expect resp.status == 200
# rxdata -all
# expect resp.bodylen == 0
# } -run
#
# # third request sends a body with a GET
# stream 5 {
# barrier b3 sync
# txreq \
# -req "HEAD" \
# -scheme "https" \
# -url "/test13.html" \
# -nostrend \
# -body "this must be delivered, like it or not"
# rxwinup
# rxhdrs
# expect resp.status == 200
# rxdata -all
# expect resp.bodylen == 0
# } -run
#
# # fourth request is valid and advertises C-L:0, and close, and is
# # followed by a string "this is not sent\r\n\r\n" which must be
# # dropped.
# stream 7 {
# barrier b4 sync
# txreq \
# -req "HEAD" \
# -scheme "https" \
# -url "/test14.html" \
# -hdr "content-length" "0" \
# -nostrend
# txdata -data "this is sent and ignored"
# rxwinup
# rxhdrs
# expect resp.status == 200
# rxdata -all
# expect resp.bodylen == 0
# } -run
#} -run
# POST requests
client c3h2 -connect ${h1_feh2_sock} {
txpri
stream 0 {
txsettings
rxsettings
txsettings -ack
rxwinup
rxsettings
expect settings.ack == true
} -run
# first request is valid
stream 1 {
txreq \
-req "POST" \
-scheme "https" \
-url "/test21.html"
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 1"
} -run
# second request is valid and advertises C-L:0
stream 3 {
barrier b2 sync
txreq \
-req "POST" \
-scheme "https" \
-url "/test22.html" \
-hdr "content-length" "0"
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 2"
} -run
# third request sends a body with a GET
stream 5 {
barrier b3 sync
txreq \
-req "POST" \
-scheme "https" \
-url "/test23.html" \
-nostrend \
-body "this must be delivered, like it or not"
rxwinup
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 3"
} -run
# fourth request is valid and advertises C-L:0, and close, and is
# followed by a string "this is not sent\r\n\r\n" which must be
# dropped.
stream 7 {
barrier b4 sync
txreq \
-req "POST" \
-scheme "https" \
-url "/test24.html" \
-hdr "content-length" "0" \
-nostrend
txdata -data "this is sent and ignored"
rxwinup
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 4"
} -run
} -run

View File

@ -0,0 +1,273 @@
varnishtest "HTTP request tests: H2 to H1, HTX mode"
#REQUIRE_VERSION=1.9
# Run it with HAPROXY_PROGRAM=$PWD/haproxy varnishtest -l -k -t 1 "$1"
feature ignore_unknown_macro
# synchronize requests between streams
barrier b1 cond 2 -cyclic
barrier b2 cond 2 -cyclic
barrier b3 cond 2 -cyclic
barrier b4 cond 2 -cyclic
server s1 {
rxreq
txresp \
-status 200 \
-body "response 1"
barrier b2 sync
rxreq
txresp \
-status 200 \
-body "response 2"
barrier b3 sync
rxreq
txresp \
-status 200 \
-body "response 3"
barrier b4 sync
rxreq
txresp \
-status 200 \
-body "response 4"
} -repeat 2 -start
haproxy h1 -conf {
defaults
#log stdout format raw daemon
mode http
option http-use-htx
timeout connect 1s
timeout client 1s
timeout server 1s
listen feh1
bind "fd@${feh1}"
bind "fd@${feh2}" proto h2
server s1 ${s1_addr}:${s1_port}
} -start
client c1h2 -connect ${h1_feh2_sock} {
txpri
stream 0 {
txsettings
rxsettings
txsettings -ack
rxwinup
rxsettings
expect settings.ack == true
} -run
# first request is valid
stream 1 {
txreq \
-req "GET" \
-scheme "https" \
-url "/test1.html"
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 1"
} -run
# second request is valid and advertises C-L:0
stream 3 {
barrier b2 sync
txreq \
-req "GET" \
-scheme "https" \
-url "/test2.html" \
-hdr "content-length" "0"
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 2"
} -run
# third request sends a body with a GET
stream 5 {
barrier b3 sync
txreq \
-req "GET" \
-scheme "https" \
-url "/test3.html" \
-nostrend \
-body "this must be delivered, like it or not"
rxwinup
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 3"
} -run
# fourth request is valid and advertises C-L:0, and close, and is
# followed by a string "this is not sent\r\n\r\n" which must be
# dropped.
stream 7 {
barrier b4 sync
txreq \
-req "GET" \
-scheme "https" \
-url "/test4.html" \
-hdr "content-length" "0" \
-nostrend
txdata -data "this is sent and ignored"
rxwinup
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 4"
} -run
} -run
# HEAD requests : don't work well yet
#client c2h2 -connect ${h1_feh2_sock} {
# txpri
# stream 0 {
# txsettings
# rxsettings
# txsettings -ack
# rxwinup
# rxsettings
# expect settings.ack == true
# } -run
#
# # first request is valid
# stream 1 {
# txreq \
# -req "HEAD" \
# -scheme "https" \
# -url "/test11.html"
# rxhdrs
# expect resp.status == 200
# rxdata -all
# expect resp.bodylen == 0
# } -run
#
# # second request is valid and advertises C-L:0
# stream 3 {
# barrier b2 sync
# txreq \
# -req "HEAD" \
# -scheme "https" \
# -url "/test12.html" \
# -hdr "content-length" "0"
# rxhdrs
# expect resp.status == 200
# rxdata -all
# expect resp.bodylen == 0
# } -run
#
# # third request sends a body with a GET
# stream 5 {
# barrier b3 sync
# txreq \
# -req "HEAD" \
# -scheme "https" \
# -url "/test13.html" \
# -nostrend \
# -body "this must be delivered, like it or not"
# rxwinup
# rxhdrs
# expect resp.status == 200
# rxdata -all
# expect resp.bodylen == 0
# } -run
#
# # fourth request is valid and advertises C-L:0, and close, and is
# # followed by a string "this is not sent\r\n\r\n" which must be
# # dropped.
# stream 7 {
# barrier b4 sync
# txreq \
# -req "HEAD" \
# -scheme "https" \
# -url "/test14.html" \
# -hdr "content-length" "0" \
# -nostrend
# txdata -data "this is sent and ignored"
# rxwinup
# rxhdrs
# expect resp.status == 200
# rxdata -all
# expect resp.bodylen == 0
# } -run
#} -run
# POST requests
client c3h2 -connect ${h1_feh2_sock} {
txpri
stream 0 {
txsettings
rxsettings
txsettings -ack
rxwinup
rxsettings
expect settings.ack == true
} -run
# first request is valid
stream 1 {
txreq \
-req "POST" \
-scheme "https" \
-url "/test21.html"
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 1"
} -run
# second request is valid and advertises C-L:0
stream 3 {
barrier b2 sync
txreq \
-req "POST" \
-scheme "https" \
-url "/test22.html" \
-hdr "content-length" "0"
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 2"
} -run
# third request sends a body with a GET
stream 5 {
barrier b3 sync
txreq \
-req "POST" \
-scheme "https" \
-url "/test23.html" \
-nostrend \
-body "this must be delivered, like it or not"
rxwinup
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 3"
} -run
# fourth request is valid and advertises C-L:0, and close, and is
# followed by a string "this is not sent\r\n\r\n" which must be
# dropped.
stream 7 {
barrier b4 sync
txreq \
-req "POST" \
-scheme "https" \
-url "/test24.html" \
-hdr "content-length" "0" \
-nostrend
txdata -data "this is sent and ignored"
rxwinup
rxhdrs
expect resp.status == 200
rxdata -all
expect resp.body == "response 4"
} -run
} -run