Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aondio/9d254478bf6558f47eccb8bb5d8eee56 to your computer and use it in GitHub Desktop.
Save aondio/9d254478bf6558f47eccb8bb5d8eee56 to your computer and use it in GitHub Desktop.
varnishtest "Make sure we play well with other directors"
server s1 {
rxreq
txresp -hdr "server: 1"
} -start
server s2 {
rxreq
txresp -hdr "server: 2"
} -start
varnish v1 -vcl+backend {
import directors;
import std;
import udo;
sub vcl_init {
new live = directors.fallback(sticky=true);
live.add_backend(s1);
live.add_backend(s2);
new vod = directors.fallback(sticky=true);
vod.add_backend(s2);
vod.add_backend(s1);
}
sub vcl_recv {
if (req.url == "live") {
set req.backend_hint = live.backend();
return (pass);
}
if (req.url == "vod") {
set req.backend_hint = vod.backend();
return (pass);
}
}
} -start
varnish v1 -cliok "param.set debug +syncvsl"
client c1 {
txreq -url "live"
rxresp
expect resp.status == 200
expect resp.http.server == "1"
txreq -url "vod"
rxresp
expect resp.status == 200
expect resp.http.server == "2"
} -run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment