]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: reg-test: test http-reuse with specific dst addr
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 11 Jan 2021 16:21:49 +0000 (17:21 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 12 Feb 2021 11:54:04 +0000 (12:54 +0100)
Add a reg-test for connection reuse with a specific destination address.
It is based on the set-dst-port http rule.

reg-tests/connection/http_reuse_conn_hash.vtc

index 34de202e5a7bde7007638acb036b2e88631f962d..e0adefc8df8437765296831ac1c0788a3b60484e 100644 (file)
@@ -11,10 +11,28 @@ haproxy h1 -conf {
                bind "fd@${feS_sni}"
                server srv2 ${h1_feR_ssl_addr}:${h1_feR_ssl_port} ssl sni "req.hdr(x-sni)" verify none pool-low-conn 2
 
+       # set-dst
+       # specify dst1_addr for server, which should be identical to dst2_addr
+       # port is specified by the client in header x-dst-port
+       listen sender-set-dst
+               bind "fd@${feS_dst}"
+               http-request set-dst-port hdr(x-dst-port)
+               server srv2 ${h1_feR_dst1_addr}:0 pool-low-conn 2
+
        listen receiver
                bind "fd@${feR_ssl}" ssl crt ${testdir}/common.pem
                http-request return status 200
                http-after-response set-header http_first_request %[http_first_req]
+
+       listen receiver-dst1
+               bind "fd@${feR_dst1}"
+               http-request return status 200 hdr "x-dst" "dst1"
+               http-after-response set-header http_first_request %[http_first_req]
+
+       listen receiver-dst2
+               bind "fd@${feR_dst2}"
+               http-request return status 200 hdr "x-dst" "dst2"
+               http-after-response set-header http_first_request %[http_first_req]
 } -start
 
 # http-reuse with sni parameters
@@ -43,3 +61,41 @@ client c_sni -connect ${h1_feS_sni_sock} {
        rxresp
        expect resp.http.http_first_request == "0"
 } -run
+
+# http-reuse with destination address
+client c_dst1 -connect ${h1_feS_dst_sock} {
+       txreq \
+         -hdr "x-dst-port: ${h1_feR_dst1_port}"
+       rxresp
+       expect resp.status == 200
+       expect resp.http.x-dst == "dst1"
+       expect resp.http.http_first_request == "1"
+
+       txreq \
+         -hdr "x-dst-port: ${h1_feR_dst1_port}"
+       rxresp
+       expect resp.status == 200
+       expect resp.http.x-dst == "dst1"
+       expect resp.http.http_first_request == "0"
+
+       txreq \
+         -hdr "x-dst-port: ${h1_feR_dst2_port}"
+       rxresp
+       expect resp.status == 200
+       expect resp.http.x-dst == "dst2"
+       expect resp.http.http_first_request == "1"
+
+       txreq \
+         -hdr "x-dst-port: ${h1_feR_dst1_port}"
+       rxresp
+       expect resp.status == 200
+       expect resp.http.x-dst == "dst1"
+       expect resp.http.http_first_request == "0"
+
+       txreq \
+         -hdr "x-dst-port: ${h1_feR_dst2_port}"
+       rxresp
+       expect resp.status == 200
+       expect resp.http.x-dst == "dst2"
+       expect resp.http.http_first_request == "0"
+} -run