-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
302 additions
and
34 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
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,123 @@ | ||
varnishtest "Test vcl_backend_refresh" | ||
|
||
server s1 { | ||
rxreq | ||
txresp -hdr "Etag: abcd" -hdr "from-bo: true" -bodylen 10 | ||
|
||
rxreq | ||
expect req.http.if-none-match == "abcd" | ||
txresp -status 304 -hdr "be304-1: true" | ||
|
||
rxreq | ||
expect req.http.if-none-match == "abcd" | ||
txresp -status 304 -hdr "be304-2: true" | ||
|
||
rxreq | ||
expect req.http.if-none-match == "abcd" | ||
txresp -status 304 -hdr "be304-3: true" | ||
} -start | ||
|
||
varnish v1 -vcl+backend { | ||
|
||
sub vcl_backend_response { | ||
set beresp.http.vbresp = "true"; | ||
set beresp.ttl = 0.01s; | ||
set beresp.grace = 0s; | ||
set beresp.keep = 10m; | ||
set beresp.http.was-304 = beresp.was_304; | ||
} | ||
|
||
sub vcl_backend_refresh { | ||
set beresp.http.vbref = "true"; | ||
} | ||
|
||
} -start | ||
|
||
client c1 { | ||
txreq | ||
rxresp | ||
expect resp.status == 200 | ||
expect resp.http.was-304 == false | ||
expect resp.http.vbref == <undef> | ||
expect resp.http.vbresp == true | ||
expect resp.http.from-bo == true | ||
} -run | ||
|
||
delay 0.01 | ||
|
||
client c2 { | ||
txreq | ||
rxresp | ||
expect resp.status == 200 | ||
expect resp.http.was-304 == true | ||
expect resp.http.be304-1 == true | ||
expect resp.http.vbref == true | ||
expect resp.http.vbresp == true | ||
expect resp.http.from-bo == true | ||
} -run | ||
|
||
varnish v1 -vcl+backend { | ||
|
||
sub vcl_backend_response { | ||
set beresp.http.vbresp = "true"; | ||
set beresp.ttl = 0.01s; | ||
set beresp.grace = 0s; | ||
set beresp.keep = 10m; | ||
set beresp.http.was-304 = beresp.was_304; | ||
} | ||
|
||
|
||
sub vcl_refresh_status { | ||
set beresp.http.vbref = "true"; | ||
if (obj_stale.status == 200) { | ||
return (obj_stale); | ||
} | ||
} | ||
} | ||
|
||
delay 0.01 | ||
|
||
client c3 { | ||
txreq | ||
rxresp | ||
expect resp.status == 200 | ||
expect resp.http.was-304 == true | ||
expect resp.http.be304-1 == true | ||
expect resp.http.be304-2 == <undef> | ||
expect resp.http.vbref == true | ||
expect resp.http.vbresp == true | ||
expect resp.http.from-bo == true | ||
} -run | ||
|
||
varnish v1 -vcl+backend { | ||
|
||
sub vcl_backend_response { | ||
set beresp.http.vbresp = "true"; | ||
set beresp.ttl = 0.01s; | ||
set beresp.grace = 0s; | ||
set beresp.keep = 10m; | ||
set beresp.http.was-304 = beresp.was_304; | ||
} | ||
|
||
sub vcl_refresh_status { | ||
set beresp.http.vbref = "true"; | ||
if (obj_stale.status == 200) { | ||
return (beresp); | ||
} | ||
} | ||
} | ||
|
||
delay 0.01 | ||
|
||
client c4 { | ||
txreq | ||
rxresp | ||
expect resp.status == 304 | ||
expect resp.http.was-304 == true | ||
expect resp.http.be304-1 == <undef> | ||
expect resp.http.be304-2 == <undef> | ||
expect resp.http.be304-3 == true | ||
expect resp.http.vbref == true | ||
expect resp.http.vbresp == true | ||
expect resp.http.from-bo == <undef> | ||
} -run |
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,78 @@ | ||
varnishtest "Test obj_stale vcl variables" | ||
|
||
server s1 { | ||
rxreq | ||
txresp -hdr "Etag: abcd" -hdr "from-bo: true" -bodylen 10 | ||
rxreq | ||
expect req.http.if-none-match == "abcd" | ||
txresp -status 304 | ||
} -start | ||
|
||
varnish v1 -vcl+backend { | ||
|
||
sub vcl_backend_response { | ||
set beresp.http.vbresp = "true"; | ||
set beresp.ttl = 0.01s; | ||
set beresp.grace = 0s; | ||
set beresp.keep = 10m; | ||
set beresp.http.was-304 = beresp.was_304; | ||
} | ||
|
||
sub vcl_refresh_status { | ||
if (obj_stale.status == 200) { | ||
set beresp.http.vbref = "true"; | ||
|
||
set beresp.http.http = obj_stale.http.from-bo; | ||
set beresp.http.age = obj_stale.age; | ||
set beresp.http.can_esi = obj_stale.can_esi; | ||
set beresp.http.grace = obj_stale.grace; | ||
set beresp.http.hits = obj_stale.hits; | ||
set beresp.http.keep = obj_stale.keep; | ||
set beresp.http.proto = obj_stale.proto; | ||
set beresp.http.reason = obj_stale.reason; | ||
set beresp.http.status = obj_stale.status; | ||
set beresp.http.storage = obj_stale.storage; | ||
set beresp.http.time = obj_stale.time; | ||
set beresp.http.ttl = obj_stale.ttl; | ||
set beresp.http.uncacheable = obj_stale.uncacheable; | ||
} | ||
return (merge); | ||
} | ||
} -start | ||
|
||
client c1 { | ||
txreq | ||
rxresp | ||
expect resp.status == 200 | ||
|
||
expect resp.http.was-304 == false | ||
expect resp.http.vbref == <undef> | ||
expect resp.http.vbresp == true | ||
expect resp.http.from-bo == true | ||
} -run | ||
|
||
delay 0.01 | ||
|
||
client c2 { | ||
txreq | ||
rxresp | ||
expect resp.status == 200 | ||
expect resp.http.was-304 == true | ||
expect resp.http.vbresp == true | ||
expect resp.http.vbref == true | ||
expect resp.http.from-bo == true | ||
|
||
expect resp.http.http == true | ||
expect resp.http.age == 0 | ||
expect resp.http.can_esi == false | ||
expect resp.http.grace == 0.000 | ||
expect resp.http.hits == 0 | ||
expect resp.http.keep == 600.000 | ||
expect resp.http.proto == HTTP/1.1 | ||
expect resp.http.reason == OK | ||
expect resp.http.status == 200 | ||
expect resp.http.storage == storage.s0 | ||
expect resp.http.time != <undef> | ||
expect resp.http.ttl != <undef> | ||
expect resp.http.uncacheable == false | ||
} -run |
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