Rev 93: added --num-clients option to ctdb_messaging test in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Wed Apr 11 05:23:50 GMT 2007


------------------------------------------------------------
revno: 93
revision-id: tridge at samba.org-20070411052350-eb4fe86cc87ea5ed
parent: tridge at samba.org-20070411050922-59469f0a8a24cf4b
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge
timestamp: Wed 2007-04-11 15:23:50 +1000
message:
  added --num-clients option to ctdb_messaging test
modified:
  tests/ctdb_messaging.c         ctdb_messaging.c-20070411034205-6d6vne56pbih2x1p-1
=== modified file 'tests/ctdb_messaging.c'
--- a/tests/ctdb_messaging.c	2007-04-11 05:09:22 +0000
+++ b/tests/ctdb_messaging.c	2007-04-11 05:23:50 +0000
@@ -27,6 +27,7 @@
 static int num_records = 10;
 static int num_msgs = 1;
 static int num_repeats = 100;
+static int num_clients = 2;
 
 
 /*
@@ -36,6 +37,7 @@
 				 TDB_DATA data, void *private)
 {
 	printf("client vnn:%d received a message to srvid:%d\n",ctdb_get_vnn(ctdb),srvid);
+	fflush(stdout);
 }
 
 /*
@@ -61,16 +63,17 @@
 		{ "timelimit", 't', POPT_ARG_INT, &timelimit, 0, "timelimit", "integer" },
 		{ "num-records", 'r', POPT_ARG_INT, &num_records, 0, "num_records", "integer" },
 		{ "num-msgs", 'n', POPT_ARG_INT, &num_msgs, 0, "num_msgs", "integer" },
+		{ "num-clients", 0, POPT_ARG_INT, &num_clients, 0, "num_clients", "integer" },
 		POPT_TABLEEND
 	};
 	int opt;
 	const char **extra_argv;
 	int extra_argc = 0;
-	int ret;
+	int ret, i, j;
 	poptContext pc;
 	struct event_context *ev;
 	pid_t pid;
-	uint32_t srvid;
+	int srvid;
 	TDB_DATA data;
 
 	pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
@@ -142,11 +145,16 @@
 	/* start the protocol running */
 	ret = ctdb_start(ctdb);
 
-	pid=fork();
-	if (pid) {
-		srvid=0;
-	} else {
-		srvid=1;
+	srvid = -1;
+	for (i=0;i<num_clients-1;i++) {
+		pid=fork();
+		if (pid) {
+			srvid = i;
+			break;
+		}
+	}
+	if (srvid == -1) {
+		srvid = num_clients-1;
 	}
 
 	/* wait until all nodes are connected (should not be needed
@@ -157,12 +165,17 @@
 
 	ctdb_connect_wait(ctdb);
 
-	sleep(2);
+	sleep(1);
 
 	printf("sending message from vnn:%d to vnn:%d/srvid:%d\n",ctdb_get_vnn(ctdb),ctdb_get_vnn(ctdb), 1-srvid);
-	ctdb_send_message(ctdb, ctdb_get_vnn(ctdb), 1-srvid, data);
+	for (i=0;i<ctdb_get_num_nodes(ctdb);i++) {
+		for (j=0;j<num_clients;j++) {
+			printf("sending message to %d:%d\n", i, j);
+			ctdb_send_message(ctdb, i, j, data);
+		}
+	}
 
-	while(1){
+	while (1) {
 		event_loop_once(ev);
 	}
        



More information about the samba-cvs mailing list