فهرست منبع

CTS: add a test for sync events

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2742 fd59a12c-fef9-0310-b244-a6a79926bd2f
Angus Salkeld 16 سال پیش
والد
کامیت
15afe1d192
5فایلهای تغییر یافته به همراه139 افزوده شده و 3 حذف شده
  1. 7 1
      conf/lenses/corosync.aug
  2. 47 0
      cts/agents/Makefile.am
  3. 2 0
      cts/corosync.py
  4. 80 1
      cts/corotests.py
  5. 3 1
      include/corosync/corodefs.h

+ 7 - 1
conf/lenses/corosync.aug

@@ -122,6 +122,12 @@ let quorum =
    qstr /provider/ in
   section "quorum" setting
 
-let lns = (comment|empty|compatibility|totem|quorum|logging|amf)*
+(* The service section *)
+let service =
+  let setting =
+   qstr /name|ver/ in
+  section "service" setting
+
+let lns = (comment|empty|compatibility|totem|quorum|logging|amf|service)*
 
 let xfm = transform lns (incl "/etc/corosync/corosync.conf")

+ 47 - 0
cts/agents/Makefile.am

@@ -32,15 +32,24 @@
 MAINTAINERCLEANFILES = Makefile.in
 INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
 
+SOURCES =
 TEST_AGENTS = cpg_test_agent confdb_test_agent
 
 if INSTALL_TESTAGENTS
 agentdir = $(datadir)/$(PACKAGE)/tests
 bin_PROGRAMS = $(TEST_AGENTS)
 dist_agent_SCRIPTS = mem_leak_test.sh net_breaker.sh
+
+AM_CFLAGS		= -fPIC
+SERVICE_LCRSO		= syncv2
+SOURCES			+= $(SERVICE_LCRSO:%=%.c)
+EXTRA_DIST		= $(SOURCES)
+LCRSO			= $(SERVICE_LCRSO:%=service_%.lcrso)
+LCRSO_OBJS		= $(SOURCES:%.c=%.o)
 else
 noinst_PROGRAMS = $(TEST_AGENTS)
 noinst_SCRIPTS = mem_leak_test.sh net_breaker.sh
+LCRSO =
 endif
 
 noinst_HEADERS          = common_test_agent.h
@@ -53,6 +62,44 @@ confdb_test_agent_SOURCES = confdb_test_agent.c common_test_agent.c
 confdb_test_agent_LDADD =  -lconfdb -lcoroipcc ../../exec/coropoll.o
 confdb_test_agent_LDFLAGS =  -L../../lib 
 
+
+if BUILD_DARWIN
+
+service_%.lcrso: %.o
+	$(CC) $(CFLAGS) -L$(top_builddir)/exec -llogsys -bundle -bundle_loader $(top_builddir)/exec/corosync $^ -o $@
+
+else
+if BUILD_SOLARIS
+
+service_%.lcrso: %.o
+	$(LD) $(LDFLAGS) -G $^ -o $@
+
+else
+
+service_%.lcrso: %.o
+	$(CC) $(CFLAGS) $(COVERAGE_LCRSO_EXTRA_LDFLAGS) -shared -Wl,-soname=$@ $^ -o $@
+endif
+endif
+
+
+
+if INSTALL_TESTAGENTS
+all-local: $(LCRSO_OBJS) $(LCRSO)
+	@echo Built Service Engines
+
+install-exec-local:
+	$(INSTALL) -d $(DESTDIR)/$(LCRSODIR)
+	$(INSTALL) -m 755 $(LCRSO) $(DESTDIR)/$(LCRSODIR)
+
+uninstall-local:
+	cd $(DESTDIR)/$(LCRSODIR) && \
+		rm -f $(LCRSO)
+
+endif
+
+clean-local:
+	rm -f *.o *.a *.so* *.da *.bb *.bbg *.lcrso
+
 lint:
 	-splint $(LINT_FLAGS) $(CFLAGS) *.c
 

+ 2 - 0
cts/corosync.py

@@ -141,6 +141,8 @@ class corosync_flatiron(ClusterManager):
         self.node_to_ip = {}
         
         self.new_config = {}
+        self.new_config['service[0]/name'] = 'corosync_tst_sv2'
+        self.new_config['service[0]/ver'] = '0'
         self.applied_config = {}
         for n in self.Env["nodes"]:
             ip = socket.gethostbyname(n)

+ 80 - 1
cts/corotests.py

@@ -178,6 +178,83 @@ class CpgCfgChgOnNodeLeave(CpgConfigChangeBase):
         self.failure_action()
         return self.wait_for_config_change()
 
+###################################################################
+class CpgCfgChgOnLowestNodeJoin(CTSTest):
+    '''
+    1) stop all nodes
+    2) start all but the node with the smallest ip address
+    3) start recording events
+    4) start the last node
+    '''
+    def __init__(self, cm):
+        CTSTest.__init__(self, cm)
+        self.name="CpgCfgChgOnLowestNodeJoin"
+        self.start = StartTest(cm)
+        self.stop = StopTest(cm)
+        self.config = {}
+        self.config['compatibility'] = 'none'
+
+    def lowest_ip_set(self):
+        self.lowest = None
+        for n in self.CM.Env["nodes"]:
+            if self.lowest is None:
+                self.lowest = n
+
+        self.CM.log("lowest node is " + self.lowest)
+
+    def setup(self, node):
+        # stop all nodes
+        for n in self.CM.Env["nodes"]:
+            self.CM.StopaCM(n)
+
+        self.lowest_ip_set()
+
+        # copy over any new config
+        for c in self.config:
+            self.CM.new_config[c] = self.config[c]
+
+        # install the config
+        self.CM.install_all_config()
+
+        # start all but lowest
+        self.listener = None
+        for n in self.CM.Env["nodes"]:
+            if n is not self.lowest:
+                if self.listener is None:
+                    self.listener = n
+                self.incr("started")
+                self.CM.log("starting " + n)
+                self.start(n)
+                self.CM.cpg_agent[n].clean_start()
+                self.CM.cpg_agent[n].cpg_join(self.name)
+
+        # start recording events
+        pats = []
+        pats.append("%s .*sync: node joined.*" % self.listener)
+        pats.append("%s .*sync: activate correctly.*" % self.listener)
+        self.sync_log = self.create_watch(pats, 60)
+        self.sync_log.setwatch()
+                
+        self.CM.log("setup done")
+
+        return CTSTest.setup(self, node)
+
+
+    def __call__(self, node):
+        self.incr("calls")
+
+        self.start(self.lowest)
+        self.CM.cpg_agent[self.lowest].clean_start()
+        self.CM.cpg_agent[self.lowest].cpg_join(self.name)
+        self.wobbly_id = self.CM.cpg_agent[self.lowest].cpg_local_get()
+
+        self.CM.log("waiting for sync events")
+        if not self.sync_log.lookforall():
+            return self.failure("Patterns not found: " + repr(self.sync_log.unmatched))
+        else:
+            return self.success()
+
+
 ###################################################################
 class CpgCfgChgOnExecCrash(CpgConfigChangeBase):
 
@@ -495,6 +572,7 @@ GenTestClasses.append(CpgCfgChgOnExecCrash)
 GenTestClasses.append(CpgCfgChgOnGroupLeave)
 GenTestClasses.append(CpgCfgChgOnNodeLeave)
 GenTestClasses.append(CpgCfgChgOnNodeIsolate)
+GenTestClasses.append(CpgCfgChgOnLowestNodeJoin)
 
 AllTestClasses = []
 AllTestClasses.append(ConfdbReplaceTest)
@@ -585,7 +663,8 @@ def CoroTestList(cm, audits):
             bound_test = testclass(cm)
             if bound_test.is_applicable():
                 bound_test.Audits = audits
-                bound_test.config = cfg
+                for c in cfg:
+                    bound_test.config[c] = cfg[c]
                 bound_test.name = bound_test.name + '_' + str(num)
                 result.append(bound_test)
         num = num + 1

+ 3 - 1
include/corosync/corodefs.h

@@ -57,7 +57,9 @@ enum corosync_service_types {
 	TMR_SERVICE = 14,
 	VOTEQUORUM_SERVICE = 15,
 	NTF_SERVICE = 16,
-	AMF_V2_SERVICE = 17
+	AMF_V2_SERVICE = 17,
+	TST_SV1_SERVICE = 18,
+	TST_SV2_SERVICE = 19
 };
 
 #ifdef HAVE_SMALL_MEMORY_FOOTPRINT