[4.1] a8dc87802 Test case that shows return(abandon) to avoid cache insertion
PÃ¥l Hermunn Johansen
hermunn at varnish-software.com
Thu Sep 13 13:03:12 UTC 2018
commit a8dc87802fa83ec64eb762bce2a1107af09b7d6b
Author: Pål Hermunn Johansen <hermunn at varnish-software.com>
Date: Fri Jun 15 10:54:48 2018 +0200
Test case that shows return(abandon) to avoid cache insertion
diff --git a/bin/varnishtest/tests/b00063.vtc b/bin/varnishtest/tests/b00063.vtc
new file mode 100644
index 000000000..1adfe2680
--- /dev/null
+++ b/bin/varnishtest/tests/b00063.vtc
@@ -0,0 +1,90 @@
+varnishtest "Abandon background fetch when backend serves 5xx"
+
+barrier b1 cond 2
+barrier b2 cond 3
+
+server s1 {
+ # This is what we want to get to all client requests below
+ rxreq
+ expect req.url == "/1"
+ txresp -body "1"
+
+ # 503s will be abandoned when we have a bgfetch
+ rxreq
+ expect req.url == "/1"
+ txresp -status 503 -body "2"
+
+ # varnish will disconnect on a 503
+ accept
+ rxreq
+ expect req.url == "/1"
+ # wait until varnish has delivered 200 before replying
+ # with the 404
+ barrier b2 sync
+ delay .1
+ # this response will not be abandoned
+ txresp -status 404 -reason "Not Found" -body "3"
+
+ # some other resource at the end
+ rxreq
+ expect req.url == "/2"
+ txresp -body "4"
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_backend_response {
+ if (beresp.status >= 500 && bereq.is_bgfetch) {
+ return (abandon);
+ }
+ if (beresp.status >= 400) {
+ set beresp.ttl = 1m;
+ } else {
+ set beresp.ttl = 1ms;
+ }
+ set beresp.grace = 1m;
+ }
+} -start
+
+client c1 {
+ txreq -url "/1"
+ rxresp
+ expect resp.status == 200
+ expect resp.body == "1"
+ delay .2
+ txreq -url "/1"
+ rxresp
+ expect resp.status == 200
+ expect resp.body == "1"
+ delay .2
+ barrier b1 sync
+ txreq -url "/1"
+ rxresp
+ expect resp.status == 200
+ expect resp.body == "1"
+ barrier b2 sync
+} -start
+
+client c2 {
+ barrier b1 sync
+ txreq -url "/1"
+ rxresp
+ expect resp.status == 200
+ expect resp.body == "1"
+ barrier b2 sync
+} -start
+
+client c1 -wait
+client c2 -wait
+
+client c3 {
+ delay .1
+ # We should now get a HIT on the 404:
+ txreq -url "/1"
+ rxresp
+ expect resp.status == 404
+ expect resp.body == "3"
+ # do a different resource to make sure we got the right number of reqs to /1
+ txreq -url "/2"
+ rxresp
+ expect resp.body == "4"
+} -run
More information about the varnish-commit
mailing list