Created
December 18, 2019 08:50
-
-
Save aondio/67539404140910030b2de03607584651 to your computer and use it in GitHub Desktop.
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
varnishtest "hash director with sick backend" | |
server s1 -repeat 2 { | |
rxreq | |
expect req.url == "/s1" | |
expect req.http.Host == "host2" | |
txresp -hdr "Server: s1" -body "server1" | |
} -start | |
server s2 { | |
rxreq | |
expect req.url == "/s1" | |
expect req.http.Host == "host1" | |
txresp -hdr "Server: s2" -body "server2" | |
} -start | |
varnish v1 -vcl+backend { | |
import directors; | |
sub vcl_init { | |
new vd = directors.hash(); | |
vd.add_backend(s1,1); | |
vd.add_backend(s2,1); | |
} | |
sub vcl_recv { | |
set req.backend_hint = vd.backend(client.ip); | |
} | |
} -start | |
varnish v1 -cliok "backend.set_health s1 sick" | |
client c1 { | |
txreq -url /s1 -hdr "Host: host1" | |
rxresp | |
# il server 1 è sick perciò il response deve arrivare dal server 2 | |
expect resp.body == "server2" | |
} -run | |
varnish v1 -cliok "backend.set_health s1 healthy" | |
client c2 { | |
txreq -url /s1 -hdr "Host: host2" | |
rxresp | |
# il server 1 è tornato healthy ed ora il response arriva da s1 | |
expect resp.body == "server1" | |
} -run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment