From c709ecc706fcbf697c440d8266df93d73576eb3d Mon Sep 17 00:00:00 2001
From: ugaston <ugaston@localhost>
Date: Mon, 17 Aug 2009 17:50:11 +0000
Subject: [PATCH] Replication tests: verifyTrees refactoring + extend disableReplicaton function + small fixes
---
opends/tests/staf-tests/functional-tests/testcases/replication/resynchronization/resynchronization.xml | 2
opends/tests/staf-tests/shared/functions/topology.xml | 233 +++++++++++++++++++++++++++++++++++-----------
opends/tests/staf-tests/shared/functions/tools.xml | 18 +++
opends/tests/staf-tests/functional-tests/testcases/replication/replication_setup.xml | 29 +++++
opends/tests/staf-tests/functional-tests/testcases/replication-safe-data/replication-safe-data.xml | 5 +
opends/tests/staf-tests/functional-tests/testcases/replication-safe-read/replication-safe-read.xml | 5 +
6 files changed, 229 insertions(+), 63 deletions(-)
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication-safe-data/replication-safe-data.xml b/opends/tests/staf-tests/functional-tests/testcases/replication-safe-data/replication-safe-data.xml
index e44015c..b9b471e 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication-safe-data/replication-safe-data.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication-safe-data/replication-safe-data.xml
@@ -65,6 +65,11 @@
ownTestList = []
globalAssuredReplication = 'safe-data'
+
+ if (REPLICATION_SPLIT_SERVERS == 'true'):
+ globalSplitServers = True
+ else:
+ globalSplitServers = None
</script>
<iterate var="_test" in="commonTestList" >
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication-safe-read/replication-safe-read.xml b/opends/tests/staf-tests/functional-tests/testcases/replication-safe-read/replication-safe-read.xml
index 61cfb06..603a6f8 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication-safe-read/replication-safe-read.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication-safe-read/replication-safe-read.xml
@@ -65,6 +65,11 @@
ownTestList = []
globalAssuredReplication = 'safe-read'
+
+ if (REPLICATION_SPLIT_SERVERS == 'true'):
+ globalSplitServers = True
+ else:
+ globalSplitServers = None
</script>
<iterate var="_test" in="commonTestList" >
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/replication_setup.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/replication_setup.xml
index b3d93e8..f60864a 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/replication_setup.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/replication_setup.xml
@@ -158,8 +158,33 @@
<!-- Start the servers in the topology -->
<call function="'startServers'">
[_splitServerList]
- </call>
-
+ </call>
+
+ <if expr="len(_topologyReplServerList) != 0">
+ <paralleliterate var="replServer" in="_topologyReplServerList">
+ <!-- Remove userRoot backend from replication servers -->
+ <sequence>
+ <message>
+ 'Remove userRoot backend from replication server %s:%s' % \
+ (replServer.getHostname(), replServer.getPort())
+ </message>
+
+ <call function="'dsconfig'">
+ { 'location' : replServer.getHostname(),
+ 'dsPath' : '%s/%s' \
+ % (replServer.getDir(),OPENDSNAME),
+ 'dsInstanceHost' : replServer.getHostname(),
+ 'dsInstanceAdminPort' : replServer.getAdminPort(),
+ 'dsInstanceDn' : replServer.getRootDn(),
+ 'dsInstancePswd' : replServer.getRootPwd(),
+ 'subcommand' : 'delete-backend',
+ 'objectType' : 'backend-name',
+ 'objectName' : 'userRoot'
+ }
+ </call>
+ </sequence>
+ </paralleliterate>
+ </if>
<iterate var="server" in="_splitServerList[1:]">
<sequence>
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/resynchronization/resynchronization.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/resynchronization/resynchronization.xml
index bd9896e..9baf1d2 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/resynchronization/resynchronization.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/resynchronization/resynchronization.xml
@@ -75,7 +75,7 @@
'dsPath' : clientPath,
'dsInstanceHost' : server3.getHostname(),
'dsInstanceAdminPort' : server3.getAdminPort(),
- 'replicationDnList' : [synchroSuffix]
+ 'disableAll' : True
}
</call>
diff --git a/opends/tests/staf-tests/shared/functions/tools.xml b/opends/tests/staf-tests/shared/functions/tools.xml
index 835f2a5..9f92d08 100755
--- a/opends/tests/staf-tests/shared/functions/tools.xml
+++ b/opends/tests/staf-tests/shared/functions/tools.xml
@@ -669,7 +669,7 @@
</function-arg-def>
</function-list-args>
- <sequence>
+ <sequence>
<script>
myRC = 0
myKnownIssue = knownIssue
@@ -680,7 +680,21 @@
sampleTree = 'sampleTree.ldif'
treeDiffs = 'treeDiffs.ldif'
</script>
- <message>
+
+ <!-- Verify the synchronization of the trees among the servers in
+ the topology -->
+ <call function="'getReplicationStatus'">
+ { 'location' : location,
+ 'dsPath' : dsPath,
+ 'dsInstanceHost' : referenceServer.getHostname(),
+ 'dsInstanceAdminPort' : referenceServer.getAdminPort(),
+ 'replicationDnList' : [synchroSuffix],
+ 'noOfLoops' : 10,
+ 'noOfMilliSeconds' : 6000
+ }
+ </call>
+
+ <message>
'Verify tree %s taking %s as reference.' \
% (treeSuffix, referenceServerPath)
</message>
diff --git a/opends/tests/staf-tests/shared/functions/topology.xml b/opends/tests/staf-tests/shared/functions/topology.xml
index 50ee148..4b1b503 100755
--- a/opends/tests/staf-tests/shared/functions/topology.xml
+++ b/opends/tests/staf-tests/shared/functions/topology.xml
@@ -1499,12 +1499,33 @@
<function-arg-property name="type" value="Port number" />
</function-arg-def>
- <function-arg-def name="replicationDnList" type="required">
+ <function-arg-def name="replicationDnList"
+ type="optional"
+ default="None">
<function-arg-description>
DN of the replicated suffix
</function-arg-description>
<function-arg-property name="type" value="DN list" />
- </function-arg-def>
+ </function-arg-def>
+
+ <function-arg-def name="disableReplServer"
+ type="optional"
+ default="None">
+ <function-arg-description>
+ Disable replication server (remove configuration, changelot and port)
+ </function-arg-description>
+ <function-arg-property name="type" value="boolean" />
+ </function-arg-def>
+
+ <function-arg-def name="disableAll"
+ type="optional"
+ default="None">
+ <function-arg-description>
+ Disable replication completely (domain, repl-server, changelog and
+ admin data).
+ </function-arg-description>
+ <function-arg-property name="type" value="boolean" />
+ </function-arg-def>
<function-arg-def name="adminUID"
type="optional"
@@ -1557,6 +1578,12 @@
if replicationDnList:
for dn in replicationDnList:
STAFCmdParamsList.append('-b "%s"' % dn)
+
+ if disableReplServer:
+ STAFCmdParamsList.append('--disableReplicationServer')
+
+ if disableAll:
+ STAFCmdParamsList.append('--disableAll')
if adminUID:
STAFCmdParamsList.append('-I "%s"' % adminUID)
@@ -2688,8 +2715,8 @@
</function-arg-def>
<function-arg-def name="adminUID"
- type="optional"
- default="AdminUID">
+ type="optional"
+ default="AdminUID">
<function-arg-description>
Global Administrator UID
</function-arg-description>
@@ -2697,13 +2724,31 @@
</function-arg-def>
<function-arg-def name="adminPswd"
- type="optional"
- default="AdminPswd">
+ type="optional"
+ default="AdminPswd">
<function-arg-description>
Global Administrator password
</function-arg-description>
<function-arg-property name="type" value="string" />
- </function-arg-def>
+ </function-arg-def>
+
+ <function-arg-def name="noOfLoops"
+ type="optional"
+ default="1">
+ <function-arg-description>
+ Number of iterations
+ </function-arg-description>
+ <function-arg-property name="type" value="integer"/>
+ </function-arg-def>
+
+ <function-arg-def name="noOfMilliSeconds"
+ type="optional"
+ default="0">
+ <function-arg-description>
+ Number of milliseconds to wait between iterations
+ </function-arg-description>
+ <function-arg-property name="type" value="seconds"/>
+ </function-arg-def>
<function-arg-def name="expectedRC" type="optional" default="0">
<function-arg-description>
@@ -2753,31 +2798,108 @@
STAFCmdParams=' '.join(STAFCmdParamsList)
</script>
- <call function="'runCommand'">
- { 'name' : 'Get Replication Status',
- 'location' : location,
- 'command' : STAFCmd,
- 'arguments' : STAFCmdParams
- }
- </call>
-
- <script>
- commandRC = RC
- commandResult = STAXResult
- </script>
- <call function="'checktestRC'">
- { 'returncode' : commandRC,
- 'result' : commandResult,
- 'expected' : expectedRC
- }
- </call>
- <script>
- replStatusRC = commandResult[0][0]
- replStatusResult = commandResult[0][1]
- resultLength = len(replStatusResult) > 0
+ <script>
+ servernameList = []
+ entriesList = []
+ missingChangesList = []
+ ageList = []
+ replStatusRC = 0
+ resultLength = 0
+ refNbOfEntries = 'Unknown'
+ refServername = 'Unknown'
+
+ myLoop = 0
+ missingRC = True
</script>
-
+ <loop from="1" to="noOfLoops" while="missingRC == True">
+ <sequence>
+ <script>
+ myLoop = myLoop + 1
+ missingRC = False
+ </script>
+
+ <call function="'runCommand'">
+ { 'name' : 'Get Replication Status',
+ 'location' : location,
+ 'command' : STAFCmd,
+ 'arguments' : STAFCmdParams
+ }
+ </call>
+
+ <script>
+ commandRC = RC
+ commandResult = STAXResult
+ </script>
+ <call function="'checktestRC'">
+ { 'returncode' : commandRC,
+ 'result' : commandResult,
+ 'expected' : expectedRC
+ }
+ </call>
+ <if expr="commandRC != expectedRC">
+ <return> commandResult </return>
+ </if>
+
+ <script>
+ replStatusRC = commandResult[0][0]
+ replStatusResult = commandResult[0][1]
+ resultLength = len(replStatusResult) > 0
+ </script>
+
+ <if expr="(replStatusRC == 0) and (resultLength != 0)">
+ <sequence>
+ <script>
+ servernameList = []
+ entriesList = []
+ missingChangesList = []
+ ageList = []
+
+ for line in replStatusResult.splitlines():
+ if line.startswith('Server:'):
+ server = line[line.find('Server:') + 7:].strip()
+ servernameList.append(server)
+ elif line.startswith('Entries:'):
+ entries = line[line.find('Entries:') + 8:].strip()
+ entriesList.append(entries)
+ elif line.startswith('Missing Changes:'):
+ missingChanges = line[line.find('Missing') + 16:].strip()
+ missingChangesList.append(missingChanges)
+ elif line.startswith('Age of oldest missing change:'):
+ age = line[line.find('Age of') + 29:].strip()
+ ageList.append(age)
+ </script>
+
+ <iterate var="missing" in="missingChangesList">
+ <if expr="(missing != '0') and (missing != '--')">
+ <sequence>
+ <script>
+ missingRC = True
+ </script>
+ <break/>
+ </sequence>
+ </if>
+ </iterate>
+
+ <message>
+ 'getReplicationStatus LOOP %s => missingChanges? \
+ (True=1/False=0) : %s' % (myLoop, missingRC)
+ </message>
+
+ <if expr="missingRC == True">
+ <!-- If there are still missing changes, wait for some more time and
+ ! give the servers a chance to synchronise -->
+ <call function="'Sleep'">
+ { 'sleepForMilliSeconds' : noOfMilliSeconds }
+ </call>
+ </if>
+ </sequence>
+ </if>
+
+ </sequence>
+ </loop>
+
+
<if expr="(replStatusRC == 0) and (resultLength != 0)">
<sequence>
<message>
@@ -2785,37 +2907,32 @@
%s:%s : \n%s ' % \
(dsInstanceHost, dsInstanceAdminPort, replStatusResult)
</message>
- <script>
- serverList = []
- entriesList = []
- missingChangesList = []
- ageList = []
+
+ <iterate var="entries" in="entriesList" indexvar="i">
+ <if expr="entries.startswith('Server') == False">
+ <sequence>
+ <script>
+ refNbOfEntries = entries
+ refServername = servernameList[i]
+ </script>
+ <break/>
+ </sequence>
+ </if>
+ </iterate>
- for line in replStatusResult.splitlines():
- if line.startswith('Server:'):
- server = line[line.find('Server:') + 7:].strip()
- serverList.append(server)
- elif line.startswith('Entries:'):
- entries = line[line.find('Entries:') + 8:].strip()
- entriesList.append(entries)
- elif line.startswith('Missing Changes:'):
- missingChanges = line[line.find('Missing') + 16:].strip()
- missingChangesList.append(missingChanges)
- elif line.startswith('Age of oldest missing change:'):
- age = line[line.find('Age of') + 29:].strip()
- ageList.append(age)
-
- refNbOfEntries = entriesList[0]
- </script>
-
- <iterate var="server" in="serverList" indexvar="i">
+ <iterate var="server" in="servernameList" indexvar="i">
<sequence>
<script>
- entries = entriesList[i]
+ entries = entriesList[i]
missingChanges = missingChangesList[i]
- age = ageList[i]
+ age = ageList[i]
+
+ anyMissChg = (missingChanges != '0' and missingChanges != '--')
+ anyOldAge = (age != 'N/A' and age != '--')
+ anyEntries = (entries.startswith('Server') == False)
+ entriesDiff = (entries != refNbOfEntries)
</script>
- <if expr="(missingChanges != '0') or (age != 'N/A')">
+ <if expr="anyMissChg or anyOldAge">
<sequence>
<message log="1" level="'Error'">
'getReplicationStatus: Server %s is missing %s changes. \
@@ -2825,13 +2942,13 @@
<tcstatus result="'fail'"/>
</sequence>
</if>
- <if expr="entries != refNbOfEntries">
+ <if expr="anyEntries and entriesDiff">
<sequence>
<message log="1" level="'Error'">
'getReplicationStatus: Different number of entries.\n\
Server %s : %s entries\n\
Reference server %s : %s entries\n' % \
- (server, entries, serverList[0], refNbOfEntries)
+ (server, entries, refServername, refNbOfEntries)
</message>
<tcstatus result="'fail'"/>
</sequence>
--
Gitblit v1.10.0