blob: fc746310c2626a49403452d88710adb850c0822d [file] [log] [blame]
Amaury Denoyelled86ae4b2021-01-26 14:35:23 +01001varnishtest "Test the http-reuse never mode"
2
3#REQUIRE_VERSION=2.2
4
5feature ignore_unknown_macro
6
7haproxy h1 -conf {
8 defaults
9 mode http
10
11 # limit idle pool to one connection
12 # this is to mirror http-reuse safe test, but in this case to ensure that
13 # connection are never reused as expected
14 listen sender
15 bind "fd@${feS}"
16 http-reuse never
17 http-request set-header client-id %[req.hdr(client-id)] if { req.hdr(client-id) -m found }
18 server srv ${h1_feR_addr}:${h1_feR_port} pool-max-conn 1
19
20 listen receiver
21 bind "fd@${feR}"
22 http-request set-var(sess.client_id) req.hdr(client-id)
23 http-request return status 200
24 http-after-response set-header http_first_request %[http_first_req]
25 http-after-response set-header client-id %[var(sess.client_id)]
26} -start
27
28client c1 -connect ${h1_feS_sock} {
29 txreq \
30 -hdr "client-id: c1"
31 rxresp
32 expect resp.http.http_first_request == "1"
33
34 txreq
35 rxresp
36 expect resp.http.http_first_request == "0"
37 expect resp.http.client-id == "c1"
38
39 txreq
40 rxresp
41 expect resp.http.http_first_request == "0"
42 expect resp.http.client-id == "c1"
43} -run
44
45client c2 -connect ${h1_feS_sock} {
46 txreq \
47 -hdr "client-id: c2"
48 rxresp
49 expect resp.http.http_first_request == "1"
50 expect resp.http.client-id == "c2"
51
52 txreq
53 rxresp
54 expect resp.http.http_first_request == "0"
55 expect resp.http.client-id == "c2"
56
57 txreq
58 rxresp
59 expect resp.http.http_first_request == "0"
60 expect resp.http.client-id == "c2"
61} -run
62
63client c3 -connect ${h1_feS_sock} {
64 txreq \
65 -hdr "client-id: c3"
66 rxresp
67 expect resp.http.http_first_request == "1"
68 expect resp.http.client-id == "c3"
69
70 txreq
71 rxresp
72 expect resp.http.http_first_request == "0"
73 expect resp.http.client-id == "c3"
74
75 txreq
76 rxresp
77 expect resp.http.http_first_request == "0"
78 expect resp.http.client-id == "c3"
79} -run