Commit b302a2cf authored by Nils Goroll's avatar Nils Goroll Committed by Dridi Boukelmoune

Test adding (dynamic) backends with probe to already warm vcl

this tests d912ffe4

Tweaked:
	bin/varnishtest/tests/d00007.vtc

In 6.0 this bug doesn't exist and directors behave slightly differently
so the test case needed some adjustments to both show that a backend can
be added to an already warm VCL with a probe, and that requests succeed.
parent b57e5296
......@@ -3,6 +3,10 @@ varnishtest "Test dynamic backends"
server s1 {
rxreq
txresp
close
accept
rxreq
txresp
} -start
varnish v1 -vcl {
......@@ -10,11 +14,18 @@ varnish v1 -vcl {
backend dummy { .host = "${bad_backend}"; }
probe pr {
.window = 1;
.threshold = 1;
.initial = 1;
}
sub vcl_init {
new s1 = debug.dyn("${s1_addr}", "${s1_port}");
new s1 = debug.dyn("${bad_backend}", "0");
}
sub vcl_recv {
s1.refresh("${s1_addr}", "${s1_port}", pr);
set req.backend_hint = s1.backend();
}
} -start
......@@ -26,3 +37,5 @@ client c1 {
rxresp
expect resp.status == 200
} -run
server s1 -wait
......@@ -129,7 +129,7 @@ $Function VOID fail()
Function to fail vcl code. (See also: RFC748)
$Object dyn(STRING addr, STRING port)
$Object dyn(STRING addr, STRING port, PROBE probe=0)
Dynamically create a single-backend director, addr and port must not be empty.
......@@ -137,7 +137,7 @@ $Method BACKEND .backend()
Return the dynamic backend.
$Method VOID .refresh(STRING addr, STRING port)
$Method VOID .refresh(STRING addr, STRING port, PROBE probe=0)
Dynamically refresh & (always!) replace the backend by a new one.
......
......@@ -60,7 +60,7 @@ struct xyzzy_debug_dyn_uds {
static void
dyn_dir_init(VRT_CTX, struct xyzzy_debug_dyn *dyn,
VCL_STRING addr, VCL_STRING port)
VCL_STRING addr, VCL_STRING port, VCL_PROBE probe)
{
struct addrinfo hints, *res = NULL;
struct suckaddr *sa;
......@@ -75,6 +75,7 @@ dyn_dir_init(VRT_CTX, struct xyzzy_debug_dyn *dyn,
vrt.port = port;
vrt.vcl_name = dyn->vcl_name;
vrt.hosthdr = addr;
vrt.probe = probe;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
......@@ -116,7 +117,7 @@ dyn_dir_init(VRT_CTX, struct xyzzy_debug_dyn *dyn,
VCL_VOID
xyzzy_dyn__init(VRT_CTX, struct xyzzy_debug_dyn **dynp,
const char *vcl_name, VCL_STRING addr, VCL_STRING port)
const char *vcl_name, VCL_STRING addr, VCL_STRING port, VCL_PROBE probe)
{
struct xyzzy_debug_dyn *dyn;
......@@ -139,7 +140,7 @@ xyzzy_dyn__init(VRT_CTX, struct xyzzy_debug_dyn **dynp,
AZ(pthread_mutex_init(&dyn->mtx, NULL));
dyn_dir_init(ctx, dyn, addr, port);
dyn_dir_init(ctx, dyn, addr, port, probe);
XXXAN(dyn->dir);
*dynp = dyn;
}
......@@ -172,11 +173,11 @@ xyzzy_dyn_backend(VRT_CTX, struct xyzzy_debug_dyn *dyn)
VCL_VOID
xyzzy_dyn_refresh(VRT_CTX, struct xyzzy_debug_dyn *dyn,
VCL_STRING addr, VCL_STRING port)
VCL_STRING addr, VCL_STRING port, VCL_PROBE probe)
{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(dyn, VMOD_DEBUG_DYN_MAGIC);
dyn_dir_init(ctx, dyn, addr, port);
dyn_dir_init(ctx, dyn, addr, port, probe);
}
static int
......
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