blob: 99a4d8b71fe6eead1e89e32f7a190e0fc7165230 [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
Willy Tarreauf6739232021-11-18 17:46:22 +010038 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
39 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
40 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
Thayne McCombs23cc52d2020-12-19 00:59:35 -070041 log stdout format raw local0 debug
42
43 peers mypeers
44 bind "fd@${A}"
45 server A
46 server B ${h2_B_addr}:${h2_B_port}
47 table mytable type string size 10m srvkey addr
48
49 backend be1
50 balance roundrobin
51 stick on urlp(client) table mypeers/mytable
52 server srv1 ${s1_addr}:${s1_port}
53 server srv2 ${s2_addr}:${s2_port}
54
55 backend be2
56 balance roundrobin
57 stick on urlp(client) table mypeers/mytable
58 server s_not_used_1 ${s_not_used_1_addr}:${s_not_used_1_port}
59 server s_not_used_2 ${s_not_used_2_addr}:${s_not_used_2_port}
60 server s_not_used_3 ${s_not_used_3_addr}:${s_not_used_3_port}
61 server srv2_2 ${s2_addr}:${s2_port}
62 server s_not_used_4 ${s_not_used_4_addr}:${s_not_used_4_port}
63 server s_not_used_5 ${s_not_used_5_addr}:${s_not_used_5_port}
64 server s_not_used_6 ${s_not_used_6_addr}:${s_not_used_6_port}
65 server srv1_2 ${s1_addr}:${s1_port}
Willy Tarreaufae9a4c2021-01-06 09:20:22 +010066 server s_no_addr_1 unresolvable1.addr.local init-addr none
Thayne McCombs23cc52d2020-12-19 00:59:35 -070067
68 frontend fe
69 acl acl_be1 path_beg /be1
70 acl acl_be2 path_beg /be2
71 use_backend be1 if acl_be1
72 use_backend be2 if acl_be2
73 bind "fd@${fe}"
74} -start
75
76haproxy h2 -arg "-L B" -conf {
77 defaults
78 mode http
Willy Tarreauf6739232021-11-18 17:46:22 +010079 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
80 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
81 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
Thayne McCombs23cc52d2020-12-19 00:59:35 -070082
83 peers mypeers
84 bind "fd@${B}"
85 server A ${h1_A_addr}:${h1_A_port}
86 server B
87 table mytable type string size 10m srvkey addr
88
89 backend be1
90 balance roundrobin
91 stick on urlp(client) table mypeers/mytable
92 server s_not_used_7 ${s_not_used_7_addr}:${s_not_used_7_port}
93 server s_not_used_8 ${s_not_used_8_addr}:${s_not_used_8_port}
94 server s_not_used_9 ${s_not_used_9_addr}:${s_not_used_9_port}
95 server srv1_h2_1 ${s1_addr}:${s1_port}
96 server s_not_used_10 ${s_not_used_10_addr}:${s_not_used_10_port}
97 server s_not_used_11 ${s_not_used_11_addr}:${s_not_used_11_port}
98 server s_not_used_12 ${s_not_used_12_addr}:${s_not_used_12_port}
99 server srv2_h2_1 ${s2_addr}:${s2_port}
Willy Tarreaufae9a4c2021-01-06 09:20:22 +0100100 server s_no_addr_1 unresolvable1.addr.local init-addr none
Thayne McCombs23cc52d2020-12-19 00:59:35 -0700101
102 backend be2
103 balance roundrobin
104 stick on urlp(client) table mypeers/mytable
105 server s_not_used_1 ${s_not_used_1_addr}:${s_not_used_1_port}
106 server s_not_used_2 ${s_not_used_2_addr}:${s_not_used_2_port}
107 server s_not_used_3 ${s_not_used_3_addr}:${s_not_used_3_port}
108 server s_not_used_4 ${s_not_used_4_addr}:${s_not_used_4_port}
109 server s_not_used_5 ${s_not_used_5_addr}:${s_not_used_5_port}
110 server s_not_used_6 ${s_not_used_6_addr}:${s_not_used_6_port}
111 server srv1_h2_2 ${s1_addr}:${s1_port}
112 server srv2_h2_2 ${s2_addr}:${s2_port}
Willy Tarreaufae9a4c2021-01-06 09:20:22 +0100113 server s_no_addr_2 unresolvable2.addr.local init-addr none
Thayne McCombs23cc52d2020-12-19 00:59:35 -0700114
115 frontend fe
116 acl acl_be1 path_beg /be1
117 acl acl_be2 path_beg /be2
118 use_backend be1 if acl_be1
119 use_backend be2 if acl_be2
120 bind "fd@${fe}"
121} -start
122
123delay 0.2
124
125client cx -connect ${h1_fe_sock} {
126 txreq -url "/be1?client=c1"
127 rxresp
128 expect resp.status == 200
129 expect resp.http.Server ~ s1
130} -repeat 2 -run
131
132haproxy h1 -cli {
133 send "show table mypeers/mytable"
134 expect ~ .*
135}
136
137haproxy h2 -cli {
138 send "show table mypeers/mytable"
139 expect ~ .*
140}
141
142client cy -connect ${h1_fe_sock} {
143 txreq -url "/be2?client=c1"
144 rxresp
145 expect resp.status == 200
146 expect resp.http.Server ~ s1
147} -repeat 2 -run
148
149haproxy h1 -cli {
150 send "show table mypeers/mytable"
151 expect ~ .*
152}
153
154haproxy h2 -cli {
155 send "show table mypeers/mytable"
156 expect ~ .*
157}
158
159client cx -connect ${h2_fe_sock} {
160 txreq -url "/be1?client=c1"
161 rxresp
162 expect resp.status == 200
163 expect resp.http.Server ~ s1
164} -repeat 2 -run
165
166haproxy h1 -cli {
167 send "show table mypeers/mytable"
168 expect ~ .*
169}
170
171haproxy h2 -cli {
172 send "show table mypeers/mytable"
173 expect ~ .*
174}
175
176client cy -connect ${h2_fe_sock} {
177 txreq -url "/be2?client=c1"
178 rxresp
179 expect resp.status == 200
180 expect resp.http.Server ~ s1
181} -repeat 2 -run
182
183haproxy h1 -cli {
184 send "show table mypeers/mytable"
185 expect ~ .*
186}
187
188haproxy h2 -cli {
189 send "show table mypeers/mytable"
190 expect ~ .*
191}
192
193client cX -connect ${h1_fe_sock} {
194 txreq -url "/be1?client=c2"
195 rxresp
196 expect resp.status == 200
197 expect resp.http.Server ~ s2
198} -repeat 2 -run
199
200haproxy h1 -cli {
201 send "show table mypeers/mytable"
202 expect ~ .*
203}
204
205haproxy h2 -cli {
206 send "show table mypeers/mytable"
207 expect ~ .*
208}
209
210client cY -connect ${h1_fe_sock} {
211 txreq -url "/be2?client=c2"
212 rxresp
213 expect resp.status == 200
214 expect resp.http.Server ~ s2
215} -repeat 2 -run
216
217haproxy h1 -cli {
218 send "show table mypeers/mytable"
219 expect ~ .*
220}
221
222haproxy h2 -cli {
223 send "show table mypeers/mytable"
224 expect ~ .*
225}
226
227client cX -connect ${h2_fe_sock} {
228 txreq -url "/be1?client=c2"
229 rxresp
230 expect resp.status == 200
231 expect resp.http.Server ~ s2
232} -repeat 2 -run
233
234haproxy h1 -cli {
235 send "show table mypeers/mytable"
236 expect ~ .*
237}
238
239haproxy h2 -cli {
240 send "show table mypeers/mytable"
241 expect ~ .*
242}
243
244client cY -connect ${h2_fe_sock} {
245 txreq -url "/be2?client=c2"
246 rxresp
247 expect resp.status == 200
248 expect resp.http.Server ~ s2
249} -repeat 2 -run
250
251haproxy h1 -cli {
252 send "show table mypeers/mytable"
253 expect ~ .*
254}
255
256haproxy h2 -cli {
257 send "show table mypeers/mytable"
258 expect ~ .*
259}
260