Commit d53674df authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Tollef Fog Heen

Make this test case more robust (and faster) by using the

CLI to control backend health, rather than rely on probes.

Submitted by:	Federico G. Schwindt
parent f93325ea
varnishtest "Test fallback director" varnishtest "Test fallback director"
server s1 { server s1 {
rxreq rxreq
expect req.url == "/" txresp -hdr "Foo: 1"
txresp -body "slash"
close
sema r1 sync 3
accept
rxreq
expect req.url == "/"
txresp -body "slash"
close
accept
rxreq
expect req.url == "/"
txresp -body "slash"
close
sema r3 sync 2
accept
rxreq
expect req.url == "/foo"
txresp -hdr "Foo: 1" -body "foobar"
} -start } -start
server s2 { server s2 {
rxreq rxreq
expect req.url == "/" txresp -hdr "Foo: 2"
txresp -body "slash"
close
sema r1 sync 3
accept
rxreq
expect req.url == "/"
txresp -body "slash"
close
sema r2 sync 2
accept
rxreq
expect req.url == "/foo"
txresp -hdr "Foo: 2" -body "foobar"
} -start } -start
server s3 { server s3 {
rxreq rxreq
expect req.url == "/foo" txresp -hdr "Foo: 3"
txresp -hdr "Foo: 3" -body "foobar"
} -start } -start
varnish v1 -vcl { varnish v1 -vcl {
backend b1 {
probe p1 { .host = "${s1_addr}";
.url = "/"; .port = "${s1_port}";
.timeout = 1s; }
.interval = 1s; backend b2 {
.window = 4; .host = "${s2_addr}";
.threshold = 3; .port = "${s2_port}";
.initial = 0; }
} backend b3 {
probe p2 { .host = "${s3_addr}";
.url = "/"; .port = "${s3_port}";
.timeout = 1s; }
.interval = 1s; director f1 fallback {
.window = 3; { .backend = b1; }
.threshold = 2; { .backend = b2; }
.initial = 0; { .backend = b3; }
} }
sub vcl_recv {
backend b1 { set req.backend = f1;
.host = "${s1_addr}"; return (pass);
.port = "${s1_port}"; }
.max_connections = 1;
.probe = p1;
}
backend b2 {
.host = "${s2_addr}";
.port = "${s2_port}";
.max_connections = 1;
.probe = p2;
}
backend b3 {
.host = "${s3_addr}";
.port = "${s3_port}";
}
director f1 fallback {
{ .backend = b1; }
{ .backend = b2; }
{ .backend = b3; }
}
sub vcl_recv {
set req.backend = f1;
return(pass);
}
} -start } -start
varnish v1 -cliok "backend.set_health b1 sick"
varnish v1 -cliok "backend.set_health b2 sick"
client c1 { client c1 {
# s1 & s2 are both sick, expect response from s3 # s1 & s2 are both sick, expect response from s3
txreq -url "/foo" txreq
rxresp rxresp
expect resp.http.foo == "3" expect resp.http.foo == "3"
} -run
sema r1 sync 3 varnish v1 -cliok "backend.set_health b2 healthy"
# wait for s2 to become healthy client c1 {
sema r2 sync 2 txreq
txreq -url "/foo" rxresp
rxresp expect resp.http.foo == "2"
expect resp.http.foo == "2" } -run
# wait for s1 to become healthy varnish v1 -cliok "backend.set_health b1 healthy"
sema r3 sync 2
txreq -url "/foo" client c1 {
rxresp txreq
expect resp.http.foo == "1" rxresp
expect resp.http.foo == "1"
} -run } -run
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