[PATCH 5/6] testvotequorum2: Opt for polling with old ringid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Option -F is added to force sending old ringid for given number of
times. Option is useful for testing failure scenario during corosync
synchronization phase.

Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 test/testvotequorum2.c |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/test/testvotequorum2.c b/test/testvotequorum2.c
index f545070..0a2e926 100644
--- a/test/testvotequorum2.c
+++ b/test/testvotequorum2.c
@@ -47,6 +47,8 @@
 static votequorum_handle_t handle;
 
 static votequorum_ring_id_t last_received_ring_id;
+static votequorum_ring_id_t ring_id_to_send;
+static int no_sent_old_ringid = 0;
 
 static int print_info(int ok_to_fail)
 {
@@ -88,11 +90,13 @@ static void votequorum_notification_fn(
 	printf("\n");
 
 	memcpy(&last_received_ring_id, &ring_id, sizeof(ring_id));
+	no_sent_old_ringid = 0;
 }
 
 static void usage(const char *command)
 {
-  printf("%s [-p <num>] [-t <time>] [-n <name>] [-c] [-m]\n", command);
+  printf("%s [-F <num>] [-p <num>] [-t <time>] [-n <name>] [-c] [-m]\n", command);
+	printf("      -F <num>  Number of times to send old ringid before actual ringid is sent (for testing, default = 0)\n");
         printf("      -p <num>  Number of times to poll qdevice (default 0=infinte)\n");
         printf("      -t <secs> Time (in seconds) to wait between polls (default=1)\n");
         printf("      -n <name> Name of quorum device (default QDEVICE)\n");
@@ -107,11 +111,12 @@ int main(int argc, char *argv[])
 	int ret = 0;
 	int cast_vote = 1, master_wins = 0;
 	int pollcount=0, polltime=1, quiet=0, once=0;
+	int send_old_ringid = 0;
 	int err;
 	int opt;
 	votequorum_callbacks_t callbacks;
 	const char *devicename = "QDEVICE";
-	const char *options = "n:p:t:cmq1h";
+	const char *options = "F:n:p:t:cmq1h";
 
 	memset(&callbacks, 0, sizeof(callbacks));
 	callbacks.votequorum_notify_fn = votequorum_notification_fn;
@@ -130,6 +135,9 @@ int main(int argc, char *argv[])
 		case 'q':
 		        quiet = 1;
 			break;
+		case 'F':
+		        send_old_ringid = atoi(optarg)+1;
+			break;
 		case 'p':
 		        pollcount = atoi(optarg)+1;
 			break;
@@ -191,7 +199,17 @@ int main(int argc, char *argv[])
                         }
 
 		        if (!quiet) print_info(0);
-			if ((err=votequorum_qdevice_poll(handle, devicename, cast_vote, last_received_ring_id)) != CS_OK &&
+
+			if (no_sent_old_ringid + 1 >= send_old_ringid) {
+				/*
+				 * Finally send correct ringid
+				 */
+				memcpy(&ring_id_to_send, &last_received_ring_id, sizeof(ring_id_to_send));
+			} else {
+				no_sent_old_ringid++;
+			}
+
+			if ((err=votequorum_qdevice_poll(handle, devicename, cast_vote, ring_id_to_send)) != CS_OK &&
 			     err != CS_ERR_MESSAGE_ERROR) {
 				fprintf(stderr, "qdevice poll FAILED: %d\n", err);
 				ret = -1;
-- 
1.7.1

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss




[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux