vkill | 1dfd165 | 2019-10-30 16:58:14 +0800 | [diff] [blame] | 1 | varnishtest "srv_name sample fetche Test" |
| 2 | |
| 3 | #REQUIRE_VERSION=2.1 |
| 4 | |
| 5 | feature ignore_unknown_macro |
| 6 | |
| 7 | server s1 { |
| 8 | rxreq |
| 9 | txresp |
| 10 | } -start |
| 11 | |
| 12 | server s2 { |
| 13 | rxreq |
| 14 | txresp |
| 15 | } -start |
| 16 | |
| 17 | haproxy h1 -conf { |
| 18 | defaults |
| 19 | mode http |
| 20 | timeout connect 1s |
| 21 | timeout client 1s |
| 22 | timeout server 1s |
| 23 | |
| 24 | frontend fe |
| 25 | bind "fd@${fe}" |
| 26 | http-response set-header srv-id "%[srv_id]" |
| 27 | http-response set-header srv-name "%[srv_name]" |
| 28 | default_backend be |
| 29 | |
| 30 | backend be |
| 31 | server srv1 ${s1_addr}:${s1_port} |
| 32 | server srv2 ${s2_addr}:${s2_port} |
| 33 | } -start |
| 34 | |
| 35 | client c1 -connect ${h1_fe_sock} { |
| 36 | txreq -url "/" |
| 37 | rxresp |
| 38 | expect resp.status == 200 |
| 39 | expect resp.http.srv-id == "1" |
| 40 | expect resp.http.srv-name == "srv1" |
| 41 | txreq -url "/" |
| 42 | rxresp |
| 43 | expect resp.status == 200 |
| 44 | expect resp.http.srv-id == "2" |
| 45 | expect resp.http.srv-name == "srv2" |
| 46 | } -run |