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

ugaston
27.36.2007 d993dc267d083728198af709abc8ca321c5d6432
New dsconfig wrappers + refactorying for replication configuration
5 files modified
583 ■■■■■ changed files
opends/tests/functional-tests/config/config.py 1 ●●●● patch | view | raw | blame | history
opends/tests/functional-tests/shared/functions/dsconfig.xml 455 ●●●●● patch | view | raw | blame | history
opends/tests/functional-tests/shared/functions/environment.xml 7 ●●●●● patch | view | raw | blame | history
opends/tests/functional-tests/shared/functions/topology.xml 114 ●●●●● patch | view | raw | blame | history
opends/tests/functional-tests/shared/functions/utils.xml 6 ●●●●● patch | view | raw | blame | history
opends/tests/functional-tests/config/config.py
@@ -28,4 +28,3 @@
LOGS_URI                    = ''
SEND_MAIL_AFTER_TEST_RUN    = 'false'
SEND_MAIL_TO                = ''
DSCONFIG                    = 'dsconfig'
opends/tests/functional-tests/shared/functions/dsconfig.xml
@@ -177,7 +177,7 @@
        <parms>'%s' % STAFCmdParams</parms>
        <workdir>'%s' % dsBinPath</workdir>
        <envs>
          ['PATH=/bin:/usr/bin:%s' % dsBinPath, 'JAVA_HOME=%s' % JAVA_HOME]
          ['PATH=/bin:/usr/bin:%s' % dsBinPath]
        </envs>
        <console use="'same'"/>
        <stderr mode="'stdout'"/>
@@ -296,13 +296,12 @@
        'expectedRC'             : expectedRC }
    </call>
            
    <if expr="expectedRC != 'noCheck'">
        <call function="'checktestRC'">
          { 'returncode' : STAXCode ,
            'result'     : STAXReason ,
            'expected'   : expectedRC }
        </call>
    </if>
    <return>
        STAXReason
    </return>
@@ -417,7 +416,7 @@
        <parms>'%s' % STAFCmdParams</parms>
        <workdir>'%s' % dsBinPath</workdir>
        <envs>
          ['PATH=/bin:/usr/bin:%s' % dsBinPath, 'JAVA_HOME=%s' % JAVA_HOME]
          ['PATH=/bin:/usr/bin:%s' % dsBinPath]
        </envs>
        <console use="'same'"/>
        <stderr mode="'stdout'"/>
@@ -428,13 +427,11 @@
        STAXCode=RC
        STAXReason=STAXResult
      </script>
      <if expr="expectedRC != 'noCheck'">
        <call function="'checktestRC'">
          { 'returncode' : STAXCode ,
            'result'     : STAXReason ,
            'expected'   : expectedRC }
        </call>
      </if>
      <return>
        STAXReason
      </return>
@@ -537,13 +534,11 @@
        'expectedRC'             : expectedRC }
    </call>
            
    <if expr="expectedRC != 'noCheck'">
        <call function="'checktestRC'">
          { 'returncode' : STAXCode ,
            'result'     : STAXReason ,
            'expected'   : expectedRC }
        </call>
    </if>
    <return>
        STAXReason
    </return>
@@ -646,13 +641,11 @@
        'expectedRC'             : expectedRC }
    </call>
            
    <if expr="expectedRC != 'noCheck'">
        <call function="'checktestRC'">
          { 'returncode' : STAXCode ,
            'result'     : STAXReason ,
            'expected'   : expectedRC }
        </call>
    </if>
    <return>
        STAXReason
    </return>
@@ -662,4 +655,446 @@
  </function>
  <!-- Create synchronization provider using dsconfig -->
  <function name="createSyncProvider">
    <function-prolog>
      This function creates a synchronization provider using dsconfig
    </function-prolog>
    <function-map-args>
      <function-arg-def name="location" type="optional" default="'%s' % STAF_REMOTE_HOSTNAME">
        <function-arg-description>
          Location of target host
        </function-arg-description>
        <function-arg-property name="type" value="hostname"/>
      </function-arg-def>
      <function-arg-def name="dsPath" type="optional" default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
        <function-arg-description>
          Pathname to installation root
        </function-arg-description>
        <function-arg-property name="type" value="filepath"/>
      </function-arg-def>
      <function-arg-def name="dsInstanceHost" type="optional" default="'%s' % STAF_REMOTE_HOSTNAME">
        <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-description>
          Directory server port number
        </function-arg-description>
        <function-arg-property name="type" value="Port number"/>
      </function-arg-def>
      <function-arg-def name="dsInstanceDn" type="required">
        <function-arg-description>
          Bind DN
        </function-arg-description>
        <function-arg-property name="type" value="DN"/>
      </function-arg-def>
      <function-arg-def name="dsInstancePswd" type="required">
        <function-arg-description>
          Bind password
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="providerName" type="optional" default="MultimasterSync">
        <function-arg-description>
          Name for the synchronization provider
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="providerType" type="optional" default="MultimasterType">
        <function-arg-description>
          Synchronization provider type
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="expectedRC" type="optional" default="0">
        <function-arg-description>
          Expected return code value. Default value is 0
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
    </function-map-args>
    <sequence>
      <!-- Local variables -->
      <script>
        mylocation=location
        STAFCmdParams=''
        STAFCmd=''
        if dsPath:
          dsBinPath='%s/%s' % (dsPath,fileFolder)
          STAFCmd='%s/%s%s' % (dsBinPath,DSCONFIG,fileExt)
        STAFCmdParamsList=[]
        STAFCmdParamsList.append('create-synchronization-provider')
        STAFCmdParamsList.append('--provider-name "%s"' % providerName)
        STAFCmdParamsList.append('-t %s' % providerType)
        STAFCmdParamsList.append('--set "enabled:true"')
      </script>
      <call function="'_dsconfigCommonArgs'"/>
      <script>
        STAFCmdParams=' '.join(STAFCmdParamsList)
      </script>
      <message>
        '%s %s' % (STAFCmd, STAFCmdParams)
      </message>
      <process name="'Modify dsconfig object'">
        <location>'%s' % location</location>
        <command>'%s' % STAFCmd</command>
        <parms>'%s' % STAFCmdParams</parms>
        <workdir>'%s' % dsBinPath</workdir>
        <envs>
          ['PATH=/bin:/usr/bin:%s' % dsBinPath]
        </envs>
        <console use="'same'"/>
        <stderr mode="'stdout'"/>
        <returnstdout/>
      </process>
      <script>
        STAXCode=RC
        STAXReason=STAXResult
      </script>
      <call function="'checktestRC'">
        { 'returncode' : STAXCode ,
          'result'     : STAXReason ,
          'expected'   : expectedRC }
      </call>
      <return>
        STAXReason
      </return>
    </sequence>
  </function>
  <!-- Create a replication server using dsconfig -->
  <function name="createReplicationServer">
    <function-prolog>
      This function creates a replication server under a given synchronization provider using dsconfig
    </function-prolog>
    <function-map-args>
      <function-arg-def name="location" type="optional" default="'%s' % STAF_REMOTE_HOSTNAME">
        <function-arg-description>
          Location of target host
        </function-arg-description>
        <function-arg-property name="type" value="hostname"/>
      </function-arg-def>
      <function-arg-def name="dsPath" type="optional" default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
        <function-arg-description>
          Pathname to installation root
        </function-arg-description>
        <function-arg-property name="type" value="filepath"/>
      </function-arg-def>
      <function-arg-def name="dsInstanceHost" type="optional" default="'%s' % STAF_REMOTE_HOSTNAME">
        <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-description>
          Directory server port number
        </function-arg-description>
        <function-arg-property name="type" value="Port number"/>
      </function-arg-def>
      <function-arg-def name="dsInstanceDn" type="required">
        <function-arg-description>
          Bind DN
        </function-arg-description>
        <function-arg-property name="type" value="DN"/>
      </function-arg-def>
      <function-arg-def name="dsInstancePswd" type="required">
        <function-arg-description>
          Bind password
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="providerName" type="optional" default="MultimasterSync">
        <function-arg-description>
          Name for the synchronization provider
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="replicationPort" type="required">
        <function-arg-description>
          Replication port number
        </function-arg-description>
        <function-arg-property name="type" value="Port number"/>
      </function-arg-def>
      <function-arg-def name="replicationServerId" type="required">
        <function-arg-description>
          Replication server ID
        </function-arg-description>
        <function-arg-property name="type" value="ID number"/>
      </function-arg-def>
      <function-arg-def name="replicationServerList" type="required">
        <function-arg-description>
          List of replication servers (as in host:replicationServerPort)
        </function-arg-description>
        <function-arg-property name="type" value="list"/>
      </function-arg-def>
      <function-arg-def name="expectedRC" type="optional" default="0">
        <function-arg-description>
          Expected return code value. Default value is 0
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
    </function-map-args>
    <sequence>
      <!-- Local variables -->
      <script>
        mylocation=location
        STAFCmdParams=''
        STAFCmd=''
        if dsPath:
          dsBinPath='%s/%s' % (dsPath,fileFolder)
          STAFCmd='%s/%s%s' % (dsBinPath,DSCONFIG,fileExt)
        STAFCmdParamsList=[]
        STAFCmdParamsList.append('create-replication-server')
        STAFCmdParamsList.append('--provider-name "%s"' % providerName)
        STAFCmdParamsList.append('--set "replication-port:%s"' % replicationPort)
        STAFCmdParamsList.append('--set "replication-server-id:%s"' % replicationServerId)
        for replServer in replicationServerList :
          STAFCmdParamsList.append('--set "replication-server:%s"' % replServer)
      </script>
      <call function="'_dsconfigCommonArgs'"/>
      <script>
        STAFCmdParams=' '.join(STAFCmdParamsList)
      </script>
      <message>
        '%s %s' % (STAFCmd, STAFCmdParams)
      </message>
      <process name="'Modify dsconfig object'">
        <location>'%s' % location</location>
        <command>'%s' % STAFCmd</command>
        <parms>'%s' % STAFCmdParams</parms>
        <workdir>'%s' % dsBinPath</workdir>
        <envs>
          ['PATH=/bin:/usr/bin:%s' % dsBinPath]
        </envs>
        <console use="'same'"/>
        <stderr mode="'stdout'"/>
        <returnstdout/>
      </process>
      <script>
        STAXCode=RC
        STAXReason=STAXResult
      </script>
      <call function="'checktestRC'">
        { 'returncode' : STAXCode ,
          'result'     : STAXReason ,
          'expected'   : expectedRC }
      </call>
      <return>
        STAXReason
      </return>
    </sequence>
  </function>
  <!-- Create a multimaster domain using dsconfig -->
  <function name="createMultimasterDomain">
    <function-prolog>
      This function creates a multimaster domain under a given synchronization provider using dsconfig
    </function-prolog>
    <function-map-args>
      <function-arg-def name="location" type="optional" default="'%s' % STAF_REMOTE_HOSTNAME">
        <function-arg-description>
          Location of target host
        </function-arg-description>
        <function-arg-property name="type" value="hostname"/>
      </function-arg-def>
      <function-arg-def name="dsPath" type="optional" default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
        <function-arg-description>
          Pathname to installation root
        </function-arg-description>
        <function-arg-property name="type" value="filepath"/>
      </function-arg-def>
      <function-arg-def name="dsInstanceHost" type="optional" default="'%s' % STAF_REMOTE_HOSTNAME">
        <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-description>
          Directory server port number
        </function-arg-description>
        <function-arg-property name="type" value="Port number"/>
      </function-arg-def>
      <function-arg-def name="dsInstanceDn" type="required">
        <function-arg-description>
          Bind DN
        </function-arg-description>
        <function-arg-property name="type" value="DN"/>
      </function-arg-def>
      <function-arg-def name="dsInstancePswd" type="required">
        <function-arg-description>
          Bind password
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="providerName" type="optional" default="MultimasterSync">
        <function-arg-description>
          Name for the synchronization provider
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="domainName" type="required">
        <function-arg-description>
          Name for multimaster domain
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="replicationDn" type="required">
        <function-arg-description>
          DN of the replicated suffix
        </function-arg-description>
        <function-arg-property name="type" value="DN"/>
      </function-arg-def>
      <function-arg-def name="serverId" type="required">
        <function-arg-description>
          Server ID
        </function-arg-description>
        <function-arg-property name="type" value="ID number"/>
      </function-arg-def>
      <function-arg-def name="replicationServerList" type="required">
        <function-arg-description>
          List of replication servers (as in host:replicationServerPort)
        </function-arg-description>
        <function-arg-property name="type" value="list"/>
      </function-arg-def>
      <function-arg-def name="expectedRC" type="optional" default="0">
        <function-arg-description>
          Expected return code value. Default value is 0
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
    </function-map-args>
    <sequence>
      <!-- Local variables -->
      <script>
        mylocation=location
        STAFCmdParams=''
        STAFCmd=''
        if dsPath:
          dsBinPath='%s/%s' % (dsPath,fileFolder)
          STAFCmd='%s/%s%s' % (dsBinPath,DSCONFIG,fileExt)
        STAFCmdParamsList=[]
        STAFCmdParamsList.append('create-multimaster-domain')
        STAFCmdParamsList.append('--provider-name "%s"' % providerName)
        STAFCmdParamsList.append('--domain-name "%s"' % domainName)
        STAFCmdParamsList.append('--set "replication-dn:%s"' % replicationDn)
        STAFCmdParamsList.append('--set "server-id:%s"' % serverId)
        for replServer in replicationServerList :
          STAFCmdParamsList.append('--set "replication-server:%s"' % replServer)
      </script>
      <call function="'_dsconfigCommonArgs'"/>
      <script>
        STAFCmdParams=' '.join(STAFCmdParamsList)
      </script>
      <message>
        '%s %s' % (STAFCmd, STAFCmdParams)
      </message>
      <process name="'Modify dsconfig object'">
        <location>'%s' % location</location>
        <command>'%s' % STAFCmd</command>
        <parms>'%s' % STAFCmdParams</parms>
        <workdir>'%s' % dsBinPath</workdir>
        <envs>
          ['PATH=/bin:/usr/bin:%s' % dsBinPath]
        </envs>
        <console use="'same'"/>
        <stderr mode="'stdout'"/>
        <returnstdout/>
      </process>
      <script>
        STAXCode=RC
        STAXReason=STAXResult
      </script>
      <call function="'checktestRC'">
        { 'returncode' : STAXCode ,
          'result'     : STAXReason ,
          'expected'   : expectedRC }
      </call>
      <return>
        STAXReason
      </return>
    </sequence>
  </function>
</stax>
opends/tests/functional-tests/shared/functions/environment.xml
@@ -147,6 +147,13 @@
        DSInfoServersDict={}
        True = 1
        False = 0                 
        DSCONFIG = 'dsconfig'
        NO_CHECK = 'noCheck'
        # Replication configuration default names
        MultimasterSync = 'Multimaster Synchronization'
        MultimasterType = 'multimaster'
      </script>
                    
            
opends/tests/functional-tests/shared/functions/topology.xml
@@ -121,13 +121,9 @@
                <if expr="server.requiresSynchronization()">
                  <sequence>                    
                    <message> 'Instance requires REPLICATION configuration.' </message>
                    <script>
                      serverMap = {}
                      serverMap['instance'] = server
                    </script>
                      
                    <call function="'configureReplication'">
                      [serverMap]
                      [server]
                    </call>                                 
                  </sequence>
                </if>                   
@@ -457,7 +453,7 @@
    
    
  <function name="configureReplication">
  <function name="DEPRECATEDconfigureReplication">
    <function-prolog>
      This function configures replication in a given server.
    </function-prolog>
@@ -558,6 +554,111 @@
    
    
  <function name="configureReplication">
    <function-prolog>
      This function configures replication in a given server.
    </function-prolog>
    <function-list-args>
      <function-arg-def name="syncserver" type="required">
        <function-arg-description>
          Server class instance representing the server to configure.
        </function-arg-description>
        <function-arg-property name="type" value="Server"/>
      </function-arg-def>
    </function-list-args>
    <sequence>
      <!--- Configure replication using dsconfig -->
      <message>
        'Configure replication on server on host %s at directory %s' % (syncserver.getHostname(),syncserver.getDir())
      </message>
      <script>
        syncserverPath = '%s/%s' % (syncserver.getDir(),OPENDSNAME)
      </script>
      <!--- Start DS -->
      <call function="'StartDsWithScript'">
        { 'location'  : syncserver.getHostname(),
           'dsPath' : syncserverPath }
      </call>
      <message>
        'Create synchronization provider'
      </message>
      <call function="'createSyncProvider'">
        { 'location' : syncserver.getHostname(),
          'dsPath' : syncserverPath,
          'dsInstanceHost'    : syncserver.getHostname(),
          'dsInstancePort'   : syncserver.getPort(),
          'dsInstanceDn'    : syncserver.getRootDn(),
          'dsInstancePswd'  : syncserver.getRootPwd() }
      </call>
      <script>
        replicationServer = syncserver.getChangelogServer()
        replicatedSuffixList = server.getSynchronizedSuffixList()
      </script>
      <if expr="replicationServer">
        <sequence>
          <message>
            'Create replication server listening on port: %s' % replicationServer.getPort()
          </message>
          <call function="'createReplicationServer'">
            { 'location' : syncserver.getHostname(),
              'dsPath' : syncserverPath,
              'dsInstanceHost'    : syncserver.getHostname(),
              'dsInstancePort'   : syncserver.getPort(),
              'dsInstanceDn'    : syncserver.getRootDn(),
              'dsInstancePswd'  : syncserver.getRootPwd(),
              'replicationPort'  : replicationServer.getPort(),
              'replicationServerId'  :  replicationServer.getId(),
              'replicationServerList'  :  replicationServer.getChangelogServerList() }
          </call>
        </sequence>
      </if>
      <iterate var="suffix" in="replicatedSuffixList" indexvar="i">
        <sequence>
          <message>
            'Create domain name for suffix: %s' % suffix.getSuffixDn()
          </message>
          <call function="'createMultimasterDomain'">
            { 'location' : syncserver.getHostname(),
              'dsPath' : syncserverPath,
              'dsInstanceHost'    : syncserver.getHostname(),
              'dsInstancePort'   : syncserver.getPort(),
              'dsInstanceDn'    : syncserver.getRootDn(),
              'dsInstancePswd'  : syncserver.getRootPwd(),
              'domainName'  : 'SUFFIX-%s' % i,
              'replicationDn'  : suffix.getSuffixDn(),
              'serverId'  :  suffix.getId(),
              'replicationServerList'  :  suffix.getChangelogServerList() }
          </call>
        </sequence>
      </iterate>
      <!--- Stop DS -->
      <call function="'StopDsWithScript'">
        { 'location'  : syncserver.getHostname(),
          'dsHost' : syncserver.getHostname(),
          'dsPath' : syncserverPath,
          'dsPort'    : syncserver.getPort(),
          'dsBindDN'  : syncserver.getRootDn(),
          'dsBindPwd' : syncserver.getRootPwd() }
      </call>
    </sequence>
  </function>
    
  <function name="readTopology">
@@ -812,4 +913,5 @@
        
  </function>
        
</stax>
opends/tests/functional-tests/shared/functions/utils.xml
@@ -53,6 +53,9 @@
    </function-map-args>
    <sequence>
      <if expr="expected == NO_CHECK">
        <return/>
      </if>
      <if expr="returncode == expected">
        <sequence>
          <if expr="result == ''">
@@ -103,6 +106,9 @@
      </function-arg-def>
    </function-map-args>  
    <sequence>      
      <if expr="expected == NO_CHECK">
        <return/>
      </if>
      <if expr="returncode == expected">
        <sequence>
          <if expr="STAXCurrentTestcase != None">