[Openais] [PATCH 2/4] CTS: fix issues with new pacemaker cts

Angus Salkeld asalkeld at redhat.com
Wed Mar 24 13:38:39 PDT 2010


Signed-off-by: Angus Salkeld <asalkeld at redhat.com>
---
 cts/agents/mem_leak_test.sh |   13 +----
 cts/corolab.py              |  126 +++++++++++++++++++++++-------------------
 cts/corosync.py             |   29 +++++++---
 cts/corotests.py            |   16 +++---
 4 files changed, 98 insertions(+), 86 deletions(-)

diff --git a/cts/agents/mem_leak_test.sh b/cts/agents/mem_leak_test.sh
index 1a0f37f..1bdb2b0 100755
--- a/cts/agents/mem_leak_test.sh
+++ b/cts/agents/mem_leak_test.sh
@@ -57,16 +57,6 @@ _object_test_()
 }
 
 #
-# load and unload a service a bunch of times
-#
-_service_test_()
-{
-  echo _service_test_
-
-  exit 0
-}
-
-#
 # run the corosync tools to cause IPC sessions to created/destroyed
 #
 _session_test_()
@@ -88,7 +78,7 @@ _session_test_()
 # Note that we use `"$@"' to let each command-line parameter expand to a 
 # separate word. The quotes around `$@' are essential!
 # We need TEMP as the `eval set --' would nuke the return value of getopt.
-TEMP=`getopt -o u123 --long help,object,session,service \
+TEMP=`getopt -o u12 --long help,object,session \
      -n '$0' -- "$@"`
 
 if [ $? != 0 ] ; then echo "Incorrect arguments..." >&2 ; _usage_ ; exit 1 ; fi
@@ -101,7 +91,6 @@ while true ; do
                 -u|--help) _usage_ ;;
                 -1|--object) _object_test_ ;;
                 -2|--session) _session_test_ ;;
-                -3|--service) _service_test_ ;;
                 --) shift ; break ;;
                 *) echo "Internal error!" ; exit 1 ;;
         esac
diff --git a/cts/corolab.py b/cts/corolab.py
index 4efb4ce..83547de 100755
--- a/cts/corolab.py
+++ b/cts/corolab.py
@@ -40,8 +40,8 @@ Copyright (c) 2010 Red Hat, Inc.
 
 import sys
 from cts.CTSaudits import AuditList
-from cts.CTS import Scenario, InitClusterManager
-from corotests import CoroTestList, AllTests
+from cts.CTSscenarios import *
+from corotests import CoroTestList
 from corosync import *
 

@@ -93,12 +93,53 @@ def usage(arg):
     print "\t [--set option=value]"
     sys.exit(1)
 
+class CoroLabEnvironment(CtsLab):
+
+    def __init__(self):
+        CtsLab.__init__(self)
+
+        #  Get a random seed for the random number generator.
+        self["DoStonith"] = 0
+        self["DoStandby"] = 0
+        self["DoFencing"] = 0
+        self["XmitLoss"] = "0.0"
+        self["RecvLoss"] = "0.0"
+        self["IPBase"] = "127.0.0.10"
+        self["ClobberCIB"] = 0
+        self["CIBfilename"] = None
+        self["CIBResource"] = 0
+        self["DoBSC"]    = 0
+        self["use_logd"] = 0
+        self["oprofile"] = []
+        self["warn-inactive"] = 0
+        self["ListTests"] = 0
+        self["benchmark"] = 0
+        self["logrestartcmd"] = "/etc/init.d/rsyslog restart 2>&1 > /dev/null"
+        self["Schema"] = "corosync 1.2"
+        self["Stack"] = "corosync (flatiron)"
+        self['CMclass'] = corosync_flatiron
+        self["stonith-type"] = "external/ssh"
+        self["stonith-params"] = "hostlist=all,livedangerously=yes"
+        self["at-boot"] = 0  # Does the cluster software start automatically when the node boot 
+        self["logger"] = ([StdErrLog(self)])
+        self["loop-minutes"] = 60
+        self["valgrind-prefix"] = None
+        self["valgrind-procs"] = "corosync"
+        self["valgrind-opts"] = """--leak-check=full --show-reachable=yes --trace-children=no --num-callers=25 --gen-suppressions=all --suppressions="""+CTSvars.CTS_home+"""/cts.supp"""
+
+        self["experimental-tests"] = 0
+        self["valgrind-tests"] = 0
+        self["unsafe-tests"] = 0
+        self["loop-tests"] = 0
+        self["all-once"] = 1
+        self["LogWatcher"] = "remote"
+        self["SyslogFacility"] = DefaultFacility
     
 #
 # Main entry into the test system.
 #
 if __name__ == '__main__': 
-    Environment = CtsLab()
+    Environment = CoroLabEnvironment()
 
     NumIter = 0
     Version = 1
@@ -209,12 +250,6 @@ if __name__ == '__main__':
            except ValueError:
                usage(args[i])
 
-    Environment["remote_logwatch"]  = True
-    Environment["SyslogFacility"] = DefaultFacility
-    Environment["loop-minutes"] = int(Environment["loop-minutes"])
-    Environment["Stack"]    = "corosync (flatiron)"
-    Environment['CMclass']  = corosync_flatiron
-    Environment["use_logd"] = 0
     if Environment["OutputFile"]:
         Environment["logger"].append(FileLog(Environment, Environment["OutputFile"]))
 
@@ -233,74 +268,51 @@ if __name__ == '__main__':
 
     # Create the Cluster Manager object
     cm = Environment['CMclass'](Environment)
-
     Audits = AuditList(cm)
-    Tests = []
         
-    # Your basic start up the world type of test scenario...
-
-    # Scenario selection
-    scenario = Scenario(
-        [ InitClusterManager(Environment), TestAgentComponent(Environment)])
-
-
     if Environment["ListTests"] == 1 :
         Tests = CoroTestList(cm, Audits)
-        cm.log("Total %d tests"%len(Tests))
+        Environment.log("Total %d tests"%len(Tests))
         for test in Tests :
-            cm.log(str(test.name));
+            Environment.log(str(test.name));
         sys.exit(0)
 
     if TruncateLog:
-        cm.log("Truncating %s" % LogFile)
+        Environment.log("Truncating %s" % LogFile)
         lf = open(LogFile, "w");
         if lf != None:
             lf.truncate(0)
             lf.close()
 
-    keys = []
-    for key in Environment.keys():
-        keys.append(key)
-
-    keys.sort()
-    for key in keys:
-        cm.debug("Environment["+key+"]:\t"+str(Environment[key]))
-
-    cm.log(">>>>>>>>>>>>>>>> BEGINNING " + repr(NumIter) + " TESTS ")
-    cm.log("System log files: %s" % Environment["LogFileName"])
-    cm.ns.WaitForAllNodesToComeUp(Environment["nodes"])
-    cm.log("Cluster nodes: ")
-    for node in Environment["nodes"]:
-        cm.log("    * %s" % (node))
-
     if TestCase != None:
         for test in CoroTestList(cm, Audits):
             if test.name == TestCase:
                 Tests.append(test)
         if Tests == []:
             usage("--choose: No applicable/valid tests chosen")        
+
     else:
         Tests = CoroTestList(cm, Audits)
     
-    if Environment["benchmark"]:
-        Environment.ScenarioTests = BenchTests(scenario, cm, Tests, Audits)
-    elif Environment["all-once"] or NumIter == 0:
-        Environment.ScenarioTests = AllTests(scenario, cm, Tests, Audits)
-    else:
-        Environment.ScenarioTests = RandomTests(scenario, cm, Tests, Audits)
-
-    try :
-        overall, detailed = Environment.ScenarioTests.run(NumIter)
-    except :
-        cm.Env.log("Exception by %s" % sys.exc_info()[0])
-        for logmethod in Environment["logger"]:
-          traceback.print_exc(50, logmethod)
-        
-    Environment.ScenarioTests.summarize()
-    if Environment.ScenarioTests.Stats["failure"] > 0:
-        sys.exit(Environment.ScenarioTests.Stats["failure"])
+    # Scenario selection
+    if Environment["DoBSC"]:
+        scenario = RandomTests(cm, [ BasicSanityCheck(Environment) ], Audits, Tests)
 
-    elif Environment.ScenarioTests.Stats["success"] != NumIter:
-        cm.Env.log("No failure count but success != requested iterations")
-        sys.exit(1)
-        
+    elif Environment["all-once"] or NumIter == 0: 
+        NumIter = len(Tests)
+        scenario = AllOnce(
+            cm, [ InitClusterManager(Environment), TestAgentComponent(Environment), PacketLoss(Environment) ], Audits, Tests)
+    else:
+        scenario = RandomTests(
+            cm, [ InitClusterManager(Environment), TestAgentComponent(Environment), PacketLoss(Environment) ], Audits, Tests)
+
+    Environment.log(">>>>>>>>>>>>>>>> BEGINNING " + repr(NumIter) + " TESTS ")
+    Environment.log("Stack:            %s" % Environment["Stack"])
+    Environment.log("Schema:           %s" % Environment["Schema"])
+    Environment.log("Scenario:         %s" % scenario.__doc__)
+    Environment.log("Random Seed:      %s" % Environment["RandSeed"])
+    Environment.log("System log files: %s" % Environment["LogFileName"])
+
+    Environment.dump()
+    rc = Environment.run(scenario, NumIter)
+    sys.exit(rc)
diff --git a/cts/corosync.py b/cts/corosync.py
index d6c808c..9455a36 100644
--- a/cts/corosync.py
+++ b/cts/corosync.py
@@ -44,7 +44,7 @@ import string
 
 import augeas
 from cts.CTS import ClusterManager
-from cts.CTS import ScenarioComponent
+from cts.CTSscenarios import ScenarioComponent
 from cts.CTS import RemoteExec
 from cts.CTSvars import CTSvars
 
@@ -222,12 +222,11 @@ class corosync_flatiron(ClusterManager):
             self.agent[node].stop()
         return ClusterManager.StopaCM(self, node)
 
-
-    def StataCM(self, node):
-
-        '''Report the status of corosync on a given node'''
-
-        out=self.rsh(node, self["StatusCmd"], 1)
+    def test_node_CM(self, node):
+        # 2 - up and stable
+        # 1 - unstable
+        # 0 - down
+        out = self.rsh(node, self["StatusCmd"], 1)
         is_stopped = string.find(out, 'stopped')
         is_dead = string.find(out, 'dead')
 
@@ -235,6 +234,7 @@ class corosync_flatiron(ClusterManager):
 
         try:
             if ret:
+                ret = 2
                 if self.ShouldBeStatus[node] == "down":
                     self.log(
                     "Node status for %s is %s but we think it should be %s"
@@ -246,15 +246,26 @@ class corosync_flatiron(ClusterManager):
                     %        (node, "down", self.ShouldBeStatus[node]))
         except KeyError:        pass
 
-        if ret:        self.ShouldBeStatus[node]="up"
-        else:        self.ShouldBeStatus[node]="down"
+        if ret:        self.ShouldBeStatus[node] = "up"
+        else:        self.ShouldBeStatus[node] = "down"
         return ret
 
+    def StataCM(self, node):
+
+        '''Report the status of corosync on a given node'''
+        if self.test_node_CM(node) > 0:
+            return 1
+        else:
+            return None
 
     def RereadCM(self, node):
         self.log('reloading corosync on : ' + node)
         return ClusterManager.RereadCM(self, node)
 
+    def find_partitions(self):
+        ccm_partitions = []
+        return ccm_partitions
+
     def prepare(self):
         '''Finish the Initialization process. Prepare to test...'''
 
diff --git a/cts/corotests.py b/cts/corotests.py
index 92ea570..fb28fc5 100644
--- a/cts/corotests.py
+++ b/cts/corotests.py
@@ -189,6 +189,7 @@ class CpgCfgChgOnExecCrash(CpgConfigChangeBase):
         self.CM.log("sending SIGSEGV to corosync on " + self.wobbly)
         self.CM.rsh(self.wobbly, "killall -9 corosync")
         self.CM.rsh(self.wobbly, "rm -f /var/run/corosync.pid")
+        self.CM.ShouldBeStatus[self.wobbly] = "down"
 
     def __call__(self, node):
         self.incr("calls")
@@ -452,6 +453,13 @@ def CoroTestList(cm, audits):
     result = []
     configs = []
     empty = {}
+
+    for testclass in AllTestClasses:
+        bound_test = testclass(cm)
+        if bound_test.is_applicable():
+            bound_test.Audits = audits
+            result.append(bound_test)
+
     configs.append(empty)
 
     a = {}
@@ -495,13 +503,5 @@ def CoroTestList(cm, audits):
                 result.append(bound_test)
         num = num + 1
 
-
-
-    for testclass in AllTestClasses:
-        bound_test = testclass(cm)
-        if bound_test.is_applicable():
-            bound_test.Audits = audits
-            result.append(bound_test)
-
     return result
 
-- 
1.6.6.1




More information about the Openais mailing list