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