]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: reg-tests: test http-reuse with proxy protocol
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 22 Jan 2021 15:36:55 +0000 (16:36 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 12 Feb 2021 11:54:04 +0000 (12:54 +0100)
Complete the http-reuse test with the proxy protocol usage. A server
connection can be reused if the proxy protocol fields are the same.

reg-tests/connection/http_reuse_conn_hash.vtc

index e0adefc8df8437765296831ac1c0788a3b60484e..e60ed0593037ec345e4808671a81bd0e77b2da8a 100644 (file)
@@ -19,8 +19,16 @@ haproxy h1 -conf {
                http-request set-dst-port hdr(x-dst-port)
                server srv2 ${h1_feR_dst1_addr}:0 pool-low-conn 2
 
+       # proxy protocol
+       # must use reuse always as consecutive requests are from different client
+       listen sender-proxy
+               bind "fd@${feS_proxy}" accept-proxy
+               http-reuse always
+               server srv2 ${h1_feR_proxy_addr}:${h1_feR_proxy_port} send-proxy
+
        listen receiver
                bind "fd@${feR_ssl}" ssl crt ${testdir}/common.pem
+               bind "fd@${feR_proxy}" accept-proxy
                http-request return status 200
                http-after-response set-header http_first_request %[http_first_req]
 
@@ -99,3 +107,45 @@ client c_dst1 -connect ${h1_feS_dst_sock} {
        expect resp.http.x-dst == "dst2"
        expect resp.http.http_first_request == "0"
 } -run
+
+## first request with proxy protocol
+client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:40000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
+       txreq
+       rxresp
+       expect resp.status == 200
+       expect resp.http.http_first_request == "1"
+
+       txreq
+       rxresp
+       expect resp.status == 200
+       expect resp.http.http_first_request == "0"
+} -run
+
+## second request with same proxy protocol entry
+client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:40000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
+       txreq
+       rxresp
+       expect resp.status == 200
+       expect resp.http.http_first_request == "0"
+} -run
+
+## third request with different proxy protocol entry, no reuse
+client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:50000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
+       txreq
+       rxresp
+       expect resp.status == 200
+       expect resp.http.http_first_request == "1"
+} -run
+
+## fourth request, reuse proxy protocol
+client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:50000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
+       txreq
+       rxresp
+       expect resp.status == 200
+       expect resp.http.http_first_request == "0"
+
+       txreq
+       rxresp
+       expect resp.status == 200
+       expect resp.http.http_first_request == "0"
+} -run