]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REGTESTS: add dynamic backend creation test quic-interop flx05/quic-interop
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 2 Feb 2026 09:52:07 +0000 (10:52 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 6 Feb 2026 16:28:27 +0000 (17:28 +0100)
Add a new regtests to validate backend creation at runtime. A server is
then added and requests made to validate the newly created instance
before (with force-be-switch) and after publishing.

reg-tests/proxy/cli_add_backend.vtc [new file with mode: 0644]

diff --git a/reg-tests/proxy/cli_add_backend.vtc b/reg-tests/proxy/cli_add_backend.vtc
new file mode 100644 (file)
index 0000000..7a2c97f
--- /dev/null
@@ -0,0 +1,84 @@
+varnishtest "Add backend via cli"
+
+feature ignore_unknown_macro
+
+haproxy hsrv -conf {
+       global
+       .if feature(THREAD)
+               thread-groups 1
+       .endif
+
+       defaults
+               mode http
+               timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
+               timeout client  "${HAPROXY_TEST_TIMEOUT-5s}"
+               timeout server  "${HAPROXY_TEST_TIMEOUT-5s}"
+
+       frontend fe
+               bind "fd@${fe}"
+               http-request return status 200
+} -start
+
+haproxy h1 -conf {
+       global
+       .if feature(THREAD)
+               thread-groups 1
+       .endif
+
+       defaults
+               mode http
+               timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
+               timeout client  "${HAPROXY_TEST_TIMEOUT-5s}"
+               timeout server  "${HAPROXY_TEST_TIMEOUT-5s}"
+
+       frontend fe
+               bind "fd@${feS}"
+               force-be-switch if { req.hdr("x-admin") "1" }
+               use_backend %[req.hdr(x-be)]
+
+       defaults def
+
+       defaults def_http
+               mode http
+} -start
+
+client c1 -connect ${h1_feS_sock} {
+       txreq -hdr "x-be: be"
+       rxresp
+       expect resp.status == 503
+} -run
+
+haproxy h1 -cli {
+       # non existent backend
+       send "experimental-mode on; add backend be from def"
+       expect ~ "Mode is required"
+
+       send "experimental-mode on; add backend be from def_http"
+       expect ~ "New backend registered."
+
+       send "add server be/srv ${hsrv_fe_addr}:${hsrv_fe_port}"
+       expect ~ "New server registered."
+       send "enable server be/srv"
+       expect ~ ".*"
+}
+
+client c1 -connect ${h1_feS_sock} {
+       txreq -hdr "x-be: be"
+       rxresp
+       expect resp.status == 503
+
+       txreq -hdr "x-be: be" -hdr "x-admin: 1"
+       rxresp
+       expect resp.status == 200
+} -run
+
+haproxy h1 -cli {
+       send "publish backend be"
+       expect ~ "Backend published."
+}
+
+client c1 -connect ${h1_feS_sock} {
+       txreq -hdr "x-be: be"
+       rxresp
+       expect resp.status == 200
+} -run