|
| 1 | +varnishtest "X-Magento-Cache-Debug header" |
| 2 | + |
| 3 | +server s1 { |
| 4 | + # first request will be the probe, handle it and be on our way |
| 5 | + rxreq |
| 6 | + expect req.url == "/health_check.php" |
| 7 | + txresp |
| 8 | + |
| 9 | + # the probe expects the connection to close |
| 10 | + close |
| 11 | + accept |
| 12 | + |
| 13 | + rxreq |
| 14 | + txresp -hdr "answer-to: POST" |
| 15 | + |
| 16 | + rxreq |
| 17 | + txresp -hdr "answer-to: GET" |
| 18 | +} -start |
| 19 | + |
| 20 | +# generate usable VCL pointing towards s1 |
| 21 | +# mostly, we replace the place-holders, but we also jack up the probe |
| 22 | +# interval to avoid further interference |
| 23 | +shell { |
| 24 | + # testdir is automatically set to the directory containing the present vtc |
| 25 | + sed \ |
| 26 | + -e 's@\.interval = 5s;@.interval = 5m; .initial = 10;@' \ |
| 27 | + -e 's@/\* {{ host }} \*/@${s1_addr}@' \ |
| 28 | + -e 's@/\* {{ port }} \*/@${s1_port}@' \ |
| 29 | + -e 's@/\* {{ ssl_offloaded_header }} \*/@unused@' \ |
| 30 | + -e 's@/\* {{ grace_period }} \*/@0@' \ |
| 31 | + ${testdir}/../../../app/code/Magento/PageCache/etc/varnish6.vcl > ${tmpdir}/output.vcl |
| 32 | +} |
| 33 | + |
| 34 | +varnish v1 -arg "-f" -arg "${tmpdir}/output.vcl" -start |
| 35 | + |
| 36 | +# make surethe probe request fired |
| 37 | +delay 1 |
| 38 | + |
| 39 | +client c1 { |
| 40 | + txreq -method "POST" |
| 41 | + rxresp |
| 42 | + expect resp.http.answer-to == "POST" |
| 43 | + expect resp.http.X-Magento-Cache-Debug == "UNCACHEABLE" |
| 44 | + |
| 45 | + txreq |
| 46 | + rxresp |
| 47 | + expect resp.http.answer-to == "GET" |
| 48 | + expect resp.http.X-Magento-Cache-Debug == "MISS" |
| 49 | + |
| 50 | + txreq |
| 51 | + rxresp |
| 52 | + expect resp.http.answer-to == "GET" |
| 53 | + expect resp.http.X-Magento-Cache-Debug == "HIT" |
| 54 | +} -run |
0 commit comments