Commit b8816994 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Implement fail in vcl_hit{} and vcl_deliver{}

parent 1567375b
......@@ -117,6 +117,9 @@ cnt_deliver(struct worker *wrk, struct req *req)
case VCL_RET_RESTART:
req->req_step = R_STP_RESTART;
break;
case VCL_RET_FAIL:
req->req_step = R_STP_VCLFAIL;
break;
case VCL_RET_SYNTH:
req->req_step = R_STP_SYNTH;
break;
......@@ -474,6 +477,9 @@ cnt_lookup(struct worker *wrk, struct req *req)
case VCL_RET_RESTART:
req->req_step = R_STP_RESTART;
break;
case VCL_RET_FAIL:
req->req_step = R_STP_VCLFAIL;
break;
case VCL_RET_SYNTH:
req->req_step = R_STP_SYNTH;
break;
......
......@@ -232,9 +232,6 @@ logexpect l1 -wait
varnish v1 -vcl+backend {
import debug;
sub vcl_recv {
if (req.http.foo == "miss") { return(hash); }
}
sub vcl_miss {
if (req.http.foo == "miss") {
debug.fail();
......@@ -250,7 +247,7 @@ logexpect l1 -v v1 -g raw {
} -start
client c1 {
txreq -url /x -hdr "foo: miss"
txreq -url /miss -hdr "foo: miss"
rxresp
expect resp.status == 503
expect resp.reason == "VCL failed"
......@@ -260,3 +257,63 @@ varnish v1 -expect sc_vcl_failure == 8
logexpect l1 -wait
#######################################################################
# Fail in vcl_hit
varnish v1 -vcl+backend {
import debug;
sub vcl_hit {
if (req.http.foo == "hit") {
debug.fail();
set req.http.not = "Should not happen";
}
}
}
logexpect l1 -v v1 -g raw {
expect * 1020 VCL_call "HIT"
expect 0 1020 Debug "Forced failure"
expect 0 1020 VCL_return "fail"
} -start
client c1 {
txreq -url /hit -hdr "foo: hit"
rxresp
expect resp.status == 503
expect resp.reason == "VCL failed"
} -run
varnish v1 -expect sc_vcl_failure == 9
logexpect l1 -wait
#######################################################################
# Fail in vcl_deliver
varnish v1 -vcl+backend {
import debug;
sub vcl_deliver {
if (req.http.foo == "deliver") {
debug.fail();
set req.http.not = "Should not happen";
}
}
}
logexpect l1 -v v1 -g raw {
expect * 1022 VCL_call "DELIVER"
expect 0 1022 Debug "Forced failure"
expect 0 1022 VCL_return "fail"
} -start
client c1 {
txreq -url /hit -hdr "foo: deliver"
rxresp
expect resp.status == 503
expect resp.reason == "VCL failed"
} -run
varnish v1 -expect sc_vcl_failure == 10
logexpect l1 -wait
......@@ -114,11 +114,11 @@ returns = (
),
('hit',
"C",
('synth', 'restart', 'pass', 'miss', 'deliver',)
('fail', 'synth', 'restart', 'pass', 'miss', 'deliver',)
),
('deliver',
"C",
('synth', 'restart', 'deliver',)
('fail', 'synth', 'restart', 'deliver',)
),
('synth',
"C",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment