[6.0] b302a2cf4 Test adding (dynamic) backends with probe to already warm vcl
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Thu Aug 16 08:53:20 UTC 2018
commit b302a2cf4d4f3863d4ebe9d8c0d6092e5b401079
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Jul 12 12:53:58 2018 +0200
Test adding (dynamic) backends with probe to already warm vcl
this tests d912ffe4f7a5e643275699c94b2722d486fd9e7f
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.
diff --git a/bin/varnishtest/tests/d00007.vtc b/bin/varnishtest/tests/d00007.vtc
index eac4a4d17..b46660787 100644
--- a/bin/varnishtest/tests/d00007.vtc
+++ b/bin/varnishtest/tests/d00007.vtc
@@ -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
diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc
index d6094bcae..3e6b06108 100644
--- a/lib/libvmod_debug/vmod.vcc
+++ b/lib/libvmod_debug/vmod.vcc
@@ -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.
diff --git a/lib/libvmod_debug/vmod_debug_dyn.c b/lib/libvmod_debug/vmod_debug_dyn.c
index 3603d73e5..338c2518c 100644
--- a/lib/libvmod_debug/vmod_debug_dyn.c
+++ b/lib/libvmod_debug/vmod_debug_dyn.c
@@ -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
More information about the varnish-commit
mailing list