Willy Tarreau | 0657b93 | 2022-03-09 17:33:05 +0100 | [diff] [blame] | 1 | varnishtest "Verify logging of last final rule" |
Willy Tarreau | 0657b93 | 2022-03-09 17:33:05 +0100 | [diff] [blame] | 2 | |
Tim Duesterhus | fbbbc33 | 2022-03-11 22:46:16 +0100 | [diff] [blame] | 3 | feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.6-dev0)'" |
| 4 | feature ignore_unknown_macro |
Willy Tarreau | 0657b93 | 2022-03-09 17:33:05 +0100 | [diff] [blame] | 5 | |
| 6 | server s1 { |
| 7 | rxreq |
| 8 | txresp |
| 9 | } -repeat 15 -start |
| 10 | |
| 11 | syslog Slg_1 -level info { |
| 12 | recv |
| 13 | # /trqacc1 |
| 14 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:30" |
| 15 | recv |
| 16 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:31" |
| 17 | recv |
| 18 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:32" |
| 19 | recv |
| 20 | # /trsacc1 |
| 21 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:36" |
| 22 | recv |
| 23 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:37" |
| 24 | recv |
| 25 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:38" |
| 26 | recv |
| 27 | # /hrqvar |
| 28 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*-:-" |
| 29 | recv |
| 30 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:41" |
| 31 | recv |
| 32 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:42" |
| 33 | recv |
| 34 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:43" |
| 35 | recv |
| 36 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:44" |
| 37 | recv |
| 38 | # /hrsacc1 |
| 39 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:46" |
| 40 | recv |
| 41 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:47" |
| 42 | recv |
| 43 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:48" |
| 44 | recv |
| 45 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:49" |
| 46 | } -start |
| 47 | |
| 48 | haproxy h1 -conf { |
| 49 | global |
| 50 | nbthread 1 |
| 51 | |
| 52 | defaults |
| 53 | mode http |
| 54 | option httplog |
| 55 | option http-server-close |
| 56 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 57 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 58 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
| 59 | |
| 60 | frontend fe1 |
| 61 | bind "fd@${fe_1}" |
| 62 | log ${Slg_1_addr}:${Slg_1_port} local0 |
| 63 | log-format "ci:%cp [%tr] lr=%[last_rule_file]:%[last_rule_line]" |
| 64 | default_backend be |
| 65 | |
| 66 | backend be |
| 67 | # handle these URLs: |
| 68 | # /trqacc1, /trqrej1, /trqrej2, /trsacc1, /trsrej1, /trsrej2 |
| 69 | # /hrqvar, /hrqacc1, /hrqred1, /hrqrej1, /hrqrej2, |
| 70 | # /hrsacc1, /hrsred1, /hrsrej1, /hrsrej2 |
| 71 | |
| 72 | tcp-response inspect-delay 10s |
| 73 | tcp-request content set-var(txn.path) path # must have no effect |
| 74 | tcp-request content accept if { var(txn.path) -m beg /trqacc1 /hrqrej1 } |
| 75 | tcp-request content reject if { var(txn.path) -m beg /trqrej1 } |
| 76 | tcp-request content reject if { var(txn.path) -m beg /trqrej2 } |
| 77 | |
| 78 | tcp-response content reject unless WAIT_END |
| 79 | tcp-response content set-var(txn.foo) var(txn.path) # must have no effect |
| 80 | tcp-response content accept if { var(txn.path) -m beg /trsacc1 /hrsrej1 } |
| 81 | tcp-response content reject if { var(txn.path) -m beg /trsrej1 } |
| 82 | tcp-response content reject if { var(txn.path) -m beg /trsrej2 } |
| 83 | |
| 84 | http-request set-var(txn.bar) var(txn.path) if { path_beg /hrqvar } # must have no effect |
| 85 | http-request allow if { var(txn.path) -m beg /hrqacc1 /hrsrej2 } |
| 86 | http-request redirect location / if { var(txn.path) -m beg /hrqred1 } |
| 87 | http-request deny if { var(txn.path) -m beg /hrqrej1 } # accepted by tcp-rq above |
| 88 | http-request deny if { var(txn.path) -m beg /hrqrej2 } |
| 89 | |
| 90 | http-response allow if { var(txn.path) -m beg /hrsacc1 } |
| 91 | http-response redirect location / if { var(txn.path) -m beg /hrsred1 } |
| 92 | http-response deny if { var(txn.path) -m beg /hrsrej1 } # accepted by tcp-rs above |
| 93 | http-response deny if { var(txn.path) -m beg /hrsrej2 } # accepted by http-rq above |
| 94 | http-response deny if { var(txn.path) -m beg /hrsrej3 } |
| 95 | |
| 96 | server app1 ${s1_addr}:${s1_port} |
| 97 | } -start |
| 98 | |
| 99 | client c1 -connect ${h1_fe_1_sock} { |
| 100 | txreq -url /trqacc1 |
| 101 | rxresp |
| 102 | |
| 103 | txreq -url /trqrej1 |
| 104 | expect_close |
| 105 | } -run |
| 106 | |
| 107 | # The following client are started in background and synchronized |
| 108 | client c2 -connect ${h1_fe_1_sock} { |
| 109 | txreq -url /trqrej2 |
| 110 | expect_close |
| 111 | } -run |
| 112 | |
| 113 | client c3 -connect ${h1_fe_1_sock} { |
| 114 | txreq -url /trsacc1 |
| 115 | rxresp |
| 116 | expect resp.status == 200 |
| 117 | |
| 118 | txreq -url /trsrej1 |
| 119 | expect_close |
| 120 | } -run |
| 121 | |
| 122 | client c4 -connect ${h1_fe_1_sock} { |
| 123 | txreq -url /trsrej2 |
| 124 | expect_close |
| 125 | } -run |
| 126 | |
| 127 | client c5 -connect ${h1_fe_1_sock} { |
| 128 | txreq -url /hrqvar |
| 129 | rxresp |
| 130 | expect resp.status == 200 |
| 131 | |
| 132 | txreq -url /hrqacc1 |
| 133 | rxresp |
| 134 | expect resp.status == 200 |
| 135 | |
| 136 | txreq -url /hrqred1 |
| 137 | rxresp |
| 138 | expect resp.status == 302 |
| 139 | |
| 140 | txreq -url /hrqrej1 |
| 141 | rxresp |
| 142 | expect resp.status == 403 |
| 143 | |
| 144 | txreq -url /hrqrej2 |
| 145 | rxresp |
| 146 | expect resp.status == 403 |
| 147 | |
| 148 | txreq -url /hrsacc1 |
| 149 | rxresp |
| 150 | expect resp.status == 200 |
| 151 | |
| 152 | txreq -url /hrsred1 |
| 153 | rxresp |
| 154 | expect resp.status == 302 |
| 155 | |
| 156 | txreq -url /hrsrej1 |
| 157 | rxresp |
| 158 | expect resp.status == 502 |
| 159 | |
| 160 | txreq -url /hrsrej2 |
| 161 | rxresp |
| 162 | expect resp.status == 502 |
| 163 | } -run |
| 164 | |
| 165 | syslog Slg_1 -wait |