Thayne McCombs | 23cc52d | 2020-12-19 00:59:35 -0700 | [diff] [blame] | 1 | vtest "A reg test for stickiness with srvkey addr" |
| 2 | feature 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 | |
| 11 | server s_not_used_1 {} |
| 12 | server s_not_used_2 {} |
| 13 | server s_not_used_3 {} |
| 14 | server s_not_used_4 {} |
| 15 | server s_not_used_5 {} |
| 16 | server s_not_used_6 {} |
| 17 | server s_not_used_7 {} |
| 18 | server s_not_used_8 {} |
| 19 | server s_not_used_9 {} |
| 20 | server s_not_used_10 {} |
| 21 | server s_not_used_11 {} |
| 22 | server s_not_used_12 {} |
| 23 | |
| 24 | # h1/be1 servers |
| 25 | server s1 { |
| 26 | rxreq |
| 27 | txresp -hdr "Server: s1" |
| 28 | } -repeat 8 -start |
| 29 | |
| 30 | server s2 { |
| 31 | rxreq |
| 32 | txresp -hdr "Server: s2" |
| 33 | } -repeat 8 -start |
| 34 | |
| 35 | haproxy h1 -arg "-L A" -conf { |
| 36 | defaults |
| 37 | mode http |
Thayne McCombs | 23cc52d | 2020-12-19 00:59:35 -0700 | [diff] [blame] | 38 | timeout server 1s |
| 39 | timeout connect 1s |
| 40 | timeout client 1s |
| 41 | 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 Tarreau | fae9a4c | 2021-01-06 09:20:22 +0100 | [diff] [blame] | 66 | server s_no_addr_1 unresolvable1.addr.local init-addr none |
Thayne McCombs | 23cc52d | 2020-12-19 00:59:35 -0700 | [diff] [blame] | 67 | |
| 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 | |
| 76 | haproxy h2 -arg "-L B" -conf { |
| 77 | defaults |
| 78 | mode http |
Thayne McCombs | 23cc52d | 2020-12-19 00:59:35 -0700 | [diff] [blame] | 79 | timeout server 1s |
| 80 | timeout connect 1s |
| 81 | timeout client 1s |
| 82 | |
| 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 Tarreau | fae9a4c | 2021-01-06 09:20:22 +0100 | [diff] [blame] | 100 | server s_no_addr_1 unresolvable1.addr.local init-addr none |
Thayne McCombs | 23cc52d | 2020-12-19 00:59:35 -0700 | [diff] [blame] | 101 | |
| 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 Tarreau | fae9a4c | 2021-01-06 09:20:22 +0100 | [diff] [blame] | 113 | server s_no_addr_2 unresolvable2.addr.local init-addr none |
Thayne McCombs | 23cc52d | 2020-12-19 00:59:35 -0700 | [diff] [blame] | 114 | |
| 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 | |
| 123 | delay 0.2 |
| 124 | |
| 125 | client 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 | |
| 132 | haproxy h1 -cli { |
| 133 | send "show table mypeers/mytable" |
| 134 | expect ~ .* |
| 135 | } |
| 136 | |
| 137 | haproxy h2 -cli { |
| 138 | send "show table mypeers/mytable" |
| 139 | expect ~ .* |
| 140 | } |
| 141 | |
| 142 | client 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 | |
| 149 | haproxy h1 -cli { |
| 150 | send "show table mypeers/mytable" |
| 151 | expect ~ .* |
| 152 | } |
| 153 | |
| 154 | haproxy h2 -cli { |
| 155 | send "show table mypeers/mytable" |
| 156 | expect ~ .* |
| 157 | } |
| 158 | |
| 159 | client 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 | |
| 166 | haproxy h1 -cli { |
| 167 | send "show table mypeers/mytable" |
| 168 | expect ~ .* |
| 169 | } |
| 170 | |
| 171 | haproxy h2 -cli { |
| 172 | send "show table mypeers/mytable" |
| 173 | expect ~ .* |
| 174 | } |
| 175 | |
| 176 | client 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 | |
| 183 | haproxy h1 -cli { |
| 184 | send "show table mypeers/mytable" |
| 185 | expect ~ .* |
| 186 | } |
| 187 | |
| 188 | haproxy h2 -cli { |
| 189 | send "show table mypeers/mytable" |
| 190 | expect ~ .* |
| 191 | } |
| 192 | |
| 193 | client 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 | |
| 200 | haproxy h1 -cli { |
| 201 | send "show table mypeers/mytable" |
| 202 | expect ~ .* |
| 203 | } |
| 204 | |
| 205 | haproxy h2 -cli { |
| 206 | send "show table mypeers/mytable" |
| 207 | expect ~ .* |
| 208 | } |
| 209 | |
| 210 | client 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 | |
| 217 | haproxy h1 -cli { |
| 218 | send "show table mypeers/mytable" |
| 219 | expect ~ .* |
| 220 | } |
| 221 | |
| 222 | haproxy h2 -cli { |
| 223 | send "show table mypeers/mytable" |
| 224 | expect ~ .* |
| 225 | } |
| 226 | |
| 227 | client 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 | |
| 234 | haproxy h1 -cli { |
| 235 | send "show table mypeers/mytable" |
| 236 | expect ~ .* |
| 237 | } |
| 238 | |
| 239 | haproxy h2 -cli { |
| 240 | send "show table mypeers/mytable" |
| 241 | expect ~ .* |
| 242 | } |
| 243 | |
| 244 | client 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 | |
| 251 | haproxy h1 -cli { |
| 252 | send "show table mypeers/mytable" |
| 253 | expect ~ .* |
| 254 | } |
| 255 | |
| 256 | haproxy h2 -cli { |
| 257 | send "show table mypeers/mytable" |
| 258 | expect ~ .* |
| 259 | } |
| 260 | |