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

ugaston
18.45.2007 d734fd078702dcf908523ab093e6994d571a406b
Add replication failover testsuite
2 files added
2 files modified
385 ■■■■■ changed files
opends/tests/functional-tests/config/replication/3server_topology.txt 41 ●●●●● patch | view | raw | blame | history
opends/tests/functional-tests/shared/functions/topology.xml 12 ●●●● patch | view | raw | blame | history
opends/tests/functional-tests/testcases/replication/failover/failover.xml 330 ●●●●● patch | view | raw | blame | history
opends/tests/functional-tests/testcases/replication/replication.xml 2 ●●● patch | view | raw | blame | history
opends/tests/functional-tests/config/replication/3server_topology.txt
New file
@@ -0,0 +1,41 @@
Hostname: localhost
Directory: /tmp/opends-synchro-tests/server1
Port: 11389
Sslport: 11636
Jmxport: 11689
RootDn: cn=directory manager
RootPwd: secret12
BaseDn: o=example
Changelogport: 11111
SynchronizedSuffix: o=example
ChangelogServer: localhost:11111
ChangelogServer: localhost:22222
ChangelogServer: localhost:33333
Hostname: localhost
Directory: /tmp/opends-synchro-tests/server2
Port: 22389
Sslport: 22636
Jmxport: 22689
RootDn: cn=directory manager
RootPwd: secret12
BaseDn: o=example
Changelogport: 22222
SynchronizedSuffix: o=example
ChangelogServer: localhost:11111
ChangelogServer: localhost:22222
ChangelogServer: localhost:33333
Hostname: localhost
Directory: /tmp/opends-synchro-tests/server3
Port: 33389
Sslport: 33636
Jmxport: 33689
RootDn: cn=directory manager
RootPwd: secret12
BaseDn: o=example
Changelogport: 33333
SynchronizedSuffix: o=example
ChangelogServer: localhost:11111
ChangelogServer: localhost:22222
ChangelogServer: localhost:33333
opends/tests/functional-tests/shared/functions/topology.xml
@@ -944,14 +944,16 @@
      
      <function-arg-def name="dsInstanceHost"
                        type="optional"
                        default="STAF_REMOTE_HOSTNAME">
                        default="None">
        <function-arg-description>
          Directory server hostname or IP address
        </function-arg-description>
        <function-arg-property name="type" value="hostname" />
      </function-arg-def>
      
      <function-arg-def name="dsInstancePort" type="required">
      <function-arg-def name="dsInstancePort"
                        type="optional"
                        default="None">
        <function-arg-description>
          Directory server port number
        </function-arg-description>
@@ -1018,7 +1020,11 @@
          STAFCmd='%s/%s%s' % (dsBinPath,DSREPLICATION,fileExt)
        
        STAFCmdParamsList=[]
        STAFCmdParamsList.append('initialize')
        if dsInstanceHost:
          STAFCmdParamsList.append('initialize')
        else:
          STAFCmdParamsList.append('initialize-all')
        STAFCmdParamsList.append('-n')                    
        STAFCmdParamsList.append('-Q')
          
opends/tests/functional-tests/testcases/replication/failover/failover.xml
New file
@@ -0,0 +1,330 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../../shared/stax.dtd">
<!--
 ! CDDL HEADER START
 !
 ! The contents of this file are subject to the terms of the
 ! Common Development and Distribution License, Version 1.0 only
 ! (the "License").  You may not use this file except in compliance
 ! with the License.
 !
 ! You can obtain a copy of the license at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
 ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 ! See the License for the specific language governing permissions
 ! and limitations under the License.
 !
 ! When distributing Covered Code, include this CDDL HEADER in each
 ! file and include the License file at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 ! add the following below this CDDL HEADER, with the fields enclosed
 ! by brackets "[]" replaced with your own identifying information:
 !      Portions Copyright [yyyy] [name of copyright owner]
 !
 ! CDDL HEADER END
 !
 !      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 ! -->
<stax>
  <defaultcall function="replication_failover"/>
  <function name="replication_failover">
    <sequence>
      <block name="'failover'">
        <sequence>
          <script>
            if not CurrentTestPath.has_key('group'):
              CurrentTestPath['group']='replication'
            CurrentTestPath['suite']=STAXCurrentBlock
          </script>
          <call function="'testSuite_Preamble'"/>
          <!--- Test Suite information
          #@TestSuiteName       Replication Failover Tests
          #@TestSuitePurpose    Verify that the failover of a replication server does not affect replication.
          #@TestSuiteID         Failover Tests
          #@TestSuiteGroup      Failover
          #@TestGroup           Replication
          #@TestScript          replication_failover.xml
          #@TestHTMLLink        http://opends.dev.java.net/
          -->
          <import machine="STAF_LOCAL_HOSTNAME"
            file="'%s/testcases/replication/replication_setup.xml' % (TESTS_DIR)"/>
          <call function="'replication_setup'">
            {  'topologyFile'  :  '%s/config/replication/3server_topology.txt' % TESTS_DIR  }
          </call>
          <script>
            synchroSuffix = master.getSynchronizedSuffixList()[0].getSuffixDn()
            replServerList = master.getSynchronizedSuffixList()[0].getChangelogServerList()
          </script>
          <!-- Load entries into "master" server -->
          <!-- Stop "master" Directory Server -->
          <call function="'StopDsWithScript'">
            { 'location'  : masterHost,
              'dsPath'    : masterPath,
              'dsHost'    : masterHost,
              'dsPort'    : master.getPort(),
              'dsBindDN'  : master.getRootDn(),
              'dsBindPwd' : master.getRootPwd()
            }
          </call>
          <!-- Import data into "master" Directory Server -->
          <call function="'ImportLdifWithScript'">
            { 'location'     : masterHost,
              'dsPath'       : masterPath,
              'dsBackEnd'    : 'userRoot',
              'dsLdifFile'   : '%s/replication/Example.ldif' % masterDataDir
            }
          </call>
          <!-- Start the Directory Server -->
          <call function="'StartDsWithScript'">
            { 'location'  : masterHost,
              'dsPath'    : masterPath
            }
          </call>
          <!-- Wait for DS to start -->
          <call function="'isAlive'">
            { 'location'         : masterHost,
              'dsPath'           : masterPath,
              'dsInstanceHost'   : masterHost,
              'dsInstancePort'   : master.getPort() ,
              'dsInstanceDn'     : master.getRootDn() ,
              'dsInstancePswd'   : master.getRootPwd() ,
              'noOfLoops'        : 10 ,
              'noOfMilliSeconds' : 2000
            }
          </call>
          <!-- Initialise the servers in the topology -->
<!--
          <call function="'initializeReplication'">
            { 'location'  :  clientHost,
              'dsPath'  :  clientPath,
              'sourceInstanceHost'  :  masterHost,
              'sourceInstancePort'  :  master.getPort(),
              'replicationDnList'  :  ['o=example']
            }
          </call>
-->
          <iterate var="server" in="consumerList">
            <!-- Perform the total update -->
            <call function="'initializeReplication'">
              { 'location'  :  clientHost,
                'dsPath'  :  clientPath,
                'dsInstanceHost'  :  server.getHostname(),
                'dsInstancePort'  :  server.getPort(),
                'sourceInstanceHost'  :  masterHost,
                'sourceInstancePort'  :  master.getPort(),
                'replicationDnList'  :  ['o=example']
              }
            </call>
          </iterate>
          <!--- Test Case information
          #@TestMarker          Replication Failover Tests
          #@TestName            Replication: Failover: One server down
          #@TestID                  One server down
          #@TestPurpose        Check replication when one server fails
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="getTestCaseName('One server down')">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                 'Replication: Failover: One server down. Check replication when one server fails'
              </message>
              <iterate var="server" in="_topologyServerList" indexvar="i">
                <sequence>
                  <script>
                    serverPath = '%s/%s' % (server.getDir(), OPENDSNAME)
                    nbOfServers = len(_topologyServerList)
                    nextServer = _topologyServerList[(i + 1) % nbOfServers]
                    nextServerPath = '%s/%s' % (nextServer.getDir(), OPENDSNAME)
                    userDn = 'uid=iabizen-%s, ou=People, %s' % (i, synchroSuffix)
                  </script>
                  <!-- Stop server (simulate failover?) -->
                  <call function="'StopDsWithScript'">
                    { 'location'  :  server.getHostname(),
                      'dsPath'    :  serverPath,
                      'dsHost'    :  server.getHostname(),
                      'dsPort'    :  server.getPort(),
                      'dsBindDN'  :  server.getRootDn(),
                      'dsBindPwd' :  server.getRootPwd()
                    }
                  </call>
                  <!-- Add entry to one of the other servers -->
                  <script>
                    listAttr = []
                    listAttr.append('objectclass:top')
                    listAttr.append('objectclass:organizationalperson')
                    listAttr.append('objectclass:inetorgperson')
                    listAttr.append('objectclass:person')
                    listAttr.append('givenname:Izen-%s' % i)
                    listAttr.append('sn:Abizen-%s' % i)
                    listAttr.append('cn:Izen-%s Abizen-%s' % (i, i))
                  </script>
                  <call function="'addAnEntry'">
                    { 'location'  :  nextServer.getHostname(),
                      'dsPath'  :  nextServerPath,
                      'dsInstanceHost'  :  nextServer.getHostname(),
                      'dsInstancePort'  :  nextServer.getPort(),
                      'dsInstanceDn'  :  nextServer.getRootDn(),
                      'dsInstancePswd'  :  nextServer.getRootPwd(),
                      'DNToAdd'  :  userDn,
                      'listAttributes' : listAttr,
                      'expectedRC'     :  0
                    }
                  </call>
                  <!-- Start the server again -->
                  <call function="'StartDsWithScript'">
                    { 'location'  :  server.getHostname(),
                      'dsPath'    :  serverPath
                    }
                  </call>
                </sequence>
              </iterate>
              <!-- Verify the synchronization of the trees among the servers in the topology -->
              <call function="'verifyTrees'">
                [ clientHost, clientPath, master, consumerList, synchroSuffix ]
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Replication Failover Tests
          #@TestName            Replication: Failover: All but one servers down
          #@TestID                  One server down
          #@TestPurpose        Check replication when all but one servers fail
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="getTestCaseName('All but one servers down')">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                 'Replication: Failover: All but one servers down. Check replication when all but one servers fail'
              </message>
              <paralleliterate var="server" in="consumerList">
                <sequence>
                  <script>
                    serverPath = '%s/%s' % (server.getDir(), OPENDSNAME)
                  </script>
                  <!-- Stop server (simulate failover?) -->
                  <call function="'StopDsWithScript'">
                    { 'location'  :  server.getHostname(),
                      'dsPath'    :  serverPath,
                      'dsHost'    :  server.getHostname(),
                      'dsPort'    :  server.getPort(),
                      'dsBindDN'  :  server.getRootDn(),
                      'dsBindPwd' :  server.getRootPwd()
                    }
                  </call>
                </sequence>
              </paralleliterate>
              <!-- Add entry to master servers -->
              <script>
                userDn = 'uid=iabizen-berri, ou=People, %s' % synchroSuffix
                listAttr = []
                listAttr.append('objectclass:top')
                listAttr.append('objectclass:organizationalperson')
                listAttr.append('objectclass:inetorgperson')
                listAttr.append('objectclass:person')
                listAttr.append('givenname:Izen-berri')
                listAttr.append('sn:Abizen-berri')
                listAttr.append('cn:Izen-berri Abizen-berri')
              </script>
              <call function="'addAnEntry'">
                { 'location'  :  masterHost,
                  'dsPath'  :  masterPath,
                  'dsInstanceHost'  :  masterHost,
                  'dsInstancePort'  :  master.getPort(),
                  'dsInstanceDn'  :  master.getRootDn(),
                  'dsInstancePswd'  :  master.getRootPwd(),
                  'DNToAdd'  :  userDn,
                  'listAttributes' : listAttr,
                  'expectedRC'     :  0
                }
              </call>
              <paralleliterate var="server" in="consumerList">
                <sequence>
                  <script>
                    serverPath = '%s/%s' % (server.getDir(), OPENDSNAME)
                  </script>
                  <!-- Start the server again -->
                  <call function="'StartDsWithScript'">
                    { 'location'  :  server.getHostname(),
                      'dsPath'    :  serverPath
                    }
                  </call>
                </sequence>
              </paralleliterate>
              <!-- Verify the synchronization of the trees among the servers in the topology -->
              <call function="'verifyTrees'">
                [ clientHost, clientPath, master, consumerList, synchroSuffix ]
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <import machine="STAF_LOCAL_HOSTNAME"
            file="'%s/testcases/replication/replication_cleanup.xml' % (TESTS_DIR)"/>
          <call function="'replication_cleanup'" />
          <call function="'testSuite_Postamble'"/>
        </sequence>
      </block>
    </sequence>
  </function>
</stax>
opends/tests/functional-tests/testcases/replication/replication.xml
@@ -37,7 +37,7 @@
            CurrentTestPath['group']='replication'
          </script>
          <call function="'testGroup_Preamble'"/>
          <iterate  var="_test" in="['totalupdate','binarycopy','ldifimport','resynchronization','basic','schema']">
          <iterate  var="_test" in="['totalupdate','binarycopy','ldifimport','resynchronization','basic','schema','failover']">
            <sequence>
              <import machine="STAF_LOCAL_HOSTNAME"
                      file="'%s/testcases/replication/%s/%s.xml' % (TESTS_DIR,_test,_test)"/>