r4348 - trunk/varnish-cache/bin/varnishtest

phk at projects.linpro.no phk at projects.linpro.no
Tue Nov 10 20:49:33 CET 2009


Author: phk
Date: 2009-11-10 20:49:32 +0100 (Tue, 10 Nov 2009)
New Revision: 4348

Modified:
   trunk/varnish-cache/bin/varnishtest/vtc_client.c
Log:
Add a -repeat N facility to clients.



Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_client.c	2009-11-09 15:17:49 UTC (rev 4347)
+++ trunk/varnish-cache/bin/varnishtest/vtc_client.c	2009-11-10 19:49:32 UTC (rev 4348)
@@ -58,6 +58,8 @@
 
 	char			*connect;
 
+	unsigned		repeat;
+
 	pthread_t		tp;
 };
 
@@ -75,26 +77,30 @@
 	struct vtclog *vl;
 	int fd;
 	int i;
+	unsigned u;
 
 	CAST_OBJ_NOTNULL(c, priv, CLIENT_MAGIC);
 	AN(c->connect);
 
 	vl = vtc_logopen(c->name);
 
-	vtc_log(vl, 2, "Started");
-	vtc_log(vl, 3, "Connect to %s", c->connect);
-	fd = VSS_open(c->connect);
-	for (i = 0; fd < 0 && i < 3; i++) {
-		(void)sleep(1);
+	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);
+		for (i = 0; fd < 0 && i < 3; i++) {
+			(void)sleep(1);
+			fd = VSS_open(c->connect);
+		}
+		assert(fd >= 0);
+		vtc_log(vl, 3, "Connected to %s fd is %d", c->connect, fd);
+		http_process(vl, c->spec, fd, 1);
+		vtc_log(vl, 3, "Closing fd %d", fd);
+		TCP_close(&fd);
 	}
-	assert(fd >= 0);
-	vtc_log(vl, 3, "Connected to %s fd is %d", c->connect, fd);
-	http_process(vl, c->spec, fd, 1);
-	vtc_log(vl, 3, "Closing fd %d", fd);
-	TCP_close(&fd);
 	vtc_log(vl, 2, "Ending");
-
 	return (NULL);
 }
 
@@ -223,6 +229,11 @@
 			av++;
 			continue;
 		}
+		if (!strcmp(*av, "-repeat")) {
+			c->repeat = atoi(av[1]);
+			av++;
+			continue;
+		}
 		if (!strcmp(*av, "-start")) {
 			client_start(c);
 			continue;



More information about the varnish-commit mailing list