]> git.proxmox.com Git - mirror_corosync.git/commitdiff
CTS: add context get/set tests.
authorAngus Salkeld <asalkeld@redhat.com>
Thu, 15 Apr 2010 23:15:59 +0000 (23:15 +0000)
committerAngus Salkeld <asalkeld@redhat.com>
Thu, 15 Apr 2010 23:15:59 +0000 (23:15 +0000)
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2764 fd59a12c-fef9-0310-b244-a6a79926bd2f

cts/agents/confdb_test_agent.c
cts/agents/cpg_test_agent.c
cts/agents/syncv2.c
cts/agents/votequorum_test_agent.c
cts/corosync.py
cts/corotests.py

index f90b1d0509590b9fde8fb90e3d267259708ca388..289384ddad7aacfcfed96f9769f0b5081d008516 100644 (file)
@@ -567,6 +567,31 @@ send_response:
 }
 
 
+static void context_test (int sock)
+{
+       confdb_handle_t handle;
+       char response[100];
+       char *cmp;
+       int res;
+
+       snprintf (response, 100, "%s", OK_STR);
+
+       res = confdb_initialize (&handle, &valid_callbacks);
+       if (res != CS_OK) {
+               syslog (LOG_ERR, "Could not initialize confdb error %d\n", res);
+               goto send_response;
+       }
+
+       confdb_context_set (handle, response);
+       confdb_context_get (handle, (const void**)&cmp);
+       if (response != cmp) {
+               snprintf (response, 100, "%s", FAIL_STR);
+       }
+
+send_response:
+       send (sock, response, strlen (response) + 1, 0);
+       confdb_finalize (handle);
+}
 
 static void do_command (int sock, char* func, char*args[], int num_args)
 {
@@ -583,6 +608,8 @@ static void do_command (int sock, char* func, char*args[], int num_args)
                object_find_test (sock);
        } else if (strcmp ("notification_test", func) == 0) {
                notification_test (sock);
+       } else if (strcmp ("context_test", func) == 0) {
+               context_test (sock);
        } else if (strcmp ("are_you_ok_dude", func) == 0) {
                snprintf (response, 100, "%s", OK_STR);
                send (sock, response, strlen (response) + 1, 0);
index d7645c261009812ad4695aae244922287c2fc97a..1f5babcd7537a419302a1c2003277ca5b928272a 100644 (file)
@@ -449,6 +449,23 @@ static void msg_blaster (int sock, char* num_to_send_str)
        send_some_more_messages_normal ();
 }
 
+
+static void context_test (int sock)
+{
+       char response[100];
+       char *cmp;
+
+       cpg_context_set (cpg_handle, response);
+       cpg_context_get (cpg_handle, &cmp);
+       if (response != cmp) {
+               snprintf (response, 100, "%s", FAIL_STR);
+       }
+       else {
+               snprintf (response, 100, "%s", OK_STR);
+       }
+       send (sock, response, strlen (response) + 1, 0);
+}
+
 static void msg_blaster_zcb (int sock, char* num_to_send_str)
 {
        my_msgs_to_send = atoi (num_to_send_str);
@@ -552,36 +569,26 @@ static void do_command (int sock, char* func, char*args[], int num_args)
                cpg_local_get (cpg_handle, &local_nodeid);
                snprintf (response, 100, "%u",local_nodeid);
                send (sock, response, strlen (response) + 1, 0);
-
-       } else if (strcmp ("cpg_finalize",func) == 0) {
+       } else if (strcmp ("cpg_finalize", func) == 0) {
 
                cpg_finalize (cpg_handle);
                poll_dispatch_delete (ta_poll_handle_get(), cpg_fd);
                cpg_fd = -1;
 
-       } else if (strcmp ("record_config_events",func) == 0) {
-
+       } else if (strcmp ("record_config_events", func) == 0) {
                record_config_events ();
-
-       } else if (strcmp ("record_messages",func) == 0) {
-
+       } else if (strcmp ("record_messages", func) == 0) {
                record_messages ();
-
-       } else if (strcmp ("read_config_event",func) == 0) {
-
+       } else if (strcmp ("read_config_event", func) == 0) {
                read_config_event (sock);
-
-       } else if (strcmp ("read_messages",func) == 0) {
-
+       } else if (strcmp ("read_messages", func) == 0) {
                read_messages (sock, args[0]);
-
        } else if (strcmp ("msg_blaster_zcb", func) == 0) {
-
                msg_blaster_zcb (sock, args[0]);
-
-       } else if (strcmp ("msg_blaster",func) == 0) {
-
+       } else if (strcmp ("msg_blaster", func) == 0) {
                msg_blaster (sock, args[0]);
+       } else if (strcmp ("context_test", func) == 0) {
+               context_test (sock);
        } else if (strcmp ("are_you_ok_dude", func) == 0) {
                snprintf (response, 100, "%s", OK_STR);
                send (sock, response, strlen (response) + 1, 0);
index e5645a4cfd81ee70df3b1a747a11b92db6dc294b..68595e99dfb981322e7abbf41bcb15de1e430875 100644 (file)
@@ -274,8 +274,6 @@ static int tst_sv2_sync_process (void)
 {
        num_sync_processes++;
 
-       log_printf (LOGSYS_LEVEL_INFO, "sync: process %d", num_sync_processes);
-
        if (num_sync_processes > 3) {
                return 0;
        } else {
index 23b90d3848a6fb2da47f7745a2e35ab8b6de0368..bbfb52e963abdb6777199c795ae8afa6e17f6a31 100644 (file)
@@ -265,6 +265,29 @@ send_response:
        send (sock, response, strlen (response), 0);
 }
 
+static void context_test (int sock)
+{
+       char response[100];
+       char *cmp;
+
+       snprintf (response, 100, "%s", OK_STR);
+
+       votequorum_context_set (vq_handle, response);
+       votequorum_context_get (vq_handle, (void**)&cmp);
+       if (response != cmp) {
+               snprintf (response, 100, "%s", FAIL_STR);
+               syslog (LOG_ERR, "votequorum context not the same");
+       }
+
+       quorum_context_set (q_handle, response);
+       quorum_context_get (q_handle, (const void**)&cmp);
+       if (response != cmp) {
+               snprintf (response, 100, "%s", FAIL_STR);
+               syslog (LOG_ERR, "quorum context not the same");
+       }
+       send (sock, response, strlen (response) + 1, 0);
+}
+
 static void do_command (int sock, char* func, char*args[], int num_args)
 {
        char response[100];
@@ -282,6 +305,8 @@ static void do_command (int sock, char* func, char*args[], int num_args)
                getquorate (sock);
        } else if (strcmp ("init", func) == 0) {
                lib_init (sock);
+       } else if (strcmp ("context_test", func) == 0) {
+               context_test (sock);
        } else if (strcmp ("are_you_ok_dude", func) == 0) {
                snprintf (response, 100, "%s", OK_STR);
                send (sock, response, strlen (response) + 1, 0);
index b18cf6abf2c13d31ca81938dc9eab5c9e1ea9380..3ba14507b53835c99eea22ba63ade768f3636e78 100644 (file)
@@ -566,6 +566,10 @@ class CpgTestAgent(TestAgent):
         else:
             return msg
 
+    def context_test(self):
+        self.send (["context_test"])  
+        return self.read ()
+
 ###################################################################
 class ConfdbTestAgent(TestAgent):
 
index f13829cba36035acfdba18bae7f3a53fbac08135..c1680e5a252ebb971a040032a899415ce653f723 100644 (file)
@@ -86,6 +86,19 @@ class CoroTest(CTSTest):
         self.CM.apply_default_config()
         return CTSTest.teardown(self, node)
 
+###################################################################
+class CpgContextTest(CoroTest):
+    def __init__(self, cm):
+        CoroTest.__init__(self, cm)
+        self.name="CpgContextTest"
+
+    def __call__(self, node):
+        self.incr("calls")
+        res = self.CM.cpg_agent[node].context_test()
+        if 'OK' in res:
+            return self.success()
+        else:
+            return self.failure('context_test failed')
 
 ###################################################################
 class CpgConfigChangeBase(CoroTest):
@@ -548,6 +561,20 @@ class ConfdbReplaceTest(CoroTest):
         else:
             return self.failure('set_get_test failed')
 
+###################################################################
+class ConfdbContextTest(CoroTest):
+    def __init__(self, cm):
+        CoroTest.__init__(self, cm)
+        self.name="ConfdbContextTest"
+
+    def __call__(self, node):
+        self.incr("calls")
+        res = self.CM.confdb_agent[node].context_test()
+        if 'OK' in res:
+            return self.success()
+        else:
+            return self.failure('context_test failed')
+
 
 ###################################################################
 class ConfdbIncrementTest(CoroTest):
@@ -843,12 +870,29 @@ class VoteQuorumGoUp(VoteQuorumBase):
 
         return self.success()
 
+###################################################################
+class VoteQuorumContextTest(CoroTest):
+
+    def __init__(self, cm):
+        CoroTest.__init__(self, cm)
+        self.name="VoteQuorumContextTest"
+        self.expected = len(self.CM.Env["nodes"])
+        self.config['quorum/provider'] = 'corosync_votequorum'
+        self.config['quorum/expected_votes'] = self.expected
+
+    def __call__(self, node):
+        self.incr("calls")
+        res = self.CM.votequorum_agent[node].context_test()
+        if 'OK' in res:
+            return self.success()
+        else:
+            return self.failure('context_test failed')
 
 
 ###################################################################
 class GenSimulStart(CoroTest):
-###################################################################
     '''Start all the nodes ~ simultaneously'''
+
     def __init__(self, cm):
         CoroTest.__init__(self,cm)
         self.name="GenSimulStart"
@@ -876,8 +920,8 @@ class GenSimulStart(CoroTest):
 
 ###################################################################
 class GenSimulStop(CoroTest):
-###################################################################
     '''Stop all the nodes ~ simultaneously'''
+
     def __init__(self, cm):
         CoroTest.__init__(self,cm)
         self.name="GenSimulStop"
@@ -920,6 +964,9 @@ AllTestClasses.append(ConfdbReplaceTest)
 AllTestClasses.append(ConfdbIncrementTest)
 AllTestClasses.append(ConfdbObjectFindTest)
 AllTestClasses.append(ConfdbNotificationTest)
+AllTestClasses.append(ConfdbContextTest)
+AllTestClasses.append(CpgContextTest)
+AllTestClasses.append(VoteQuorumContextTest)
 AllTestClasses.append(SamTest1)
 AllTestClasses.append(SamTest2)
 AllTestClasses.append(SamTest3)