[master] 1a9beb31d vtest: Allow to inject varnishd arguments via VTEST_VARNISHD_ADD_ARGS

Nils Goroll nils.goroll at uplex.de
Wed Apr 12 13:57:06 UTC 2023


commit 1a9beb31d7f164832e00185b4d2ba85671f93d29
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Tue Feb 28 15:13:33 2023 +0100

    vtest: Allow to inject varnishd arguments via VTEST_VARNISHD_ADD_ARGS
    
    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.

diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index f763fcce7..5c7fa3ce1 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -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);
 
@@ -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 */
@@ -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));
@@ -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 ({...}).


More information about the varnish-commit mailing list