Signed-off-by: Angus Salkeld <asalk...@redhat.com>
---
 cts/agents/Makefile.am       |    4 +-
 cts/agents/shm_leak_audit.sh |   47 ++++++++++++++++++++++++++++++++++++++++++
 cts/corolab.py               |    3 +-
 cts/corosync.py              |   39 ++++++++++++++++++++++++++++++++++
 4 files changed, 89 insertions(+), 4 deletions(-)
 create mode 100755 cts/agents/shm_leak_audit.sh

diff --git a/cts/agents/Makefile.am b/cts/agents/Makefile.am
index dbaaffb..9080462 100644
--- a/cts/agents/Makefile.am
+++ b/cts/agents/Makefile.am
@@ -41,7 +41,7 @@ EXTRA_DIST            = syncv2.c
 if INSTALL_TESTAGENTS
 agentdir = $(datadir)/$(PACKAGE)/tests
 bin_PROGRAMS = $(TEST_AGENTS)
-dist_agent_SCRIPTS = mem_leak_test.sh net_breaker.sh
+dist_agent_SCRIPTS = mem_leak_test.sh net_breaker.sh shm_leak_audit.sh
 
 AM_CFLAGS              = -fPIC
 SERVICE_LCRSO          = syncv2
@@ -50,7 +50,7 @@ LCRSO                 = $(SERVICE_LCRSO:%=service_%.lcrso)
 LCRSO_OBJS             = $(SOURCES:%.c=%.o)
 else
 noinst_PROGRAMS = $(TEST_AGENTS)
-noinst_SCRIPTS = mem_leak_test.sh net_breaker.sh
+noinst_SCRIPTS = mem_leak_test.sh net_breaker.sh shm_leak_audit.sh
 LCRSO =
 LCRSO_OBJS =
 endif
diff --git a/cts/agents/shm_leak_audit.sh b/cts/agents/shm_leak_audit.sh
new file mode 100755
index 0000000..6da16ef
--- /dev/null
+++ b/cts/agents/shm_leak_audit.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+
+/etc/init.d/corosync status >/dev/null
+CS_STATUS=$?
+
+if [ $CS_STATUS -eq 0 ]
+then
+       # corosync running
+       active=$(corosync-objctl runtime.connections. | grep active | cut -d= 
-f2)
+       if [ $active -lt 2 ]
+       then
+               FILES=$(ls /dev/shm/qb-*)
+               for f in $FILES
+               do
+                       echo $f
+               done
+       else
+               pids=$(corosync-objctl runtime.connections. | grep client_pid | 
cut -d= -f2)
+
+               FILES=$(ls /dev/shm/qb-*)
+               for f in $FILES
+               do
+                       found=0
+                       for p in $pids
+                       do
+                               if [[ "$f" =~ "$p" ]]
+                               then
+                                       found=1
+                               fi
+                       done
+                       if [ $found -eq 0 ]
+                       then
+                               echo $f
+                       fi
+               done    
+       fi
+else
+       FILES=$(ls /dev/shm/qb-*)
+       for f in $FILES
+       do
+               echo $f
+       done
+fi
+
+exit 0
+
diff --git a/cts/corolab.py b/cts/corolab.py
index d5d5241..664f0e9 100755
--- a/cts/corolab.py
+++ b/cts/corolab.py
@@ -39,7 +39,6 @@ Copyright (c) 2010 Red Hat, Inc.
 # THE POSSIBILITY OF SUCH DAMAGE.
 
 import sys
-from cts.CTSaudits import AuditList
 from cts.CTSscenarios import *
 from corotests import CoroTestList
 from corosync import *
@@ -274,7 +273,7 @@ if __name__ == '__main__':
 
     # Create the Cluster Manager object
     cm = Environment['CMclass'](Environment)
-    Audits = AuditList(cm)
+    Audits = CoroAuditList(cm)
         
     if Environment["ListTests"] == 1 :
         Tests = CoroTestList(cm, Audits)
diff --git a/cts/corosync.py b/cts/corosync.py
index 18691c1..d4b9b58 100644
--- a/cts/corosync.py
+++ b/cts/corosync.py
@@ -47,6 +47,8 @@ from cts.CTS import ClusterManager
 from cts.CTSscenarios import ScenarioComponent
 from cts.CTS import RemoteExec
 from cts.CTSvars import CTSvars
+from cts.CTSaudits import ClusterAudit
+from cts.CTSaudits import LogAudit
 
 
 ###################################################################
@@ -328,6 +330,28 @@ class corosync_needle(ClusterManager):
     def Components(self):    
         return None
 
+class ShmLeakAudit(ClusterAudit):
+
+    def __init__(self, cm):
+        self.CM = cm
+
+    def name(self):
+        return "ShmLeakAudit"
+
+    def is_applicable(self):
+        return 1
+
+    def __call__(self):
+        rc = 1
+
+        for node in self.CM.Env["nodes"]:
+            (res, lines) = self.CM.rsh(node, 
"/usr/share/corosync/tests/shm_leak_audit.sh", None)
+            for line in lines:
+                self.CM.log("%s leaked %s" % (node, line))
+                rc = 0
+
+        return rc
+
 
 ###################################################################
 class TestAgentComponent(ScenarioComponent):
@@ -485,6 +509,7 @@ class TestAgent(object):
         try:
             res = self.read ()
         except RuntimeError, msg:
+            res = None
             self.env.log("send_recv_dynamic: %s(); error: %s" % 
(self.func_name, msg))
 
         return res
@@ -630,3 +655,17 @@ class VoteQuorumTestAgent(TestAgent):
             self.init()
             self.used = False
 
+AllAuditClasses = []
+AllAuditClasses.append(LogAudit)
+AllAuditClasses.append(ShmLeakAudit)
+
+def CoroAuditList(cm):
+    result = []
+    for auditclass in AllAuditClasses:
+        a = auditclass(cm)
+        if a.is_applicable():
+            result.append(a)
+    return result
+
+
+
-- 
1.7.3.1

_______________________________________________
Openais mailing list
Openais@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to