blob: a4e016f5dd00c8007aaf9f094ff2685a11f5787f [file] [log] [blame]
Frédéric Lécaille1fda2192019-05-23 16:13:16 +02001vtest "A reg test for stickiness"
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.0
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: be1/s1"
28} -repeat 2 -start
29
30server s2 {
31 rxreq
32 txresp -hdr "Server: be1/s2"
33} -repeat 2 -start
34
35# h1/be2 servers
36server s3 {
37 rxreq
38 txresp -hdr "Server: be2/s3"
39} -repeat 2 -start
40
41server s4 {
42 rxreq
43 txresp -hdr "Server: be2/s4"
44} -repeat 2 -start
45
46haproxy h1 -arg "-L A" -conf {
47 defaults
48 mode http
Willy Tarreauf6739232021-11-18 17:46:22 +010049 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
50 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
51 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
Frédéric Lécaille1fda2192019-05-23 16:13:16 +020052 log stdout format raw local0 debug
53
54 peers mypeers
55 bind "fd@${A}"
56 server A
57 server B ${h2_B_addr}:${h2_B_port}
58 table mytable type string size 10m
59
60 backend be1
61 balance roundrobin
62 stick on urlp(client) table mypeers/mytable
63 server srv1 ${s1_addr}:${s1_port}
64 server srv2 ${s2_addr}:${s2_port}
65
66 backend be2
67 balance roundrobin
68 stick on urlp(client) table mypeers/mytable
69 server s_not_used_1 ${s_not_used_1_addr}:${s_not_used_1_port}
70 server s_not_used_2 ${s_not_used_2_addr}:${s_not_used_2_port}
71 server s_not_used_3 ${s_not_used_3_addr}:${s_not_used_3_port}
72 server srv2 ${s4_addr}:${s4_port}
73 server s_not_used_4 ${s_not_used_4_addr}:${s_not_used_4_port}
74 server s_not_used_5 ${s_not_used_5_addr}:${s_not_used_5_port}
75 server s_not_used_6 ${s_not_used_6_addr}:${s_not_used_6_port}
76 server srv1 ${s3_addr}:${s3_port}
77
78 frontend fe
79 acl acl_be1 path_beg /be1
80 acl acl_be2 path_beg /be2
81 use_backend be1 if acl_be1
82 use_backend be2 if acl_be2
83 bind "fd@${fe}"
84} -start
85
86# h2/be1 servers
87server s5 {
88 rxreq
89 txresp -hdr "Server: be1/s5"
90} -repeat 2 -start
91
92server s6 {
93 rxreq
94 txresp -hdr "Server: be1/s6"
95} -repeat 2 -start
96
97# h2/be2 servers
98server s7 {
99 rxreq
100 txresp -hdr "Server: be2/s7"
101} -repeat 2 -start
102
103server s8 {
104 rxreq
105 txresp -hdr "Server: be2/s8"
106} -repeat 2 -start
107
108
109haproxy h2 -arg "-L B" -conf {
110 defaults
111 mode http
Willy Tarreauf6739232021-11-18 17:46:22 +0100112 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
113 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
114 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
Frédéric Lécaille1fda2192019-05-23 16:13:16 +0200115
116 peers mypeers
117 bind "fd@${B}"
118 server A ${h1_A_addr}:${h1_A_port}
119 server B
120 table mytable type string size 10m
121
122 backend be1
123 balance roundrobin
124 stick on urlp(client) table mypeers/mytable
125 server s_not_used_7 ${s_not_used_7_addr}:${s_not_used_7_port}
126 server s_not_used_8 ${s_not_used_8_addr}:${s_not_used_8_port}
127 server s_not_used_9 ${s_not_used_9_addr}:${s_not_used_9_port}
128 server srv1 ${s5_addr}:${s5_port}
129 server s_not_used_10 ${s_not_used_10_addr}:${s_not_used_10_port}
130 server s_not_used_11 ${s_not_used_11_addr}:${s_not_used_11_port}
131 server s_not_used_12 ${s_not_used_12_addr}:${s_not_used_12_port}
132 server srv2 ${s6_addr}:${s6_port}
133
134 backend be2
135 balance roundrobin
136 stick on urlp(client) table mypeers/mytable
137 server s_not_used_1 ${s_not_used_1_addr}:${s_not_used_1_port}
138 server s_not_used_2 ${s_not_used_2_addr}:${s_not_used_2_port}
139 server s_not_used_3 ${s_not_used_3_addr}:${s_not_used_3_port}
140 server s_not_used_4 ${s_not_used_4_addr}:${s_not_used_4_port}
141 server s_not_used_5 ${s_not_used_5_addr}:${s_not_used_5_port}
142 server s_not_used_6 ${s_not_used_6_addr}:${s_not_used_6_port}
143 server srv1 ${s7_addr}:${s7_port}
144 server srv2 ${s8_addr}:${s8_port}
145
146 frontend fe
147 acl acl_be1 path_beg /be1
148 acl acl_be2 path_beg /be2
149 use_backend be1 if acl_be1
150 use_backend be2 if acl_be2
151 bind "fd@${fe}"
152} -start
153
154delay 0.2
155
156client cx -connect ${h1_fe_sock} {
157 txreq -url "/be1?client=c1"
158 rxresp
159 expect resp.status == 200
160 expect resp.http.Server ~ be1/s1
161} -repeat 2 -run
162
163haproxy h1 -cli {
164 send "show table mypeers/mytable"
165 expect ~ .*
166}
167
168haproxy h2 -cli {
169 send "show table mypeers/mytable"
170 expect ~ .*
171}
172
173client cy -connect ${h1_fe_sock} {
174 txreq -url "/be2?client=c1"
175 rxresp
176 expect resp.status == 200
177 expect resp.http.Server ~ be2/s3
178} -repeat 2 -run
179
180haproxy h1 -cli {
181 send "show table mypeers/mytable"
182 expect ~ .*
183}
184
185haproxy h2 -cli {
186 send "show table mypeers/mytable"
187 expect ~ .*
188}
189
190client cx -connect ${h2_fe_sock} {
191 txreq -url "/be1?client=c1"
192 rxresp
193 expect resp.status == 200
194 expect resp.http.Server ~ be1/s5
195} -repeat 2 -run
196
197haproxy h1 -cli {
198 send "show table mypeers/mytable"
199 expect ~ .*
200}
201
202haproxy h2 -cli {
203 send "show table mypeers/mytable"
204 expect ~ .*
205}
206
207client cy -connect ${h2_fe_sock} {
208 txreq -url "/be2?client=c1"
209 rxresp
210 expect resp.status == 200
211 expect resp.http.Server ~ be2/s7
212} -repeat 2 -run
213
214haproxy h1 -cli {
215 send "show table mypeers/mytable"
216 expect ~ .*
217}
218
219haproxy h2 -cli {
220 send "show table mypeers/mytable"
221 expect ~ .*
222}
223
224client cX -connect ${h1_fe_sock} {
225 txreq -url "/be1?client=c2"
226 rxresp
227 expect resp.status == 200
228 expect resp.http.Server ~ be1/s2
229} -repeat 2 -run
230
231haproxy h1 -cli {
232 send "show table mypeers/mytable"
233 expect ~ .*
234}
235
236haproxy h2 -cli {
237 send "show table mypeers/mytable"
238 expect ~ .*
239}
240
241client cY -connect ${h1_fe_sock} {
242 txreq -url "/be2?client=c2"
243 rxresp
244 expect resp.status == 200
245 expect resp.http.Server ~ be2/s4
246} -repeat 2 -run
247
248haproxy h1 -cli {
249 send "show table mypeers/mytable"
250 expect ~ .*
251}
252
253haproxy h2 -cli {
254 send "show table mypeers/mytable"
255 expect ~ .*
256}
257
258client cX -connect ${h2_fe_sock} {
259 txreq -url "/be1?client=c2"
260 rxresp
261 expect resp.status == 200
262 expect resp.http.Server ~ be1/s6
263} -repeat 2 -run
264
265haproxy h1 -cli {
266 send "show table mypeers/mytable"
267 expect ~ .*
268}
269
270haproxy h2 -cli {
271 send "show table mypeers/mytable"
272 expect ~ .*
273}
274
275client cY -connect ${h2_fe_sock} {
276 txreq -url "/be2?client=c2"
277 rxresp
278 expect resp.status == 200
279 expect resp.http.Server ~ be2/s8
280} -repeat 2 -run
281
282haproxy h1 -cli {
283 send "show table mypeers/mytable"
284 expect ~ .*
285}
286
287haproxy h2 -cli {
288 send "show table mypeers/mytable"
289 expect ~ .*
290}
291