<?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 legal-notices/CDDLv1_0.txt
! or http://forgerock.org/license/CDDLv1.0.html.
! 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 2011-2013 ForgeRock AS.
! -->
<stax>
<!-- Definition of Preamble -->
<!--- Test Case information
#@TestMarker Replication
#@TestName Replication : ECL
#@TestID ecl_setup
#@TestPurpose Setup ecl
#@TestPreamble
#@TestSteps Step1: TBD
#@TestPostamble
#@TestResult Test is successful if the result code is 0
-->
<function name="ecl_setup" scope="local">
<testcase name="getTestCaseName('ecl_setup')">
<sequence>
<try>
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'Test Name = %s' % STAXCurrentTestcase
</message>
<message>
'Replication: External Changelog: - Setup. \
Set up environment for External Changelog tests'
</message>
<message>
'Common ECL tests: reset data'
</message>
<!-- Pre external initialization set generation id (-1) and clears cn=changelog -->
<call function="'preInitializeReplication'">
{ 'location' : masterHost,
'dsPath' : masterPath,
'dsInstanceHost' : masterHost,
'dsInstanceAdminPort' : master.getAdminPort(),
'localOnly' : False,
'replicationDnList' : [synchroSuffix],
'adminUID' : adminUID,
'adminPswd' : adminPswd
}
</call>
<!-- 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,
'backEnd' : DIRECTORY_INSTANCE_BE,
'ldifFile' : '%s/replication/Example.ldif' \
% masterDataDir
}
</call>
<!-- Start the Directory Server -->
<call function="'StartDsWithScript'">
{ 'location' : masterHost,
'dsPath' : masterPath,
'dsDebugPort' : master.getDebugPort()
}
</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>
<!-- Perform the total update, resets generation id from (-1) -->
<call function="'initializeReplication'">
{ 'location' : clientHost,
'dsPath' : clientPath,
'sourceInstanceHost' : masterHost,
'sourceInstanceAdminPort' : master.getAdminPort(),
'replicationDnList' : [synchroSuffix]
}
</call>
<!-- Verify the synchronization of the trees among the servers in
the topology -->
<call function="'verifyTrees'">
[ clientHost, clientPath, master, consumerList, synchroSuffix ]
</call>
</sequence>
<finally>
<call function="'testCase_Postamble'"/>
</finally>
</try>
</sequence>
</testcase>
</function>
<!--- Test Case information
#@TestMarker Replication
#@TestName Replication : ECL: ChangeNumbers
#@TestID ecl_changenumbers_001
#@TestPurpose Verify that the 2 servers have consistent change numbers after add
#@TestPreamble
#@TestSteps Step1: Check that the changeNumber and lastChangeNumber match
#@TestSteps Step2: Check that firstChangeNumbers match
#@TestSteps Step3: Count changelog entries in draft mode
#@TestPostamble
#@TestResult Test is successful if the result code is 0
-->
<function name="ecl_changenumbers_001" scope="local">
<testcase name="getTestCaseName('ecl_changenumbers_001')">
<sequence>
<try>
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'Test Name = %s' % STAXCurrentTestcase
</message>
<!-- Reset List -->
<script>
cnsList = []
</script>
<!-- Step1: Check that the changeNumber and lastChangeNumber match -->
<call function="'testStep'">
{ 'stepMessage' : 'Check that the changeNumber and lastChangeNumber match.' }
</call>
<iterate var="server" in="_topologyServerList">
<sequence>
<script>
replServer = server
replServerPath = '%s/%s' % (replServer.getDir(), OPENDSNAME)
</script>
<!-- Search for changeNumber -->
<call function="'ldapSearchWithScript'">
{ 'location' : replServer.getHostname(),
'dsPath' : replServerPath,
'dsInstanceHost' : replServer.getHostname(),
'dsInstancePort' : replServer.getPort(),
'dsInstanceDn' : replServer.getRootDn(),
'dsInstancePswd' : replServer.getRootPwd(),
'dsBaseDN' : 'cn=changelog',
'dsFilter' : 'objectclass=*',
'dsAttributes' : 'changeNumber',
'extraParams' : '-T',
'knownIssue' : 'OPENDJ-253'
}
</call>
<script>
cn = get_last_attr_from_entry(STAXResult,'changeNumber')
cnsList.append(cn)
global_cnsList.set(cn)
</script>
<!-- Search for lastChangeNumber -->
<call function="'ldapSearchWithScript'">
{ 'location' : replServer.getHostname(),
'dsPath' : replServerPath,
'dsInstanceHost' : replServer.getHostname(),
'dsInstancePort' : replServer.getPort(),
'dsInstanceDn' : replServer.getRootDn(),
'dsInstancePswd' : replServer.getRootPwd(),
'dsBaseDN' : '',
'dsFilter' : 'objectclass=*',
'dsScope' : 'base',
'dsAttributes' : 'lastChangeNumber',
'extraParams' : '-T'
}
</call>
<script>
lcn = get_last_attr_from_entry(STAXResult,'lastChangeNumber')
cnsList.append(lcn)
</script>
</sequence>
</iterate>
<!-- Compare changeNumber and lastChangeNumber -->
<call function="'compareItems'">
{ 'items' : cnsList,
'label' : 'changeNumbers'
}
</call>
<!-- Step2: Check that firstChangeNumbers match -->
<call function="'testStep'">
{ 'stepMessage' : 'Check that firstChangeNumbers match.' }
</call>
<script>
fcnsList = []
</script>
<iterate var="server" in="_topologyServerList">
<sequence>
<script>
replServer = server
replServerPath = '%s/%s' % (replServer.getDir(), OPENDSNAME)
</script>
<!-- Search for firstChangeNumber -->
<call function="'ldapSearchWithScript'">
{ 'location' : replServer.getHostname(),
'dsPath' : replServerPath,
'dsInstanceHost' : replServer.getHostname(),
'dsInstancePort' : replServer.getPort(),
'dsInstanceDn' : replServer.getRootDn(),
'dsInstancePswd' : replServer.getRootPwd(),
'dsBaseDN' : '',
'dsScope' : 'base',
'dsFilter' : 'objectclass=*',
'dsAttributes' : 'firstChangeNumber',
'extraParams' : '-T'
}
</call>
<script>
fcn = get_last_attr_from_entry(STAXResult,'firstChangeNumber')
fcnsList.append(fcn)
</script>
</sequence>
</iterate>
<!-- Compare firstChangeNumbers -->
<call function="'compareItems'">
{ 'items' : fcnsList ,
'label' : 'firstChangeNumber'
}
</call>
<!-- Step3: Count changelog entries in draft mode -->
<call function="'testStep'">
{ 'stepMessage' : 'Count changelog entries in draft mode.' }
</call>
<script>
dncList = []
#2 changes + top
noOfEntries = 3
</script>
<iterate var="server" in="_topologyServerList">
<sequence>
<script>
replServer = server
replServerPath = '%s/%s' % (replServer.getDir(), OPENDSNAME)
</script>
<!-- Count the number of initial changes -->
<call function="'ldapSearchWithScript'">
{ 'location' : replServer.getHostname(),
'dsPath' : replServerPath,
'dsInstanceHost' : replServer.getHostname(),
'dsInstancePort' : replServer.getPort(),
'dsInstanceDn' : replServer.getRootDn(),
'dsInstancePswd' : replServer.getRootPwd(),
'dsBaseDN' : 'cn=changelog',
'dsFilter' : 'objectclass=*',
'dsAttributes' : 'dn' ,
'extraParams' : '-T'
}
</call>
<script>
dncount=int(count_attr(STAXResult))
dncList.append(dncount)
</script>
<if expr="dncount == noOfEntries">
<message>
'Search returned %s changes, expected %s' % (dncount,noOfEntries)
</message>
<else>
<sequence>
<tcstatus result="'fail'"/>
<message level="'error'">
'Search returned %s changes, expected %s' % (dncount,noOfEntries)
</message>
</sequence>
</else>
</if>
</sequence>
</iterate>
<!-- Compare number of entries -->
<call function="'compareItems'">
{ 'items' : dncList ,
'label' : 'numberOfEntries'
}
</call>
</sequence>
<finally>
<call function="'testCase_Postamble'"/>
</finally>
</try>
</sequence>
</testcase>
</function>
<!-- Definition of Postamble -->
<!--- Test Case : Replication : ECL : ECL CLEANUP -->
<!--- Test Case information
#@TestMarker Replication
#@TestName Replication : ECL
#@TestID ecl_cleanup
#@TestPurpose Cleanup ecl
#@TestPreamble
#@TestSteps Step1: TBD
#@TestPostamble
#@TestResult Test is successful if the result code is 0
-->
<function name="ecl_cleanup" scope="local">
<testcase name="getTestCaseName('ecl_cleanup')">
<sequence>
<try>
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'Test Name = %s' % STAXCurrentTestcase
</message>
<message>
'Replication: External Changelog: - Clean up. \
Clean up environment for External Changelog tests'
</message>
<tcstatus result="'pass'"/>
</sequence>
<finally>
<call function="'testCase_Postamble'"/>
</finally>
</try>
</sequence>
</testcase>
</function>
<!-- Definition of Functions -->
<function name="compareItems" scope="local">
<function-prolog>
Compares all items in List for equality
</function-prolog>
<function-map-args>
<function-required-arg name="items">
List of items to be compared for equality
</function-required-arg>
<function-optional-arg name="label" default="''">
Friendly label to aid description
</function-optional-arg>
<function-optional-arg name="knownIssue" default="None">
Issue id. Corresponds to an issue number.
</function-optional-arg>
</function-map-args>
<sequence>
<if expr="len(items) == 0">
<message level='warning'>'The list to compare is empty.'</message>
</if>
<script>
try:
allItemsMatch = list_matches(items)
except Exception,e:
print "Exception Thrown: caught (%s)" % e
allItemsMatch = 'False'
</script>
<if expr="allItemsMatch == 'True'">
<sequence>
<message>'%s Items match successfully (%s)' % (label,items)</message>
<tcstatus result="'pass'"/>
</sequence>
<else>
<sequence>
<if expr="knownIssue == None">
<tcstatus result="'fail'"/>
<else>
<sequence>
<call function="'setKnownIssue'">
{ 'issueId' : knownIssue }
</call>
</sequence>
</else>
</if>
<message level="'error'">'%s Items do not match (%s)' % (label,items)</message>
</sequence>
</else>
</if>
</sequence>
</function>
</stax>