[PATCH 2/2] test: Make test_votequorum1 work

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

 



Previously, votequorum getinfo call accepted 0 as nodeid, meaning
current node. After changes, this is no longer case, so we need to
read cmap to get current nodeid.

Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 test/Makefile.am       |    2 +-
 test/testvotequorum1.c |   16 ++++++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/test/Makefile.am b/test/Makefile.am
index 7010c50..d2282cf 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -60,7 +60,7 @@ stress_cpgcontext_LDADD	= -lcpg $(LIBQB_LIBS)
 stress_cpgcontext_LDFLAGS	= $(COMMON_OPTS)
 testquorum_LDADD	= -lquorum $(LIBQB_LIBS)
 testquorum_LDFLAGS	= $(COMMON_OPTS)
-testvotequorum1_LDADD	= -lvotequorum $(LIBQB_LIBS)
+testvotequorum1_LDADD	= -lvotequorum -lcmap $(LIBQB_LIBS)
 testvotequorum1_LDFLAGS	= $(COMMON_OPTS)
 testvotequorum2_LDADD	= -lvotequorum $(LIBQB_LIBS)
 testvotequorum2_LDFLAGS	= $(COMMON_OPTS)
diff --git a/test/testvotequorum1.c b/test/testvotequorum1.c
index 033012f..c14c0be 100644
--- a/test/testvotequorum1.c
+++ b/test/testvotequorum1.c
@@ -42,8 +42,11 @@
 #include <unistd.h>
 #include <corosync/corotypes.h>
 #include <corosync/votequorum.h>
+#include <corosync/cmap.h>
 
 static votequorum_handle_t g_handle;
+static uint32_t our_nodeid = 0;
+static cmap_handle_t cmap_handle = 0;
 
 static const char *node_state(int state)
 {
@@ -107,13 +110,22 @@ int main(int argc, char *argv[])
 	callbacks.votequorum_notify_fn = votequorum_notification_fn;
 	callbacks.votequorum_expectedvotes_notify_fn = votequorum_expectedvotes_notification_fn;
 
+	if ((err = cmap_initialize(&cmap_handle)) != CS_OK) {
+		fprintf(stderr, "cmap_initialize FAILED: %d\n", err);
+		exit (1);
+	}
+	if ((err = cmap_get_uint32(cmap_handle, "runtime.votequorum.this_node_id", &our_nodeid)) != CS_OK) {
+		fprintf(stderr, "Unable to retrive this node nodeid. Err %d\n", err);
+		exit (1);
+	}
+
 	if ( (err=votequorum_initialize(&g_handle, &callbacks)) != CS_OK)
 		fprintf(stderr, "votequorum_initialize FAILED: %d\n", err);
 
 	if ( (err = votequorum_trackstart(g_handle, g_handle, CS_TRACK_CHANGES)) != CS_OK)
 		fprintf(stderr, "votequorum_trackstart FAILED: %d\n", err);
 
-	if ( (err=votequorum_getinfo(g_handle, 0, &info)) != CS_OK)
+	if ( (err=votequorum_getinfo(g_handle, our_nodeid, &info)) != CS_OK)
 		fprintf(stderr, "votequorum_getinfo FAILED: %d\n", err);
 	else {
 		printf("node votes       %d\n", info.node_votes);
@@ -142,7 +154,7 @@ int main(int argc, char *argv[])
 	}
 
 	if (argc >= 2) {
-		if ( (err=votequorum_getinfo(g_handle, 0, &info)) != CS_OK)
+		if ( (err=votequorum_getinfo(g_handle, our_nodeid, &info)) != CS_OK)
 			fprintf(stderr, "votequorum_getinfo2 FAILED: %d\n", err);
 		else {
 			printf("-------------------\n");
-- 
1.7.10.4

_______________________________________________
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