<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
! 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 legal-notices/CDDLv1_0.txt
! 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 legal-notices/CDDLv1_0.txt.
! 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
!
! Copyright 2009-2010 Sun Microsystems, Inc.
! -->
<stax>
<defaultcall function="replication_modify"/>
<function name="replication_modify">
<sequence>
<block name="'replication-modify'">
<sequence>
<script>
if not CurrentTestPath.has_key('group'):
CurrentTestPath['group']='replication'
CurrentTestPath['suite']=STAXCurrentBlock
</script>
<call function="'testSuite_Preamble'"/>
<import machine="STAF_LOCAL_HOSTNAME"
file="'%/functional-tests/testcases/replication/replication_setup.xml' % (TESTS_DIR)"/>
<call function="'replication_setup'"/>
<script>
ldcltLoop = testsDuration / 10
lowRange = 100000
highRange = lowRange + numberOfEntries
jvmLoop = testsDuration / 1800 + 1
jvmSleep = 1800000
baseDN = 'ou=People,%s' % synchroSuffix
masterDir = '%s/..' % masterPath
ldifTemplate = '%s/%s_entries.template' \
% (masterDir, numberOfEntries)
ldifFile = '%s/%s_entries.ldif' \
% (masterDir, numberOfEntries)
totalEntries = numberOfEntries + 2
suffix = 'modify'
consumer = _topologyServerList[1]
</script>
<testcase name="getTestCaseName('Preamble')">
<sequence>
<call function="'testCase_Preamble'"/>
<!-- Check if 'ldifFile' exists -->
<call function="'GetEntry'">
{
'location' : masterHost ,
'entry' : ldifFile ,
'attribute' : 'TYPE'
}
</call>
<if expr="RC == 48">
<sequence>
<message>
'replication_modify: File %s does not exist, create it' \
% ldifFile
</message>
<message>
'replication_modify: Make a make-ldif template file'
</message>
<call function="'MakeAMakeLdifTemplate'">
{
'numEntries' : numberOfEntries,
'suffix' : synchroSuffix,
'startFrom' : lowRange,
'additionalAttributes' : True,
'templateFile' : ldifTemplate,
'templateLocation' : masterHost
}
</call>
<message>
'replication_modify: Make the ldif file'
</message>
<call function="'MakeLdifWithScript'">
{
'location' : masterHost,
'dsPath' : masterPath,
'templateFile' : ldifTemplate,
'ldifFile' : ldifFile
}
</call>
</sequence>
<else>
<message>
'replication_modify: File %s exists, do nothing' % ldifFile
</message>
</else>
</if>
<message>
'replication_modify: Import large ldif file'
</message>
<!-- Stop "master" Directory Server -->
<call function="'StopDsWithScript'">
{ 'location' : masterHost,
'dsPath' : masterPath,
'dsHost' : masterHost,
'dsAdminPort' : master.getAdminPort(),
'dsBindDN' : master.getRootDn(),
'dsBindPwd' : master.getRootPwd()
}
</call>
<!-- Import data into "master" Directory Server -->
<call function="'ImportLdifWithScript'">
{ 'location' : masterHost,
'dsPath' : masterPath,
'dsBackEnd' : DIRECTORY_INSTANCE_BE,
'dsLdifFile' : ldifFile
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{ 'returnString' : returnString,
'expectedString' : 'Processed %s entries' % totalEntries
}
</call>
<message>
'replication_modify: Start DS running on %s:%s' % \
(masterHost, master.getPort())
</message>
<!-- 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' : 5000
}
</call>
<!-- Perform the total update -->
<call function="'initializeReplication'">
{ 'location' : clientHost,
'dsPath' : clientPath,
'sourceInstanceHost' : masterHost,
'sourceInstanceAdminPort' : master.getAdminPort(),
'replicationDnList' : [synchroSuffix]
}
</call>
<!-- If the External Changelog is to be tested, install an
! stand-alone instance whereto replay the changes -->
<if expr="globalTestExternalChangelog">
<sequence>
<message>
'Test ECL: Install stand-alone instance whereto replay \
changes'
</message>
<!-- Create instance with default parameters read from
! config.py -->
<script>
standaloneServer = Server(DIRECTORY_INSTANCE_HOST,
DIRECTORY_INSTANCE_DIR,
DIRECTORY_INSTANCE_PORT,
DIRECTORY_INSTANCE_ADMIN_PORT,
DIRECTORY_INSTANCE_SSL_PORT,
None,
synchroSuffix)
</script>
<call function="'createInstance'">
{ 'dsHost' : standaloneServer.getHostname(),
'dsDir' : standaloneServer.getDir(),
'dsPort' : standaloneServer.getPort(),
'dsAdminPort' : standaloneServer.getAdminPort(),
'dsSslPort' : standaloneServer.getSslPort(),
'dsJmxPort' : standaloneServer.getJmxPort(),
'dsBindDN' : standaloneServer.getRootDn(),
'dsBindPwd' : standaloneServer.getRootPwd(),
'dsBaseDN' : standaloneServer.getBaseDn()
}
</call>
<!-- Copy ldif file from "master" -->
<script>
standaloneLdifFile = '%s/%s_entries.ldif' \
% (standaloneServer.getDir(), numberOfEntries)
</script>
<if expr="masterHost != standaloneServer.getHostname()">
<call function="'copyFile'">
{ 'location' : masterHost,
'srcfile' : ldifFile,
'destfile' : standaloneLdifFile,
'remotehost' : standaloneServer.getHostname()
}
</call>
<else>
<script>
standaloneLdifFile = ldifFile
</script>
</else>
</if>
<!-- Import same data imported into "master" -->
<call function="'ImportLdifWithScript'">
{ 'location' : standaloneServer.getHostname(),
'dsPath' : '%s/%s' % \
(standaloneServer.getDir(), OPENDSNAME),
'dsBackEnd' : DIRECTORY_INSTANCE_BE,
'dsLdifFile' : standaloneLdifFile
}
</call>
<!-- Start the stand-alone Directory Server -->
<call function="'StartDsWithScript'">
{ 'location' : standaloneServer.getHostname() }
</call>
</sequence>
</if>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<testcase name="getTestCaseName('Run ldclt clients')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'replication_modify: Run ldclt modify'
</message>
<!--<timer duration="timerDuration">
<sequence>-->
<parallel>
<block name="'ldclt-modify-threads'">
<sequence>
<message>
'replication_modify: modify threads'
</message>
<script>
opt1 = '-e delayedstartup=1'
opt2 = '-e rdn=\"uid:user.[RNDN(%s;%s;6)]\"' \
% (lowRange, highRange)
opt3 = '-e attreplace=\"description: random modify XXXXXX\"'
opt4 = '-N %s -I 32 -v -q' % ldcltLoop
opts = '%s %s %s %s' % (opt1, opt2, opt3, opt4)
</script>
<call function="'ldclt'">
{ 'location' : STAF_CLIENT_HOSTNAME,
'dsInstanceHost' : masterHost,
'dsInstancePort' : master.getPort(),
'dsInstanceDn' : master.getRootDn(),
'dsInstancePswd' : master.getRootPwd(),
'dsBaseDn' : baseDN,
'ldcltOptions' : opts,
'outputFile' : 'ldclt_modify-%s.res' % suffix,
'outputPath' : ldcltDir
}
</call>
</sequence>
</block>
<block name="'ldclt-jvm'">
<sequence>
<loop from="1" to="jvmLoop" var="loop">
<sequence>
<message>
'LOOP %s out of %s' % (loop, jvmLoop)
</message>
<message>
'replication_modify: save jvm information'
</message>
<call function="'ldapSearchWithScript'">
{ 'location' : masterHost,
'dsPath' : masterPath,
'dsInstanceHost' : masterHost,
'dsInstancePort' : master.getPort(),
'dsInstanceDn' : master.getRootDn(),
'dsInstancePswd' : master.getRootPwd(),
'dsBaseDN' : 'cn=JVM Memory Usage,cn=monitor',
'dsFilter' : 'objectclass=*',
'expectedRC' : 'noCheck',
'outputFile' : 'jvm_%s_%s.out' % (suffix, loop),
'outputPath' : masterDir
}
</call>
<if expr="loop != jvmLoop">
<call function="'Sleep'">
{ 'sleepForMilliSeconds' : jvmSleep }
</call>
</if>
</sequence>
</loop>
</sequence>
</block>
<!-- If the External Changelog is to be tested, install an
! stand-alone instance whereto replay the changes -->
<if expr="globalTestExternalChangelog">
<block name="'ecl-test'">
<sequence>
<message>
'replication_modify: Test ECL: Read and replay \
changes'
</message>
<call function="'eclReadAndPlay'">
{ 'location' : standaloneServer.getHostname(),
'standaloneHost' : standaloneServer.getHostname(),
'standalonePort' : standaloneServer.getPort(),
'replicaHost1' : consumer.getHostname(),
'replicaPort1' : consumer.getPort(),
'replicaHost2' : masterHost,
'replicaPort2' : master.getPort(),
'bindDn' : master.getRootDn(),
'bindPswd' : master.getRootPwd(),
'eclMode' : globalExternalChangelogMode,
'queueSize' : 1000,
'outputFilename' : '%s/eclReadAndPlay.output' \
}
</call>
</sequence>
</block>
</if>
</parallel>
<!--</sequence>
</timer>
<script>timerRC = RC</script>
<if expr="timerRC == 0">
<sequence>
<message>'Timer exceeds %s' % timerDuration</message>
<tcstatus result="'fail'"/>
</sequence>
</if>-->
<message>
(ldcltDir, suffix, STAF_CLIENT_HOSTNAME, logs.sut, STAXServiceMachine)
</message>
<call function="'copyFile'">
{
'location' : STAF_CLIENT_HOSTNAME,
'remotehost' : STAXServiceMachine
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<testcase name="getTestCaseName('Check server is still running')">
<sequence>
<call function="'testCase_Preamble'"/>
<paralleliterate var="server" in="_topologyServerList" indexvar="i">
<sequence>
<script>
serverPath = '%s/%s' % (server.getDir(), OPENDSNAME)
</script>
<message>
'replication_modify: Check server is still running on \
%s:%s' % (server.getHostname(), server.getPort())
</message>
<!-- Modify entry on one of the servers -->
<call function="'isAlive'">
{ 'location' : server.getHostname(),
'dsPath' : serverPath,
'dsInstanceHost' : server.getHostname(),
'dsInstancePort' : server.getPort(),
'dsInstanceDn' : server.getRootDn(),
'dsInstancePswd' : server.getRootPwd(),
'noOfLoops' : 10 ,
'noOfMilliSeconds' : 5000
}
</call>
</sequence>
</paralleliterate>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<testcase name="getTestCaseName('Verify replication')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'replication_modify: Verify replication is still working'
</message>
<!-- Verify the replication is still working among the servers in
the topology -->
<call function="'verifyReplication'">
[ _topologyServerList, synchroSuffix ]
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<testcase name="getTestCaseName('Verify tree synchronization')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'replication_modify: Verify the tree synchronization'
</message>
<!-- 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>
<!-- If the External Changelog is to be tested, verify the
! synchronisation of the tree in the stand-alone instance -->
<if expr="globalTestExternalChangelog">
<testcase name="getTestCaseName('Verify stand-alone server tree synchronization')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'replication_modify: Verify the stand-alone server tree \
synchronization'
</message>
<script>
attrsToIgnoreFile = '%s/ignoreAttrsFile.ldifdiff' % \
clientDataDir
tmpFile = '%s/ignoreAttrsFile.ldifdiff' % TMPDIR
ignoreAttrs = []
ignoreAttrs.append('ds-sync-generation-id')
ignoreAttrs.append('ds-sync-hist')
ignoreAttrs.append('ds-sync-state')
ignoreAttrs.append('createTimestamp')
ignoreAttrs.append('modifyTimestamp')
# write out the ldif file
outfile = open(tmpFile,"w")
for line in ignoreAttrs:
outfile.write("%s\n" % line)
</script>
<if expr="clientHost != STAXServiceMachine">
<call function="'copyFile'">
{ 'location' : masterHost,
'srcfile' : tmpFile,
'destfile' : attrsToIgnoreFile,
'remotehost' : clientHost
}
</call>
<else>
<script>
attrsToIgnoreFile = tmpFile
</script>
</else>
</if>
<!-- Verify the synchronization of the trees among the servers in
the topology -->
<call function="'verifyTrees'">
[ clientHost, clientPath, master, [standaloneServer],
synchroSuffix, None, attrsToIgnoreFile ]
</call>
<!-- Stop the stand-alone Directory Server -->
<call function="'StopDsWithScript'">
{ 'location' : standaloneServer.getHostname() }
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
</if>
<import machine="STAF_LOCAL_HOSTNAME"
file="'%/functional-tests/testcases/replication/replication_cleanup.xml' % (TESTS_DIR)"/>
<call function="'replication_cleanup'">
{ 'suiteSuffix' : suffix }
</call>
<call function="'testSuite_Postamble'"/>
</sequence>
</block>
</sequence>
</function>
</stax>