Willy Tarreau | f8462aa | 2020-09-23 09:02:13 +0200 | [diff] [blame] | 1 | vtest "Test for balance URI" |
| 2 | feature ignore_unknown_macro |
| 3 | #REQUIRE_VERSION=2.1 |
| 4 | |
| 5 | server s1 { |
| 6 | rxreq |
| 7 | txresp -hdr "Server: s1" -body "s1" |
| 8 | } -repeat 5 -start |
| 9 | |
| 10 | server s2 { |
| 11 | rxreq |
| 12 | txresp -hdr "Server: s2" -body "s2" |
| 13 | } -repeat 5 -start |
| 14 | |
| 15 | server s3 { |
| 16 | rxreq |
| 17 | txresp -hdr "Server: s3" -body "s3" |
| 18 | } -repeat 5 -start |
| 19 | |
| 20 | server s4 { |
| 21 | rxreq |
| 22 | txresp -hdr "Server: s4" -body "s4" |
| 23 | } -repeat 5 -start |
| 24 | |
| 25 | haproxy h1 -arg "-L A" -conf { |
| 26 | defaults |
| 27 | mode http |
| 28 | timeout server 1s |
| 29 | timeout connect 1s |
| 30 | timeout client 1s |
| 31 | |
| 32 | listen px |
| 33 | bind "fd@${px}" |
| 34 | bind "fd@${pxh2}" proto h2 |
| 35 | balance uri path-only |
| 36 | server srv1 ${s1_addr}:${s1_port} |
| 37 | server srv2 ${s2_addr}:${s2_port} |
| 38 | server srv3 ${s3_addr}:${s3_port} |
| 39 | server srv4 ${s4_addr}:${s4_port} |
| 40 | } -start |
| 41 | |
| 42 | client c1 -connect ${h1_px_sock} { |
Willy Tarreau | 6b659cd | 2020-09-29 09:58:23 +0200 | [diff] [blame] | 43 | txreq -url "http://127.0.0.1/url1" |
Willy Tarreau | f8462aa | 2020-09-23 09:02:13 +0200 | [diff] [blame] | 44 | rxresp |
| 45 | expect resp.status == 200 |
| 46 | expect resp.http.Server ~ s2 |
| 47 | } -run |
| 48 | |
| 49 | client c2 -connect ${h1_px_sock} { |
| 50 | txreq -url "/url1?ignore=this-arg" |
| 51 | rxresp |
| 52 | expect resp.status == 200 |
| 53 | expect resp.http.Server ~ s2 |
| 54 | } -run |
| 55 | |
| 56 | client c3 -connect ${h1_px_sock} { |
Willy Tarreau | 6b659cd | 2020-09-29 09:58:23 +0200 | [diff] [blame] | 57 | txreq -url "http://127.0.0.1/url2" |
Willy Tarreau | f8462aa | 2020-09-23 09:02:13 +0200 | [diff] [blame] | 58 | rxresp |
| 59 | expect resp.status == 200 |
| 60 | expect resp.http.Server ~ s3 |
| 61 | } -run |
| 62 | |
| 63 | client c4 -connect ${h1_px_sock} { |
| 64 | txreq -url "/url3" |
| 65 | rxresp |
| 66 | expect resp.status == 200 |
| 67 | expect resp.http.Server ~ s4 |
| 68 | } -run |
| 69 | |
| 70 | client c5 -connect ${h1_px_sock} { |
| 71 | txreq -url "/url4" |
| 72 | rxresp |
| 73 | expect resp.status == 200 |
| 74 | expect resp.http.Server ~ s1 |
| 75 | } -run |
| 76 | |
| 77 | client c6h2 -connect ${h1_pxh2_sock} { |
| 78 | txpri |
| 79 | stream 0 { |
| 80 | txsettings |
| 81 | rxsettings |
| 82 | txsettings -ack |
| 83 | rxsettings |
| 84 | expect settings.ack == true |
| 85 | } -run |
| 86 | |
| 87 | stream 1 { |
| 88 | txreq \ |
| 89 | -req "GET" \ |
| 90 | -scheme "https" \ |
| 91 | -url "/url1" |
| 92 | rxhdrs |
| 93 | expect resp.status == 200 |
| 94 | rxdata -all |
| 95 | expect resp.body == "s2" |
| 96 | } -run |
| 97 | } -run |