blob: 05616387a55cc566716f4fe97fa8a3efee19806e [file] [log] [blame]
Thayne McCombs23cc52d2020-12-19 00:59:35 -07001vtest "A reg test for stickiness with srvkey addr"
2feature ignore_unknown_macro
3
4
5# The aim of this test is to check that "stick on" rules
6# do the job they are supposed to do.
7# If we remove one of the "stick on" rule, this script fails.
8
9#REQUIRE_VERSION=2.4
10
11server s_not_used_1 {}
12server s_not_used_2 {}
13server s_not_used_3 {}
14server s_not_used_4 {}
15server s_not_used_5 {}
16server s_not_used_6 {}
17server s_not_used_7 {}
18server s_not_used_8 {}
19server s_not_used_9 {}
20server s_not_used_10 {}
21server s_not_used_11 {}
22server s_not_used_12 {}
23
24# h1/be1 servers
25server s1 {
26 rxreq
27 txresp -hdr "Server: s1"
28} -repeat 8 -start
29
30server s2 {
31 rxreq
32 txresp -hdr "Server: s2"
33} -repeat 8 -start
34
35haproxy h1 -arg "-L A" -conf {
36 defaults
37 mode http
38 ${no-htx} option http-use-htx
39 timeout server 1s
40 timeout connect 1s
41 timeout client 1s
42 log stdout format raw local0 debug
43
44 peers mypeers
45 bind "fd@${A}"
46 server A
47 server B ${h2_B_addr}:${h2_B_port}
48 table mytable type string size 10m srvkey addr
49
50 backend be1
51 balance roundrobin
52 stick on urlp(client) table mypeers/mytable
53 server srv1 ${s1_addr}:${s1_port}
54 server srv2 ${s2_addr}:${s2_port}
55
56 backend be2
57 balance roundrobin
58 stick on urlp(client) table mypeers/mytable
59 server s_not_used_1 ${s_not_used_1_addr}:${s_not_used_1_port}
60 server s_not_used_2 ${s_not_used_2_addr}:${s_not_used_2_port}
61 server s_not_used_3 ${s_not_used_3_addr}:${s_not_used_3_port}
62 server srv2_2 ${s2_addr}:${s2_port}
63 server s_not_used_4 ${s_not_used_4_addr}:${s_not_used_4_port}
64 server s_not_used_5 ${s_not_used_5_addr}:${s_not_used_5_port}
65 server s_not_used_6 ${s_not_used_6_addr}:${s_not_used_6_port}
66 server srv1_2 ${s1_addr}:${s1_port}
Willy Tarreaufae9a4c2021-01-06 09:20:22 +010067 server s_no_addr_1 unresolvable1.addr.local init-addr none
Thayne McCombs23cc52d2020-12-19 00:59:35 -070068
69 frontend fe
70 acl acl_be1 path_beg /be1
71 acl acl_be2 path_beg /be2
72 use_backend be1 if acl_be1
73 use_backend be2 if acl_be2
74 bind "fd@${fe}"
75} -start
76
77haproxy h2 -arg "-L B" -conf {
78 defaults
79 mode http
80 ${no-htx} option http-use-htx
81 timeout server 1s
82 timeout connect 1s
83 timeout client 1s
84
85 peers mypeers
86 bind "fd@${B}"
87 server A ${h1_A_addr}:${h1_A_port}
88 server B
89 table mytable type string size 10m srvkey addr
90
91 backend be1
92 balance roundrobin
93 stick on urlp(client) table mypeers/mytable
94 server s_not_used_7 ${s_not_used_7_addr}:${s_not_used_7_port}
95 server s_not_used_8 ${s_not_used_8_addr}:${s_not_used_8_port}
96 server s_not_used_9 ${s_not_used_9_addr}:${s_not_used_9_port}
97 server srv1_h2_1 ${s1_addr}:${s1_port}
98 server s_not_used_10 ${s_not_used_10_addr}:${s_not_used_10_port}
99 server s_not_used_11 ${s_not_used_11_addr}:${s_not_used_11_port}
100 server s_not_used_12 ${s_not_used_12_addr}:${s_not_used_12_port}
101 server srv2_h2_1 ${s2_addr}:${s2_port}
Willy Tarreaufae9a4c2021-01-06 09:20:22 +0100102 server s_no_addr_1 unresolvable1.addr.local init-addr none
Thayne McCombs23cc52d2020-12-19 00:59:35 -0700103
104 backend be2
105 balance roundrobin
106 stick on urlp(client) table mypeers/mytable
107 server s_not_used_1 ${s_not_used_1_addr}:${s_not_used_1_port}
108 server s_not_used_2 ${s_not_used_2_addr}:${s_not_used_2_port}
109 server s_not_used_3 ${s_not_used_3_addr}:${s_not_used_3_port}
110 server s_not_used_4 ${s_not_used_4_addr}:${s_not_used_4_port}
111 server s_not_used_5 ${s_not_used_5_addr}:${s_not_used_5_port}
112 server s_not_used_6 ${s_not_used_6_addr}:${s_not_used_6_port}
113 server srv1_h2_2 ${s1_addr}:${s1_port}
114 server srv2_h2_2 ${s2_addr}:${s2_port}
Willy Tarreaufae9a4c2021-01-06 09:20:22 +0100115 server s_no_addr_2 unresolvable2.addr.local init-addr none
Thayne McCombs23cc52d2020-12-19 00:59:35 -0700116
117 frontend fe
118 acl acl_be1 path_beg /be1
119 acl acl_be2 path_beg /be2
120 use_backend be1 if acl_be1
121 use_backend be2 if acl_be2
122 bind "fd@${fe}"
123} -start
124
125delay 0.2
126
127client cx -connect ${h1_fe_sock} {
128 txreq -url "/be1?client=c1"
129 rxresp
130 expect resp.status == 200
131 expect resp.http.Server ~ s1
132} -repeat 2 -run
133
134haproxy h1 -cli {
135 send "show table mypeers/mytable"
136 expect ~ .*
137}
138
139haproxy h2 -cli {
140 send "show table mypeers/mytable"
141 expect ~ .*
142}
143
144client cy -connect ${h1_fe_sock} {
145 txreq -url "/be2?client=c1"
146 rxresp
147 expect resp.status == 200
148 expect resp.http.Server ~ s1
149} -repeat 2 -run
150
151haproxy h1 -cli {
152 send "show table mypeers/mytable"
153 expect ~ .*
154}
155
156haproxy h2 -cli {
157 send "show table mypeers/mytable"
158 expect ~ .*
159}
160
161client cx -connect ${h2_fe_sock} {
162 txreq -url "/be1?client=c1"
163 rxresp
164 expect resp.status == 200
165 expect resp.http.Server ~ s1
166} -repeat 2 -run
167
168haproxy h1 -cli {
169 send "show table mypeers/mytable"
170 expect ~ .*
171}
172
173haproxy h2 -cli {
174 send "show table mypeers/mytable"
175 expect ~ .*
176}
177
178client cy -connect ${h2_fe_sock} {
179 txreq -url "/be2?client=c1"
180 rxresp
181 expect resp.status == 200
182 expect resp.http.Server ~ s1
183} -repeat 2 -run
184
185haproxy h1 -cli {
186 send "show table mypeers/mytable"
187 expect ~ .*
188}
189
190haproxy h2 -cli {
191 send "show table mypeers/mytable"
192 expect ~ .*
193}
194
195client cX -connect ${h1_fe_sock} {
196 txreq -url "/be1?client=c2"
197 rxresp
198 expect resp.status == 200
199 expect resp.http.Server ~ s2
200} -repeat 2 -run
201
202haproxy h1 -cli {
203 send "show table mypeers/mytable"
204 expect ~ .*
205}
206
207haproxy h2 -cli {
208 send "show table mypeers/mytable"
209 expect ~ .*
210}
211
212client cY -connect ${h1_fe_sock} {
213 txreq -url "/be2?client=c2"
214 rxresp
215 expect resp.status == 200
216 expect resp.http.Server ~ s2
217} -repeat 2 -run
218
219haproxy h1 -cli {
220 send "show table mypeers/mytable"
221 expect ~ .*
222}
223
224haproxy h2 -cli {
225 send "show table mypeers/mytable"
226 expect ~ .*
227}
228
229client cX -connect ${h2_fe_sock} {
230 txreq -url "/be1?client=c2"
231 rxresp
232 expect resp.status == 200
233 expect resp.http.Server ~ s2
234} -repeat 2 -run
235
236haproxy h1 -cli {
237 send "show table mypeers/mytable"
238 expect ~ .*
239}
240
241haproxy h2 -cli {
242 send "show table mypeers/mytable"
243 expect ~ .*
244}
245
246client cY -connect ${h2_fe_sock} {
247 txreq -url "/be2?client=c2"
248 rxresp
249 expect resp.status == 200
250 expect resp.http.Server ~ s2
251} -repeat 2 -run
252
253haproxy h1 -cli {
254 send "show table mypeers/mytable"
255 expect ~ .*
256}
257
258haproxy h2 -cli {
259 send "show table mypeers/mytable"
260 expect ~ .*
261}
262