REGTESTS: update http_reuse_be_transparent with "transparent" deprecated

With commit e93f3ea3f8 ("MEDIUM: proxy: deprecate the "transparent" and
"option transparent" directives") this one no longer works as the config
either has to be adjusted to use server 0.0.0.0 or to enable the deprecated
feature. The test used to validate a technical limitation ("transparent"
not supporting shared connections), indicated as being comparable to
"http-reuse never". Let's now duplicate the test for "http-reuse never"
and "http-reuse always" and validate both behaviors.

Take this opportunity to fix a few problems in this config:
  - use "nbthread 1": depending on the thread where the connection
    arrives, the connection may or may not be reused
  - add explicit URLs to the clients so that they can be recognized
    in the logs
  - add comments to make it clearer what to expect for each test
This commit is contained in:
Willy Tarreau 2025-06-26 14:28:36 +02:00
parent e93f3ea3f8
commit 1d3ab10423

View File

@ -1,27 +1,41 @@
varnishtest "Test the proper interaction between http-reuse and backend in transparent mode"
feature cmd "$HAPROXY_PROGRAM -cc 'feature(TPROXY)'"
# If backend is used with the transparent mode, the connection are considered
# as private and should only be reused for requests of the same session.
# This is similar to the http-reuse never mode
# Verify that connections made to a backend in transparent mode with
# "http-reuse never" are only reused with that client, and those with
# "http-reuse always" are properly shared across subsequent clients.
feature ignore_unknown_macro
haproxy h1 -conf {
global
nbthread 1
defaults
timeout client 30s
timeout server 30s
timeout connect 30s
mode http
listen sender
bind "fd@${feS}"
option transparent
listen never
bind "fd@${feN}"
http-reuse never
http-request set-dst hdr(dst)
http-request set-dst-port hdr(dst-port)
http-after-response set-header http_reuse %[bc_reused]
server transparent 0.0.0.0
listen always
bind "fd@${feA}"
http-reuse always
http-request set-dst hdr(dst)
http-request set-dst-port hdr(dst-port)
http-after-response set-header http_reuse %[bc_reused]
server transparent 0.0.0.0 pool-max-conn 10
listen srv1
bind "fd@${fes1}"
@ -34,22 +48,24 @@ haproxy h1 -conf {
http-request return status 200 hdr srv-id s2
} -start
client c1 -connect ${h1_feS_sock} {
txreq \
### now the test in http-reuse never mode
# 1,1,1
client c1 -connect ${h1_feN_sock} {
txreq -url /c1-1 \
-hdr "dst: ${h1_fes1_addr}" \
-hdr "dst-port: ${h1_fes1_port}"
rxresp
expect resp.http.http_reuse == "0"
expect resp.http.srv-id == "s1"
txreq \
txreq -url /c1-2 \
-hdr "dst: ${h1_fes1_addr}" \
-hdr "dst-port: ${h1_fes1_port}"
rxresp
expect resp.http.http_reuse == "1"
expect resp.http.srv-id == "s1"
txreq \
txreq -url /c1-3 \
-hdr "dst: ${h1_fes1_addr}" \
-hdr "dst-port: ${h1_fes1_port}"
rxresp
@ -57,22 +73,23 @@ client c1 -connect ${h1_feS_sock} {
expect resp.http.srv-id == "s1"
} -run
client c2 -connect ${h1_feS_sock} {
txreq \
# 2,1,2
client c2 -connect ${h1_feN_sock} {
txreq -url /c2-1 \
-hdr "dst: ${h1_fes2_addr}" \
-hdr "dst-port: ${h1_fes2_port}"
rxresp
expect resp.http.http_reuse == "0"
expect resp.http.srv-id == "s2"
txreq \
txreq -url /c2-2 \
-hdr "dst: ${h1_fes1_addr}" \
-hdr "dst-port: ${h1_fes1_port}"
rxresp
expect resp.http.http_reuse == "0"
expect resp.http.srv-id == "s1"
txreq \
txreq -url /c2-3 \
-hdr "dst: ${h1_fes2_addr}" \
-hdr "dst-port: ${h1_fes2_port}"
rxresp
@ -80,22 +97,97 @@ client c2 -connect ${h1_feS_sock} {
expect resp.http.srv-id == "s2"
} -run
client c3 -connect ${h1_feS_sock} {
txreq \
# 1,1,2
client c3 -connect ${h1_feN_sock} {
txreq -url /c3-1 \
-hdr "dst: ${h1_fes1_addr}" \
-hdr "dst-port: ${h1_fes1_port}"
rxresp
expect resp.http.http_reuse == "0"
expect resp.http.srv-id == "s1"
txreq \
txreq -url /c3-2 \
-hdr "dst: ${h1_fes1_addr}" \
-hdr "dst-port: ${h1_fes1_port}"
rxresp
expect resp.http.http_reuse == "1"
expect resp.http.srv-id == "s1"
txreq \
txreq -url /c3-3 \
-hdr "dst: ${h1_fes2_addr}" \
-hdr "dst-port: ${h1_fes2_port}"
rxresp
expect resp.http.http_reuse == "0"
expect resp.http.srv-id == "s2"
} -run
### now the test in http-reuse safe mode
# 1,1,1
client c4 -connect ${h1_feA_sock} {
txreq -url /c4-1 \
-hdr "dst: ${h1_fes1_addr}" \
-hdr "dst-port: ${h1_fes1_port}"
rxresp
expect resp.http.http_reuse == "0"
expect resp.http.srv-id == "s1"
txreq -url /c4-2 \
-hdr "dst: ${h1_fes1_addr}" \
-hdr "dst-port: ${h1_fes1_port}"
rxresp
expect resp.http.http_reuse == "1"
expect resp.http.srv-id == "s1"
txreq -url /c4-3 \
-hdr "dst: ${h1_fes1_addr}" \
-hdr "dst-port: ${h1_fes1_port}"
rxresp
expect resp.http.http_reuse == "1"
expect resp.http.srv-id == "s1"
} -run
# 2,1,2
client c5 -connect ${h1_feA_sock} {
txreq -url /c5-1 \
-hdr "dst: ${h1_fes2_addr}" \
-hdr "dst-port: ${h1_fes2_port}"
rxresp
expect resp.http.http_reuse == "0"
expect resp.http.srv-id == "s2"
txreq -url /c5-2 \
-hdr "dst: ${h1_fes1_addr}" \
-hdr "dst-port: ${h1_fes1_port}"
rxresp
expect resp.http.http_reuse == "1"
expect resp.http.srv-id == "s1"
txreq -url /c5-3 \
-hdr "dst: ${h1_fes2_addr}" \
-hdr "dst-port: ${h1_fes2_port}"
rxresp
expect resp.http.http_reuse == "0"
expect resp.http.srv-id == "s2"
} -run
# 1,1,2
client c6 -connect ${h1_feA_sock} {
txreq -url /c6-1 \
-hdr "dst: ${h1_fes1_addr}" \
-hdr "dst-port: ${h1_fes1_port}"
rxresp
expect resp.http.http_reuse == "1"
expect resp.http.srv-id == "s1"
txreq -url /c6-2 \
-hdr "dst: ${h1_fes1_addr}" \
-hdr "dst-port: ${h1_fes1_port}"
rxresp
expect resp.http.http_reuse == "1"
expect resp.http.srv-id == "s1"
txreq -url /c6-3 \
-hdr "dst: ${h1_fes2_addr}" \
-hdr "dst-port: ${h1_fes2_port}"
rxresp