From 2aa8aee407d3ba221e1fd24e143b916b2d0be3c0 Mon Sep 17 00:00:00 2001
From: Gary Williams <gary.williams@forgerock.com>
Date: Wed, 28 Mar 2012 14:02:43 +0000
Subject: [PATCH] refactor replication functional tests to be one test per function
---
opends/tests/staf-tests/functional-tests/testcases/replication/totalupdate/totalupdate.xml | 624 +++++++++-----------------------------------------------
1 files changed, 107 insertions(+), 517 deletions(-)
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/totalupdate/totalupdate.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/totalupdate/totalupdate.xml
index e5cc13c..ff431db 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/totalupdate/totalupdate.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/totalupdate/totalupdate.xml
@@ -7,551 +7,141 @@
! 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.
+ ! trunk/opends/resource/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
- ! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
+ ! trunk/opends/resource/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 2007-2010 Sun Microsystems, Inc.
- ! Portions Copyright 2012 ForgeRock AS.
+ ! Copyright 2012 ForgeRock AS.
! -->
<stax>
<defaultcall function="replication_totalupdate"/>
- <function name="replication_totalupdate">
+ <function name="replication_totalupdate" scope="local">
<sequence>
- <block name="'total-update'">
- <sequence>
- <script>
- if not CurrentTestPath.has_key('group'):
- CurrentTestPath['group']='replication'
- CurrentTestPath['suite']=STAXCurrentBlock
- </script>
-
- <call function="'testSuite_Preamble'"/>
-
- <!--- Test Suite information
- #@TestSuiteName Replication Total Update Tests
- #@TestSuitePurpose Verify that all the contents of a given suffix
- can be pushed in one shot from one server to
- other servers in the topology.
- #@TestSuiteID Total Update Tests
- #@TestSuiteGroup Total Update
- #@TestGroup Replication
- #@TestScript replication_totalupdate.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'" >
- { 'label' : 'Replication Totalupdate' }
- </call>
-
- <script>
- server1DataDir = '%s' % server1.getDataDir()
- </script>
-
- <!--- Test Case : Total Update -->
- <!--- Test Case information
- #@TestMarker Replication Total Update Tests
- #@TestName Replication: Total Update: Simple LDIF
- #@TestID Simple LDIF
- #@TestPurpose Initialize server with total update
- #@TestPreamble
- #@TestSteps Stop server A
- #@TestSteps Import data into server A
- #@TestSteps Start server A
- #@TestSteps Initialise (dsreplication initialize)
- every other server from server A
- #@TestSteps Check suffix has been initialised on every
- server
- #@TestSteps Add entry on server A
- #@TestPostamble
- #@TestResult Success if initialisation call succeeds for all
- servers and all servers are synchronised
- -->
- <testcase name="getTestCaseName('Simple LDIF')">
- <sequence>
-
- <call function="'testCase_Preamble'"/>
-
- <message>
- 'Replication: Total Update: Simple LDIF. Initialize server \
- with total update'
- </message>
+ <block name="'replication_totalupdate'">
+ <try>
+ <sequence>
+ <script>
+ CurrentTestPath['group'] = 'replication'
+ CurrentTestPath['suite'] = 'totalupdate'
- <!-- Stop "master" Directory Server -->
- <call function="'StopDsWithScript'">
- { 'location' : masterHost,
- 'dsPath' : masterPath,
- 'dsHost' : masterHost,
- 'dsAdminPort' : master.getAdminPort(),
- 'dsBindDN' : master.getRootDn(),
- 'dsBindPwd' : master.getRootPwd()
- }
- </call>
-
- <!-- Check that the Directory Server is stopped -->
-
- <!-- 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
- }
- </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>
-
- <!-- Check some data was imported into Directory Server -->
- <call function="'checkImport'">
- { 'location' : masterHost,
- 'dsPath' : masterPath,
- 'dsHost' : masterHost,
- 'dsPort' : master.getPort(),
- 'dsAdminPort' : master.getAdminPort(),
- 'dsDn' : master.getRootDn(),
- 'dsPswd' : master.getRootPwd(),
- 'expectedEntries' : ['uid=scarter,ou=People,o=example',
- 'uid=dmiller, ou=People, o=example',
- 'uid=rhunt, ou=People, o=example'],
- 'startDS' : 'no'
- }
- </call>
+ _group=CurrentTestPath['group']
+ _groupdir='%s/testcases/%s' % (TESTS_DIR,_group)
+ _label = 'Replication TotalUpdate'
+ </script>
-
- <iterate var="server" in="consumerList">
- <sequence>
- <!-- Perform the total update -->
- <call function="'initializeReplication'">
- { 'location' : clientHost,
- 'dsPath' : clientPath,
- 'dsInstanceHost' : server.getHostname(),
- 'dsInstanceAdminPort' : server.getAdminPort(),
- 'sourceInstanceHost' : masterHost,
- 'sourceInstanceAdminPort' : master.getAdminPort(),
- 'replicationDnList' : ['o=example']
- }
- </call>
-
- <!-- Verify the total update -->
- <call function="'checkImport'">
- { 'location' : server.getHostname(),
- 'dsPath' : '%s/%s' % (server.getDir(),OPENDSNAME),
- 'dsHost' : server.getHostname(),
- 'dsPort' : server.getPort(),
- 'dsAdminPort' : server.getAdminPort(),
- 'dsDn' : server.getRootDn(),
- 'dsPswd' : server.getRootPwd(),
- 'expectedEntries' : ['uid=scarter,ou=People,o=example',
- 'uid=dmiller, ou=People, o=example',
- 'uid=rhunt, ou=People, o=example'],
- 'startDS' : 'no'
- }
- </call>
- </sequence>
- </iterate>
-
- <!-- To make sure replication is working: add entry to "master"
- server -->
- <script>
- listAttr = []
- listAttr.append('objectclass:top')
- listAttr.append('objectclass:organizationalperson')
- listAttr.append('objectclass:inetorgperson')
- listAttr.append('objectclass:person')
- listAttr.append('givenname:Professor Moriarty')
- listAttr.append('sn:Moriarty')
- listAttr.append('cn:Professor Moriarty')
- listAttr.append('l:London')
- </script>
-
- <call function="'addAnEntry'">
- { 'location' : masterHost,
- 'dsPath' : masterPath,
- 'dsInstanceHost' : masterHost,
- 'dsInstancePort' : master.getPort(),
- 'dsInstanceDn' : master.getRootDn(),
- 'dsInstancePswd' : master.getRootPwd(),
- 'DNToAdd' : 'uid=pmoriarty, ou=People, o=example',
- 'listAttributes' : listAttr
- }
- </call>
-
- <!-- Verify the synchronization of the trees among the servers in
- the topology -->
- <call function="'verifyTrees'">
- [ clientHost, clientPath, master, consumerList, 'o=example' ]
- </call>
-
- <call function="'testCase_Postamble'"/>
- </sequence>
- </testcase>
-
-
-
- <!--- Test Case information
- #@TestMarker Replication Total Update Tests
- #@TestName Replication: Total Update: Schema total update
- #@TestID Schema total update
- #@TestPurpose Initialize the schema with total update.
- #@TestPreamble
- #@TestSteps Add entry belonging to undefined new schema on
- server B
- #@TestSteps Disable replication for cn=schema on server A
- #@TestSteps Add new objectClass and new attrType definition
- to schema in server A
- #@TestSteps Enable replication for cn=schema on server A
- (which also initialises cn=schema)
- #@TestSteps Add entry belonging to new schema on server B
- #@TestPostamble
- #@TestResult Success if first entry add attempt on server B
- fails with error 65 (objectclass violation)
- whereas second add attempt succeeds.
- -->
- <testcase name="getTestCaseName('Schema total update')">
- <sequence>
-
- <call function="'testCase_Preamble'"/>
-
- <message>
- 'Replication: Total Update: Schema total update. \
- Initialize schema with total update'
- </message>
-
- <script>
- consumer = consumerList[0]
- </script>
-
- <!-- Try to add entry belonging to new schema to "consumer"
- server; should be rejected with error 65 (objectclass violation)
+ <!--- Test Suite information
+ #@TestSuiteName Replication TotalUpdate Tests
+ #@TestSuitePurpose Verify that the total-update operations are replicated
+ correctly between two servers.
+ #@TestSuiteID TotalUpdate Tests
+ #@TestSuiteGroup TotalUpdate
+ #@TestGroup Replication
+ #@TestScript replication_totalupdate.xml
+ #@TestHTMLLink http://www.forgerock.org/
-->
- <call function="'addEntry'">
- { 'location' : clientHost,
- 'dsPath' : clientPath,
- 'dsInstanceHost' : consumer.getHostname(),
- 'dsInstancePort' : consumer.getPort(),
- 'dsInstanceDn' : consumer.getRootDn(),
- 'dsInstancePswd' : consumer.getRootPwd(),
- 'entryToBeAdded' : '%s/replication/testuser-1.ldif' \
- % clientDataDir,
- 'expectedRC' : 65
- }
- </call>
+
+ <call function="'testSuite_Preamble'"/>
+ <try>
+ <sequence>
+
+ <import machine="STAF_LOCAL_HOSTNAME"
+ file="'%s/testcases/replication/replication_setup.xml'
+ % (TESTS_DIR)"/>
+ <call function="'replication_setup'" >
+ { 'label' : _label }
+ </call>
- <!-- Disable schema replication on "master" server -->
- <call function="'disableReplication'">
- { 'location' : clientHost,
- 'dsPath' : clientPath,
- 'dsInstanceHost' : masterHost,
- 'dsInstanceAdminPort' : master.getAdminPort(),
- 'replicationDnList' : ['cn=schema']
- }
- </call>
-
- <script>
- newObjectclass = '( testobjectclass1-oid NAME \
- \'testobjectclass-1\' SUP person MAY ( street $ \
- testattribute-1 $ c ) X-ORIGIN \'user defined\' )'
- newAttributetype = '( testattribute1-oid NAME \
- \'testattribute-1\' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 \
- X-ORIGIN \'user defined\' )'
- </script>
-
- <!-- Modify schema in "master" server -->
- <call function="'modifyAnAttribute'">
- { 'dsPath' : masterPath,
- 'dsInstanceHost' : masterHost ,
- 'dsInstancePort' : master.getPort(),
- 'dsInstanceDn' : master.getRootDn(),
- 'dsInstancePswd' : master.getRootPwd(),
- 'DNToModify' : 'cn=schema',
- 'attributeName' : 'attributeTypes',
- 'newAttributeValue' : newAttributetype,
- 'changetype' : 'add'
- }
- </call>
- <call function="'modifyAnAttribute'">
- { 'dsPath' : masterPath,
- 'dsInstanceHost' : masterHost ,
- 'dsInstancePort' : master.getPort(),
- 'dsInstanceDn' : master.getRootDn(),
- 'dsInstancePswd' : master.getRootPwd(),
- 'DNToModify' : 'cn=schema',
- 'attributeName' : 'objectClasses',
- 'newAttributeValue' : newObjectclass,
- 'changetype' : 'add'
- }
- </call>
-
- <!-- Re-enable schema replication on "master" server, and
- at the same time initialise the schema across the topology -->
- <script>
- if master.isOnlyLdapServer():
- masterReplPort = None
- else:
- masterReplPort = masterReplicationServer.getPort()
-
- if consumer.isOnlyLdapServer():
- consumerReplPort = None
- else:
- replicationServer = consumer.getChangelogServer()
- consumerReplPort = replicationServer.getPort()
- </script>
- <call function="'enableReplication'">
- { 'location' : clientHost,
- 'dsPath' : clientPath,
- 'refInstanceHost' : masterHost,
- 'refInstanceAdminPort' : master.getAdminPort(),
- 'refInstanceDn' : master.getRootDn(),
- 'refInstancePswd' : master.getRootPwd(),
- 'refReplicationPort' : masterReplPort,
- 'refOnlyLdapServer' : master.isOnlyLdapServer(),
- 'refOnlyReplServer' : master.isOnlyReplServer(),
- 'dsInstanceHost' : consumer.getHostname(),
- 'dsInstanceAdminPort' : consumer.getAdminPort(),
- 'dsInstanceDn' : consumer.getRootDn(),
- 'dsInstancePswd' : consumer.getRootPwd(),
- 'dsReplicationPort' : consumerReplPort,
- 'dsOnlyLdapServer' : consumer.isOnlyLdapServer(),
- 'dsOnlyReplServer' : consumer.isOnlyReplServer(),
- 'replicationDnList' : ['cn=schema']
- }
- </call>
-
- <!-- Add entry to "consumer" server -->
- <call function="'addEntry'">
- { 'location' : clientHost,
- 'dsPath' : clientPath,
- 'dsInstanceHost' : consumer.getHostname(),
- 'dsInstancePort' : consumer.getPort(),
- 'dsInstanceDn' : consumer.getRootDn(),
- 'dsInstancePswd' : consumer.getRootPwd(),
- 'entryToBeAdded' : '%s/replication/testuser-1.ldif' \
- % clientDataDir
- }
- </call>
+ <!-- List of Import of Test Functions -->
+ <script>
+ importList=[]
+ importList.append('totalupdate/totalupdate_tests')
+ </script>
- <!-- Verify the synchronization of the schema among the servers
- in the topology -->
- <!-- If the schema files differ, it could be due to Issue OPENDJ-449
- (Replication adds modifiersName and modifyTimestamp to schema
- updates) -->
- <call function="'verifySchemas'">
- [ clientHost, clientPath, master, consumerList, '99-user.ldif',
- 'OPENDJ-449' ]
- </call>
-
- <!-- Verify the synchronization of the trees among the servers in
- the topology -->
- <call function="'verifyTrees'">
- [ clientHost, clientPath, master, consumerList, 'o=example' ]
- </call>
+ <!-- Import the files for this test suite -->
+ <iterate var="_import" in="importList">
+ <import machine="STAF_LOCAL_HOSTNAME"
+ file="'%s/%s.xml' % (_groupdir,_import)"/>
+ </iterate>
-
- <call function="'testCase_Postamble'"/>
- </sequence>
- </testcase>
+ <!-- Specific to replication tests -->
+ <script>
+ msg1 = 'Replication: TotalUpdate:'
+ server1DataDir = '%s' % server1.getDataDir()
+ </script>
+
+ <!-- List of Test Cases -->
+ <script>
+ testsList=[]
+ testsList.append('replication_totalupdate_001')
+ testsList.append('replication_totalupdate_002')
+ testsList.append('replication_totalupdate_003')
+ </script>
-
+ <!-- Execute the Tests -->
+ <iterate var="__test" in="testsList">
+ <sequence>
+ <call function="'%s' % (__test)" />
+ </sequence>
+ </iterate>
+
+ </sequence>
- <!--- Test Case information
- #@TestMarker Replication Total Update Tests
- #@TestName Replication: Total Update: Initialize all
- #@TestID Initialize all
- #@TestPurpose Initialize all servers with total update
- #@TestPreamble
- #@TestSteps Stop server A
- #@TestSteps Import data into server A
- #@TestSteps Start server A
- #@TestSteps Initialise (dsreplication initialize all) all
- the servers from server A
- #@TestSteps Check suffix has been initialised on every
- server
- #@TestSteps Add entry on server A
- #@TestPostamble
- #@TestResult Success if initialisation call succeeds for all
- servers and all servers are synchronised
- -->
- <testcase name="getTestCaseName('Initialize all')">
- <sequence>
-
- <call function="'testCase_Preamble'"/>
-
- <message>
- 'Replication: Total Update: Initialize all. Initialize all \
- servers with total update'
- </message>
-
- <!-- Stop "master" Directory Server -->
- <call function="'StopDsWithScript'">
- { 'location' : masterHost,
- 'dsPath' : masterPath,
- 'dsHost' : masterHost,
- 'dsAdminPort' : master.getAdminPort(),
- 'dsBindDN' : master.getRootDn(),
- 'dsBindPwd' : master.getRootPwd()
- }
- </call>
-
- <!-- Check that the Directory Server is stopped -->
-
- <!-- Import data into "master" Directory Server -->
- <call function="'ImportLdifWithScript'">
- { 'location' : masterHost,
- 'dsPath' : masterPath,
- 'backEnd' : DIRECTORY_INSTANCE_BE,
- 'ldifFile' : '%s/replication/Short_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>
-
- <!-- Check some data was imported into Directory Server -->
- <call function="'checkImport'">
- { 'location' : masterHost,
- 'dsPath' : masterPath,
- 'dsHost' : masterHost,
- 'dsPort' : master.getPort(),
- 'dsAdminPort' : master.getAdminPort(),
- 'dsDn' : master.getRootDn(),
- 'dsPswd' : master.getRootPwd(),
- 'expectedEntries' : ['uid=scarter,ou=People,o=example',
- 'uid=dmiller, ou=People, o=example',
- 'uid=sholmes, ou=People, o=example'],
- 'startDS' : 'no'
- }
- </call>
-
-
- <!-- Perform the total update -->
- <call function="'initializeReplication'">
- { 'location' : clientHost,
- 'dsPath' : clientPath,
- 'sourceInstanceHost' : masterHost,
- 'sourceInstanceAdminPort' : master.getAdminPort(),
- 'replicationDnList' : ['o=example']
- }
- </call>
-
-
- <iterate var="server" in="consumerList">
- <sequence>
- <!-- Verify the total update -->
- <call function="'checkImport'">
- { 'location' : server.getHostname(),
- 'dsPath' : '%s/%s' % (server.getDir(),OPENDSNAME),
- 'dsHost' : server.getHostname(),
- 'dsPort' : server.getPort(),
- 'dsAdminPort' : server.getAdminPort(),
- 'dsDn' : server.getRootDn(),
- 'dsPswd' : server.getRootPwd(),
- 'expectedEntries' : ['uid=scarter,ou=People,o=example',
- 'uid=dmiller, ou=People, o=example',
- 'uid=sholmes, ou=People, o=example'],
- 'startDS' : 'no'
- }
- </call>
+ <catch exception="'STAFException.TestSuite.SetupException'">
+ <sequence>
+ <message log="1" level="'fatal'">
+ 'Setup of test suite failed.'
+ </message>
+ <rethrow/>
</sequence>
- </iterate>
+ </catch>
+
+ <finally>
+ <message>'Test Cases Completed.'</message>
+ </finally>
- <!-- To make sure replication is working: add entry to "master"
- server -->
- <script>
- listAttr = []
- listAttr.append('objectclass:top')
- listAttr.append('objectclass:organizationalperson')
- listAttr.append('objectclass:inetorgperson')
- listAttr.append('objectclass:person')
- listAttr.append('givenname:Professor Moriarty')
- listAttr.append('sn:Moriarty')
- listAttr.append('cn:Professor Moriarty')
- listAttr.append('l:London')
- </script>
-
- <call function="'addAnEntry'">
- { 'location' : masterHost,
- 'dsPath' : masterPath,
- 'dsInstanceHost' : masterHost,
- 'dsInstancePort' : master.getPort(),
- 'dsInstanceDn' : master.getRootDn(),
- 'dsInstancePswd' : master.getRootPwd(),
- 'DNToAdd' : 'uid=pmoriarty, ou=People, o=example',
- 'listAttributes' : listAttr
- }
- </call>
-
- <!-- Verify the synchronization of the trees among the servers in
- the topology -->
- <call function="'verifyTrees'">
- [ clientHost, clientPath, master, consumerList, 'o=example' ]
- </call>
+ </try>
- <call function="'testCase_Postamble'"/>
+ </sequence>
+
+ <finally>
+ <sequence>
+ <!-- Test Suite Cleanup -->
+ <message>'Finally: Replication Cleanup.'</message>
+ <try>
+ <sequence>
+ <import machine="STAF_LOCAL_HOSTNAME"
+ file="'%s/testcases/replication/replication_cleanup.xml'
+ % (TESTS_DIR)"/>
+ <call function="'replication_cleanup'">
+ { 'label' : _label }
+ </call>
+ </sequence>
+ <catch exception="'STAFException'">
+ <sequence>
+ <message log="1" level="'fatal'">'Cleanup of test suite failed.'</message>
+ </sequence>
+ </catch>
+ <finally>
+ <call function="'testSuite_Postamble'"/>
+ </finally>
+ </try>
</sequence>
- </testcase>
-
-
- <import machine="STAF_LOCAL_HOSTNAME"
- file="'%s/testcases/replication/replication_cleanup.xml'
- % (TESTS_DIR)"/>
- <call function="'replication_cleanup'" >
- { 'label' : 'Replication Totalupdate' }
- </call>
-
- <call function="'testSuite_Postamble'"/>
- </sequence>
+ </finally>
+
+ </try>
</block>
</sequence>
</function>
--
Gitblit v1.10.0