r4372 - in trunk/varnish-cache/bin/varnishtest: . tests

phk at projects.linpro.no phk at projects.linpro.no
Wed Nov 25 14:18:46 CET 2009


Author: phk
Date: 2009-11-25 14:18:46 +0100 (Wed, 25 Nov 2009)
New Revision: 4372

Modified:
   trunk/varnish-cache/bin/varnishtest/tests/b00014.vtc
   trunk/varnish-cache/bin/varnishtest/tests/c00003.vtc
   trunk/varnish-cache/bin/varnishtest/tests/v00010.vtc
   trunk/varnish-cache/bin/varnishtest/vtc.c
   trunk/varnish-cache/bin/varnishtest/vtc.h
   trunk/varnish-cache/bin/varnishtest/vtc_client.c
   trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
Log:
Have clients pick up the varnish accept address using macros.

Make the varnish accept address just use a random free TCP port.

Fix a couple of tests where we need to know the port number.



Modified: trunk/varnish-cache/bin/varnishtest/tests/b00014.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/b00014.vtc	2009-11-25 13:00:22 UTC (rev 4371)
+++ trunk/varnish-cache/bin/varnishtest/tests/b00014.vtc	2009-11-25 13:18:46 UTC (rev 4372)
@@ -2,8 +2,6 @@
 
 test "Check -f command line arg"
 
-shell "echo 'backend foo { .host = \"127.0.0.1\"; .port = \"9080\"; }' > /tmp/_b00014.vcl" 
-varnish v1 -arg "-f /tmp/_b00014.vcl" -start
 
 server s1 {
 	rxreq 
@@ -14,6 +12,9 @@
 	txresp -body "bar"
 } -start
 
+shell "echo 'backend foo { .host = \"${s1_addr}\"; .port = \"${s1_port}\"; }' > /tmp/_b00014.vcl" 
+varnish v1 -arg "-f /tmp/_b00014.vcl" -start
+
 client c1 {
 	txreq -url /foo
 	rxresp

Modified: trunk/varnish-cache/bin/varnishtest/tests/c00003.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/c00003.vtc	2009-11-25 13:00:22 UTC (rev 4371)
+++ trunk/varnish-cache/bin/varnishtest/tests/c00003.vtc	2009-11-25 13:18:46 UTC (rev 4372)
@@ -13,7 +13,7 @@
 # Benchmark Testing
 varnish v1 -cliok "param.set listen_address 198.18.1.1:9082"
 varnish v1 -vcl+backend {} -clierr 300 start
-varnish v1 -cliok "param.set listen_address :9081,127.0.0.2:9082"
+varnish v1 -cliok "param.set listen_address 127.0.0.1:9081,127.0.0.2:9082"
 varnish v1 -start
 
 client c1 {

Modified: trunk/varnish-cache/bin/varnishtest/tests/v00010.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/v00010.vtc	2009-11-25 13:00:22 UTC (rev 4371)
+++ trunk/varnish-cache/bin/varnishtest/tests/v00010.vtc	2009-11-25 13:18:46 UTC (rev 4372)
@@ -8,6 +8,9 @@
 	rxreq
 	txresp -hdr "Panic: please" -body "012345\n"
 	sema r1 sync 2
+	accept
+	rxreq
+	txresp -hdr "Foo: foo" -body "abcdef\n"
 } -start
 
 varnish v1 -vcl+backend {
@@ -19,8 +22,13 @@
 	}
 } -start
 
-varnish v1 -cliok "param.set diag_bitmap 0x00001000" 
+varnish v1 -cliok "param.set diag_bitmap 0x00001000"
 
+# We have to force a known listen address otherwise the client cannot find
+# the varnish after the restart.
+
+varnish v1 -cliok "param.set listen_address 127.0.0.1:9080" -stop -start
+
 # varnishtest defaults to auto_restart off, to avoid masking bugs.
 varnish v1 -cliok "param.set auto_restart on" 
 
@@ -31,13 +39,9 @@
 	txreq -url "/foo"
 	# Don't expect answer, the server crashed.
 	sema r1 sync 2
-	delay 2.5
 } -run
 
-server s1 {
-	rxreq
-	txresp -hdr "Foo: foo" -body "abcdef\n"
-} -start
+delay 2.5
 
 client c1 {
 	txreq -url "/"

Modified: trunk/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.c	2009-11-25 13:00:22 UTC (rev 4371)
+++ trunk/varnish-cache/bin/varnishtest/vtc.c	2009-11-25 13:18:46 UTC (rev 4372)
@@ -136,7 +136,7 @@
 	return (retval);
 }
 
-static struct vsb *
+struct vsb *
 macro_expand(char *name)
 {
 	struct vsb *vsb;

Modified: trunk/varnish-cache/bin/varnishtest/vtc.h
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.h	2009-11-25 13:00:22 UTC (rev 4371)
+++ trunk/varnish-cache/bin/varnishtest/vtc.h	2009-11-25 13:18:46 UTC (rev 4372)
@@ -74,4 +74,4 @@
     const char *str);
 
 void macro_def(struct vtclog *vl, const char *instance, const char *name, const char *fmt, ...);
-
+struct vsb *macro_expand(char *name);

Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_client.c	2009-11-25 13:00:22 UTC (rev 4371)
+++ trunk/varnish-cache/bin/varnishtest/vtc_client.c	2009-11-25 13:18:46 UTC (rev 4372)
@@ -42,6 +42,7 @@
 
 #include "vtc.h"
 
+#include "vsb.h"
 #include "vqueue.h"
 #include "miniobj.h"
 #include "vss.h"
@@ -78,29 +79,39 @@
 	int fd;
 	int i;
 	unsigned u;
+	struct vsb *vsb;
+	char *p;
 
 	CAST_OBJ_NOTNULL(c, priv, CLIENT_MAGIC);
 	AN(c->connect);
 
+	p = strdup(c->connect);
+	vsb = macro_expand(p);
+	AN(vsb);
+
 	vl = vtc_logopen(c->name);
 
 	if (c->repeat == 0)
 		c->repeat = 1;
 	vtc_log(vl, 2, "Started (%u iterations)", c->repeat);
 	for (u = 0; u < c->repeat; u++) {
-		vtc_log(vl, 3, "Connect to %s", c->connect);
-		fd = VSS_open(c->connect);
+		vtc_log(vl, 3, "Connect to %s", vsb_data(vsb));
+		fd = VSS_open(vsb_data(vsb));
 		for (i = 0; fd < 0 && i < 3; i++) {
 			(void)sleep(1);
-			fd = VSS_open(c->connect);
+			fd = VSS_open(vsb_data(vsb));
 		}
+		if (fd < 0)
+			vtc_log(c->vl, 0, "Failed to open %s", vsb_data(vsb));
 		assert(fd >= 0);
-		vtc_log(vl, 3, "Connected to %s fd is %d", c->connect, fd);
+		vtc_log(vl, 3, "Connected to %s fd is %d", vsb_data(vsb), fd);
 		http_process(vl, c->spec, fd, -1);
 		vtc_log(vl, 3, "Closing fd %d", fd);
 		TCP_close(&fd);
 	}
 	vtc_log(vl, 2, "Ending");
+	vsb_delete(vsb);
+	free(p);
 	return (NULL);
 }
 
@@ -122,7 +133,7 @@
 	if (*c->name != 'c')
 		vtc_log(c->vl, 0, "Client name must start with 'c'");
 
-	REPLACE(c->connect, "127.0.0.1:9081");
+	REPLACE(c->connect, "${v1_sock}");
 	VTAILQ_INSERT_TAIL(&clients, c, list);
 	return (c);
 }

Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c	2009-11-25 13:00:22 UTC (rev 4371)
+++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c	2009-11-25 13:18:46 UTC (rev 4372)
@@ -172,7 +172,7 @@
 
 	v->args = vsb_newauto();
 	v->telnet = "127.0.0.1:9001";
-	v->accept = "127.0.0.1:9081";
+	v->accept = "127.0.0.1:0";
 	v->cli_fd = -1;
 	VTAILQ_INSERT_TAIL(&varnishes, v, list);
 



More information about the varnish-commit mailing list