Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
0109411b
Commit
0109411b
authored
May 15, 2019
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test VRT_fail from director contexts
Tests #2997
parent
8e7b0f01
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
116 additions
and
0 deletions
+116
-0
d00040.vtc
bin/varnishtest/tests/d00040.vtc
+33
-0
vmod.vcc
lib/libvmod_debug/vmod.vcc
+6
-0
vmod_debug.c
lib/libvmod_debug/vmod_debug.c
+77
-0
No files found.
bin/varnishtest/tests/d00040.vtc
0 → 100644
View file @
0109411b
varnishtest "Test failing in director callbacks"
varnish v1 -vcl {
import debug;
import std;
backend dummy { .host = "${bad_ip}"; }
sub vcl_init {
new d = debug.director();
}
sub vcl_recv {
if (req.url == "/healthy") {
if (std.healthy(d.fail())) {
return (synth(200));
} else {
return (synth(404));
}
}
set req.backend_hint = d.fail();
}
} -start
client c1 {
txreq -url "/"
rxresp
expect resp.status == 503
txreq -url "/healthy"
rxresp
expect resp.status == 503
} -run
lib/libvmod_debug/vmod.vcc
View file @
0109411b
...
@@ -268,3 +268,9 @@ $Function IP get_ip(PRIV_TASK)
...
@@ -268,3 +268,9 @@ $Function IP get_ip(PRIV_TASK)
Get the IP address previously stored by ``debug.store_ip()`` in the same
Get the IP address previously stored by ``debug.store_ip()`` in the same
transaction.
transaction.
$Object director()
$Method BACKEND .fail()
Return a backend which fails in director context
lib/libvmod_debug/vmod_debug.c
View file @
0109411b
...
@@ -922,3 +922,80 @@ const struct vmod_data Vmod_wrong3_Data = {
...
@@ -922,3 +922,80 @@ const struct vmod_data Vmod_wrong3_Data = {
};
};
//lint -restore
//lint -restore
/*---------------------------------------------------------------------*/
struct
VPFX
(
debug_director
)
{
unsigned
magic
;
#define VMOD_DEBUG_DIRECTOR_MAGIC 0x66b9ff3d
VCL_BACKEND
dir
;
};
/* XXX more callbacks ? */
static
vdi_healthy_f
vmod_debug_director_healthy
;
static
vdi_resolve_f
vmod_debug_director_resolve
;
static
const
struct
vdi_methods
vmod_debug_director_methods
[
1
]
=
{{
.
magic
=
VDI_METHODS_MAGIC
,
.
type
=
"debug.director"
,
.
resolve
=
vmod_debug_director_resolve
,
.
healthy
=
vmod_debug_director_healthy
}};
VCL_VOID
v_matchproto_
(
td_xyzzy_debug_director__init
)
xyzzy_director__init
(
VRT_CTX
,
struct
VPFX
(
debug_director
)
**
dp
,
const
char
*
vcl_name
)
{
struct
VPFX
(
debug_director
)
*
d
;
AN
(
dp
);
AZ
(
*
dp
);
ALLOC_OBJ
(
d
,
VMOD_DEBUG_DIRECTOR_MAGIC
);
AN
(
d
);
*
dp
=
d
;
d
->
dir
=
VRT_AddDirector
(
ctx
,
vmod_debug_director_methods
,
d
,
"%s"
,
vcl_name
);
}
VCL_VOID
v_matchproto_
(
td_xyzzy_debug_director__fini
)
xyzzy_director__fini
(
struct
VPFX
(
debug_director
)
**
dp
)
{
struct
VPFX
(
debug_director
)
*
d
;
TAKE_OBJ_NOTNULL
(
d
,
dp
,
VMOD_DEBUG_DIRECTOR_MAGIC
);
VRT_DelDirector
(
&
d
->
dir
);
FREE_OBJ
(
d
);
}
VCL_BACKEND
v_matchproto_
(
td_xyzzy_debug_director_fail
)
xyzzy_director_fail
(
VRT_CTX
,
struct
VPFX
(
debug_director
)
*
d
)
{
CHECK_OBJ_NOTNULL
(
d
,
VMOD_DEBUG_DIRECTOR_MAGIC
);
(
void
)
ctx
;
return
(
d
->
dir
);
}
static
VCL_BOOL
v_matchproto_
(
vdi_healthy_f
)
vmod_debug_director_healthy
(
VRT_CTX
,
VCL_BACKEND
dir
,
VCL_TIME
*
changed
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
(
void
)
dir
;
(
void
)
changed
;
VRT_fail
(
ctx
,
"fail"
);
return
(
1
);
}
static
VCL_BACKEND
v_matchproto_
(
vdi_resolve_f
)
vmod_debug_director_resolve
(
VRT_CTX
,
VCL_BACKEND
dir
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
(
void
)
dir
;
VRT_fail
(
ctx
,
"fail"
);
return
(
NULL
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment