blob: 7d8d514428e30afd3175de2139bfcf2d16135749 [file] [log] [blame]
varnishtest "Health-checks: some http-check tests"
feature ignore_unknown_macro
#REQUIRE_VERSION=2.2
#REGTEST_TYPE=slow
# This script tests HTTP health-checks.
server s1 {
rxreq
expect req.method == OPTIONS
expect req.url == /
expect req.proto == HTTP/1.0
txresp
} -start
server s2 {
rxreq
expect req.method == GET
expect req.url == /status
expect req.proto == HTTP/1.1
txresp
} -start
server s3 {
rxreq
expect req.method == GET
expect req.url == /status
expect req.proto == HTTP/1.1
txresp
} -start
server s4 {
rxreq
expect req.method == GET
expect req.url == /req1
expect req.proto == HTTP/1.1
expect req.http.x-test == "server=srv"
expect req.http.x-haproxy-server-state ~ "UP.+name=be4/srv"
expect req.bodylen == 0
txresp
accept
rxreq
expect req.method == GET
expect req.url == /req2
expect req.proto == HTTP/1.1
expect req.http.x-test == "server="
expect req.http.x-haproxy-server-state ~ "UP.+name=be4/srv"
expect req.http.content-length == 17
expect req.bodylen == 17
expect req.body == "health-check body"
txresp
accept
rxreq
expect req.method == GET
expect req.url == /req3
expect req.proto == HTTP/1.0
expect req.http.x-test == <undef>
expect req.http.x-haproxy-server-state ~ "UP.+name=be4/srv"
expect req.bodylen == 0
txresp
} -start
syslog S1 -level notice {
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be[0-9]+ started."
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be[0-9]+ started."
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be[0-9]+ started."
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be[0-9]+ started."
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be[0-9]/srv succeeded.*code: 200"
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be[0-9]/srv succeeded.*code: 200"
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be[0-9]/srv succeeded.*code: 200"
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be[0-9]/srv succeeded.*code: 200"
} -start
haproxy h1 -conf {
defaults
mode http
timeout client 1s
timeout server 1s
timeout connect 100ms
option log-health-checks
backend be1
log ${S1_addr}:${S1_port} len 2048 local0
option httpchk
server srv ${s1_addr}:${s1_port} check inter 100ms rise 1 fall 1
backend be2
log ${S1_addr}:${S1_port} len 2048 local0
option httpchk GET /status HTTP/1.1
server srv ${s2_addr}:${s2_port} check inter 100ms rise 1 fall 1
backend be3
log ${S1_addr}:${S1_port} len 2048 local0
option httpchk
http-check send meth GET uri /status vsn HTTP/1.1
server srv ${s3_addr}:${s3_port} check inter 100ms rise 1 fall 1
backend be4
mode tcp
log ${S1_addr}:${S1_port} len 2048 local0
option httpchk
http-check send-state
http-check connect addr ${s4_addr}:${s4_port}
http-check set-var(check.server) "str(srv)"
http-check send meth GET uri /req1 vsn HTTP/1.1 hdr x-test "server=%[var(check.server)]"
http-check expect status 200
http-check connect addr ${s4_addr} port ${s4_port}
http-check unset-var(check.server)
http-check send meth GET uri /req2 vsn HTTP/1.1 hdr x-test "server=%[var(check.server)]" body "health-check body"
http-check expect rstatus "^2[0-9]{2}"
http-check connect addr ${s4_addr} port ${s4_port}
http-check send meth GET uri /req3
## implicit expect rule
server srv ${s1_addr}:${s1_port} check inter 100ms rise 1 fall 1
} -start
syslog S1 -wait