Skip to content

Commit

Permalink
vtest: Allow to inject varnishd arguments via VTEST_VARNISHD_ADD_ARGS
Browse files Browse the repository at this point in the history
This is useful to test extensions with otherwise unaltered varnish test cases,
for example:

VTEST_VARNISHD_ADD_ARGS='-E/tmp/lib/varnish/vmods/libvmod_slash.so -sfellow=fellow,${tmpdir}/fellow.stv,100MB,1MB,64KB -sTransient=fellow,${tmpdir}/transient.stv,100MB,1MB,64KB' ./varnishtest -i ...

These arguments are added and this injection method does not achieve
its goal in all cases (e.g. for the example it breaks when other
stevedore definitions conflict), but it still reduces the cases
requiring manual intervention substantially.
  • Loading branch information
nigoroll committed Apr 12, 2023
1 parent ed76164 commit 1a9beb3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bin/varnishtest/vtc_varnish.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ struct varnish {

#define NONSENSE "%XJEIFLH|)Xspa8P"

#define VARNISHD_ADD_ARGS_ENV_VAR "VTEST_VARNISHD_ADD_ARGS"

static VTAILQ_HEAD(, varnish) varnishes =
VTAILQ_HEAD_INITIALIZER(varnishes);

Expand Down Expand Up @@ -389,7 +391,7 @@ varnish_launch(struct varnish *v)
char abuf[128], pbuf[128];
struct pollfd fd[3];
enum VCLI_status_e u;
const char *err;
const char *err, *env_args;
char *r = NULL;

/* Create listener socket */
Expand Down Expand Up @@ -429,6 +431,9 @@ varnish_launch(struct varnish *v)
VSB_printf(vsb, " -P %s/varnishd.pid", v->workdir);
if (vmod_path != NULL)
VSB_printf(vsb, " -p vmod_path=%s", vmod_path);
env_args = getenv(VARNISHD_ADD_ARGS_ENV_VAR);
if (env_args)
VSB_printf(vsb, " %s", env_args);
VSB_printf(vsb, " %s", VSB_data(v->args));
AZ(VSB_finish(vsb));
vtc_log(v->vl, 3, "CMD: %s", VSB_data(vsb));
Expand Down Expand Up @@ -1068,6 +1073,9 @@ vsl_catchup(struct varnish *v)
* \-arg STRING
* Pass an argument to varnishd, for example "-h simple_list".
*
* The environment variable VTEST_VARNISHD_ADD_ARGS can be used to
* inject additional arguments.
*
* \-vcl STRING
* Specify the VCL to load on this Varnish instance. You'll probably
* want to use multi-lines strings for this ({...}).
Expand Down

0 comments on commit 1a9beb3

Please sign in to comment.