Christopher Faulet | e41b497 | 2021-10-13 18:06:55 +0200 | [diff] [blame] | 1 | varnishtest "Test declaration of TCP rules in default sections" |
| 2 | |
Tim Duesterhus | 41922af | 2021-11-04 21:12:14 +0100 | [diff] [blame^] | 3 | feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'" |
Christopher Faulet | e41b497 | 2021-10-13 18:06:55 +0200 | [diff] [blame] | 4 | feature ignore_unknown_macro |
| 5 | |
| 6 | server s1 { |
| 7 | rxreq |
| 8 | txresp |
| 9 | expect req.http.x-test1-frt == "def_front" |
| 10 | expect req.http.x-test1-bck == "def_back" |
| 11 | } -start |
| 12 | |
| 13 | haproxy h1 -conf { |
| 14 | defaults common |
| 15 | mode http |
| 16 | timeout connect 1s |
| 17 | timeout client 1s |
| 18 | timeout server 1s |
| 19 | |
| 20 | defaults def_front from common |
| 21 | tcp-request connection accept |
| 22 | tcp-request session accept |
| 23 | tcp-request inspect-delay 5s |
| 24 | tcp-request content set-var(txn.test1) "str(def_front)" |
| 25 | tcp-request content accept |
| 26 | |
| 27 | defaults def_back from common |
| 28 | tcp-request inspect-delay 5s |
| 29 | tcp-request content set-var(txn.test1) "str(def_back)" |
| 30 | tcp-request content accept |
| 31 | |
| 32 | tcp-response inspect-delay 5s |
| 33 | tcp-response content set-var(txn.test2) "str(def_back)" |
| 34 | tcp-response content accept |
| 35 | |
| 36 | frontend fe from def_front |
| 37 | bind "fd@${feh1}" |
| 38 | tcp-request connection reject |
| 39 | tcp-request session reject |
| 40 | tcp-request content reject |
| 41 | |
| 42 | http-request set-header x-test1-frt "%[var(txn.test1)]" |
| 43 | |
| 44 | default_backend be |
| 45 | |
| 46 | backend be from def_back |
| 47 | tcp-response content reject |
| 48 | |
| 49 | http-request set-header x-test1-bck "%[var(txn.test1)]" |
| 50 | http-response set-header x-test2 "%[var(txn.test2)]" |
| 51 | |
| 52 | server s1 ${s1_addr}:${s1_port} |
| 53 | |
| 54 | } -start |
| 55 | |
| 56 | client c1 -connect ${h1_feh1_sock} { |
| 57 | txreq -req GET -url / |
| 58 | rxresp |
| 59 | expect resp.status == 200 |
| 60 | expect resp.http.x-test2 == "def_back" |
| 61 | } -run |