-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
varnishncsa: Add hitmiss hitpass indicators to Varnish:handling
- Loading branch information
Showing
4 changed files
with
109 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
varnishtest "varnishncsa handling" | ||
|
||
server s1 { | ||
rxreq | ||
txresp | ||
rxreq | ||
txresp | ||
} -start | ||
|
||
varnish v1 -vcl+backend { | ||
backend none none; | ||
|
||
sub vcl_backend_fetch { | ||
# XXX would like to do everything in v_b_e, but | ||
# return(pass(x)) is not supported | ||
if (bereq.url == "/hitpass") { | ||
set bereq.backend = s1; | ||
} else { | ||
set bereq.backend = none; | ||
} | ||
} | ||
|
||
sub vcl_backend_response { | ||
set beresp.ttl = 1y; | ||
return (pass(1y)); | ||
} | ||
|
||
sub vcl_backend_error { | ||
set beresp.status = 200; | ||
set beresp.ttl = 1y; | ||
set beresp.body = bereq.url; | ||
if (bereq.url == "/hitmiss") { | ||
set beresp.uncacheable = true; | ||
} | ||
return (deliver); | ||
} | ||
|
||
sub vcl_recv { | ||
if (req.url == "/pass") { | ||
return (pass); | ||
} | ||
if (req.url == "/synth") { | ||
return (synth(204)); | ||
} | ||
} | ||
} -start | ||
|
||
client c1 { | ||
# prime | ||
txreq -url "/hitmiss" | ||
rxresp | ||
expect resp.status == 200 | ||
txreq -url "/hitpass" | ||
rxresp | ||
expect resp.status == 200 | ||
txreq -url "/hit" | ||
rxresp | ||
expect resp.status == 200 | ||
|
||
# re-check | ||
txreq -url "/hitmiss" | ||
rxresp | ||
expect resp.status == 200 | ||
txreq -url "/hitpass" | ||
rxresp | ||
expect resp.status == 200 | ||
txreq -url "/hit" | ||
rxresp | ||
expect resp.status == 200 | ||
|
||
# others | ||
txreq -url "/pass" | ||
rxresp | ||
expect resp.status == 200 | ||
txreq -url "/synth" | ||
rxresp | ||
expect resp.status == 204 | ||
} -run | ||
|
||
shell { | ||
cat <<EOF >expect | ||
miss /hitmiss | ||
miss /hitpass | ||
miss /hit | ||
hitmiss /hitmiss | ||
hitpass /hitpass | ||
hit /hit | ||
pass /pass | ||
synth /synth | ||
EOF | ||
varnishncsa -d -n ${v1_name} -F "%{Varnish:handling}x %U" >have | ||
diff -u expect have | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters