summaryrefslogtreecommitdiffstats
path: root/reg-tests/checks/http-check.vtc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:18:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:18:05 +0000
commitb46aad6df449445a9fc4aa7b32bd40005438e3f7 (patch)
tree751aa858ca01f35de800164516b298887382919d /reg-tests/checks/http-check.vtc
parentInitial commit. (diff)
downloadhaproxy-b46aad6df449445a9fc4aa7b32bd40005438e3f7.tar.xz
haproxy-b46aad6df449445a9fc4aa7b32bd40005438e3f7.zip
Adding upstream version 2.9.5.upstream/2.9.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'reg-tests/checks/http-check.vtc')
-rw-r--r--reg-tests/checks/http-check.vtc157
1 files changed, 157 insertions, 0 deletions
diff --git a/reg-tests/checks/http-check.vtc b/reg-tests/checks/http-check.vtc
new file mode 100644
index 0000000..3353060
--- /dev/null
+++ b/reg-tests/checks/http-check.vtc
@@ -0,0 +1,157 @@
+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
+
+ accept
+ rxreq
+ expect req.method == GET
+ expect req.url == /
+ 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 == 23
+ expect req.body == "health-check on be4-srv"
+ txresp
+
+} -start
+
+syslog S1 -level notice {
+ 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"
+ 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 "${HAPROXY_TEST_TIMEOUT-5s}"
+ timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
+ timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
+ 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 ver 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 set-var(check.path) "str(/req1)"
+ http-check send meth GET uri-lf "%[var(check.path)]" ver 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 set-var(check.path) "str(/req2)"
+ http-check send meth GET uri-lf "%[var(check.path)]" ver 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 set-var(check.path) "str(/req3)"
+ http-check send meth GET uri-lf "%[var(check.path)]"
+ http-check expect rstatus "^2[0-9]{2}"
+ http-check connect addr ${s4_addr} port ${s4_port}
+ http-check unset-var(check.path)
+ http-check send meth GET uri-lf "%[var(check.path)]" body-lf "health-check on %[be_name]-%[srv_name]"
+ ## implicit expect rule
+ server srv ${s1_addr}:${s1_port} check inter 100ms rise 1 fall 1
+
+ backend be5
+ log ${S1_addr}:${S1_port} len 2048 local0
+ option httpchk
+ server srv ${h1_li1_addr}:${h1_li1_port} proto h2 check inter 100ms rise 1 fall 1
+
+ backend be6
+ log ${S1_addr}:${S1_port} len 2048 local0
+ option httpchk GET /status HTTP/1.1
+ server srv ${h1_li1_addr}:${h1_li1_port} check check-proto h2 inter 100ms rise 1 fall 1
+
+ listen li1
+ mode http
+ bind "fd@${li1}" proto h2
+ http-request return status 200
+
+} -start
+
+syslog S1 -wait