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

phk at projects.linpro.no phk at projects.linpro.no
Thu Jan 28 10:36:15 CET 2010


Author: phk
Date: 2010-01-28 10:36:15 +0100 (Thu, 28 Jan 2010)
New Revision: 4503

Modified:
   trunk/varnish-cache/bin/varnishtest/tests/v00014.vtc
   trunk/varnish-cache/bin/varnishtest/vtc_server.c
Log:
Fix a potential race when retargeting a server by doing an implicit -wait
before mucking with a running server.

If running on a random port, record it for subsequent -starts, so
we use the same (random) port throughout.

Fix the v00014 testcase which made some really bad assumptions relative
to the above, eliminating the delay it used in the process.



Modified: trunk/varnish-cache/bin/varnishtest/tests/v00014.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/v00014.vtc	2010-01-28 09:34:05 UTC (rev 4502)
+++ trunk/varnish-cache/bin/varnishtest/tests/v00014.vtc	2010-01-28 09:36:15 UTC (rev 4503)
@@ -6,7 +6,7 @@
 	rxreq
 	expect req.url == "/"
 	txresp -body "slash"
-} -start -repeat 4
+} -start
 
 varnish v1 -vcl {
 
@@ -16,7 +16,7 @@
 		.max_connections = 1;
 		.probe = {
 			.url = "/";
-			.timeout = 100 ms;
+			.timeout = 1s;
 			.interval = 1s;
 			.window = 3;
 			.threshold = 2;
@@ -39,11 +39,22 @@
 	expect resp.status == 500
 } -run
 
-delay 1
+server s1 {
+	rxreq
+	expect req.url == "/"
+	txresp -body "slash"
+} -start
 
+server s1 {
+	rxreq
+	expect req.url == "/foo"
+	txresp -body "foobar"
+} -start
+
 client c2 {
-	txreq
+	txreq -url "/foo"
 	rxresp
+	expect resp.bodylen == 6
 	expect resp.status == 200
 } -start
 

Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_server.c	2010-01-28 09:34:05 UTC (rev 4502)
+++ trunk/varnish-cache/bin/varnishtest/vtc_server.c	2010-01-28 09:36:15 UTC (rev 4503)
@@ -183,6 +183,9 @@
 		macro_def(s->vl, s->name, "addr", "%s", s->aaddr);
 		macro_def(s->vl, s->name, "port", "%s", s->aport);
 		macro_def(s->vl, s->name, "sock", "%s:%s", s->aaddr, s->aport);
+		/* Record the actual port, and reuse it on subsequent starts */
+		if (!strcmp(s->port, "0"))
+			REPLACE(s->port, s->aport);
 	}
 	vtc_log(s->vl, 1, "Listen on %s:%s", s->addr, s->port);
 	s->run = 1;
@@ -243,6 +246,7 @@
 	if (av == NULL) {
 		/* Reset and free */
 		VTAILQ_FOREACH_SAFE(s, &servers, list, s2) {
+			CHECK_OBJ_NOTNULL(s, SERVER_MAGIC);
 			VTAILQ_REMOVE(&servers, s, list);
 			if (s->run) {
 				(void)pthread_cancel(s->tp);
@@ -261,11 +265,26 @@
 			break;
 	if (s == NULL)
 		s = server_new(av[0]);
+	CHECK_OBJ_NOTNULL(s, SERVER_MAGIC);
 	av++;
 
 	for (; *av != NULL; av++) {
 		if (vtc_error)
 			break;
+		if (!strcmp(*av, "-wait")) {
+			if (!s->run)
+				vtc_log(s->vl, 0, "Server not -started");
+			server_wait(s);
+			continue;
+		}
+		/*
+		 * We do an implict -wait if people muck about with a 
+		 * running server.
+		 */
+		if (s->run) 
+			server_wait(s);
+
+		assert(s->run == 0);
 		if (!strcmp(*av, "-repeat")) {
 			s->repeat = atoi(av[1]);
 			av++;
@@ -281,10 +300,6 @@
 			server_start(s);
 			continue;
 		}
-		if (!strcmp(*av, "-wait")) {
-			server_wait(s);
-			continue;
-		}
 		if (**av == '-')
 			vtc_log(s->vl, 0, "Unknown server argument: %s", *av);
 		s->spec = *av;



More information about the varnish-commit mailing list