mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

ugaston
17.50.2009 c709ecc706fcbf697c440d8266df93d73576eb3d
Replication tests: verifyTrees refactoring + extend disableReplicaton function + small fixes
6 files modified
196 ■■■■■ changed files
opends/tests/staf-tests/functional-tests/testcases/replication-safe-data/replication-safe-data.xml 5 ●●●●● patch | view | raw | blame | history
opends/tests/staf-tests/functional-tests/testcases/replication-safe-read/replication-safe-read.xml 5 ●●●●● patch | view | raw | blame | history
opends/tests/staf-tests/functional-tests/testcases/replication/replication_setup.xml 25 ●●●●● patch | view | raw | blame | history
opends/tests/staf-tests/functional-tests/testcases/replication/resynchronization/resynchronization.xml 2 ●●● patch | view | raw | blame | history
opends/tests/staf-tests/shared/functions/tools.xml 14 ●●●●● patch | view | raw | blame | history
opends/tests/staf-tests/shared/functions/topology.xml 145 ●●●●● patch | view | raw | blame | history
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" >
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" >
opends/tests/staf-tests/functional-tests/testcases/replication/replication_setup.xml
@@ -160,6 +160,31 @@
            [_splitServerList]
          </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>
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>
          
opends/tests/staf-tests/shared/functions/tools.xml
@@ -680,6 +680,20 @@
        sampleTree = 'sampleTree.ldif'
        treeDiffs = 'treeDiffs.ldif'
      </script>
      <!-- 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)
opends/tests/staf-tests/shared/functions/topology.xml
@@ -1499,13 +1499,34 @@
        <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 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"
                                   default="AdminUID">
@@ -1558,6 +1579,12 @@
          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)
      
@@ -2705,6 +2732,24 @@
        <function-arg-property name="type" value="string" />
      </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>
        Expected return code value. Default value is 0
@@ -2753,6 +2798,27 @@
                    
        STAFCmdParams=' '.join(STAFCmdParamsList)
      </script>
      <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,
@@ -2771,6 +2837,9 @@
          'expected'   : expectedRC
        }
      </call>
          <if expr="commandRC != expectedRC">
            <return> commandResult </return>
          </if>
      
      <script>
        replStatusRC = commandResult[0][0]
@@ -2780,13 +2849,8 @@
      
      <if expr="(replStatusRC == 0) and (resultLength != 0)">
        <sequence>
          <message>
            'getReplicationStatus: Replication status retrieved from server \
            %s:%s : \n%s ' % \
            (dsInstanceHost, dsInstanceAdminPort, replStatusResult)
          </message>
          <script>
            serverList = []
                servernameList     = []
            entriesList = []
            missingChangesList = []
            ageList = []
@@ -2794,7 +2858,7 @@
            for line in replStatusResult.splitlines():
              if line.startswith('Server:'):
                server = line[line.find('Server:') + 7:].strip()
                serverList.append(server)
                    servernameList.append(server)
              elif line.startswith('Entries:'):
                entries = line[line.find('Entries:') + 8:].strip()
                entriesList.append(entries)
@@ -2804,18 +2868,71 @@
              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="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>
            'getReplicationStatus: Replication status retrieved from server \
            %s:%s : \n%s ' % \
            (dsInstanceHost, dsInstanceAdminPort, replStatusResult)
          </message>
          <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>
          <iterate var="server" in="servernameList" indexvar="i">
            <sequence>
              <script>
                entries = entriesList[i]
                missingChanges = missingChangesList[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>