From 3dfb6fc07cc7f27dc0aed5e65f2838cab253c8fb Mon Sep 17 00:00:00 2001
From: Gary Williams <gary.williams@forgerock.com>
Date: Fri, 23 Mar 2012 17:23:13 +0000
Subject: [PATCH] Make setup/cleanup a tescase in replication tests.

---
 opends/tests/staf-tests/functional-tests/testcases/replication/changelog/changelog.xml                 |    9 
 opends/tests/staf-tests/functional-tests/testcases/replication/basic/basic.xml                         |    8 
 opends/tests/staf-tests/functional-tests/testcases/replication/schema/schema.xml                       |    8 
 opends/tests/staf-tests/functional-tests/testcases/replication/conflict/conflict.xml                   |    7 
 opends/tests/staf-tests/functional-tests/testcases/replication/encryption/encryption.xml               |    9 
 opends/tests/staf-tests/functional-tests/testcases/replication/aci/aci.xml                             |   10 
 opends/tests/staf-tests/functional-tests/testcases/replication/replication_cleanup.xml                 |  177 ++++---
 opends/tests/staf-tests/functional-tests/testcases/replication/replication_setup.xml                   |  898 ++++++++++++++++++++------------------
 opends/tests/staf-tests/functional-tests/testcases/replication/binarycopy/binarycopy.xml               |   10 
 opends/tests/staf-tests/functional-tests/testcases/replication/resynchronization/resynchronization.xml |    9 
 opends/tests/staf-tests/functional-tests/testcases/replication/basic/replication_basic_setup.xml       |  203 +++++---
 opends/tests/staf-tests/functional-tests/testcases/replication/totalupdate/totalupdate.xml             |    8 
 opends/tests/staf-tests/functional-tests/testcases/replication/failover/failover.xml                   |    9 
 opends/tests/staf-tests/functional-tests/testcases/replication/ldifimport/ldifimport.xml               |   10 
 14 files changed, 753 insertions(+), 622 deletions(-)

diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/aci/aci.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/aci/aci.xml
index 6a43ed6..d79f07e 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/aci/aci.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/aci/aci.xml
@@ -24,7 +24,7 @@
  ! CDDL HEADER END
  !
  !      Copyright 2010 Sun Microsystems, Inc.
- !      Portions Copyright 2011 ForgeRock AS.
+ !      Portions Copyright 2011-2012 ForgeRock AS.
  ! -->
 <stax>
 
@@ -63,7 +63,8 @@
             file="'%s/testcases/replication/replication_setup.xml'
                   % (TESTS_DIR)"/>
           <call function="'replication_setup'">
-            { 'dataFile' : 'Short_Example.ldif' }
+            { 'dataFile' : 'Short_Example.ldif' ,
+              'label'    : 'Replication ACI' }
           </call>
                                     
           <script>
@@ -1064,11 +1065,12 @@
             </sequence>
           </testcase>
 
-
           <import machine="STAF_LOCAL_HOSTNAME"
             file="'%s/testcases/replication/replication_cleanup.xml' 
                   % (TESTS_DIR)"/>
-          <call function="'replication_cleanup'" />
+          <call function="'replication_cleanup'" >
+            { 'label'    : 'Replication ACI' }
+          </call>
 
           <call function="'testSuite_Postamble'"/>
                   
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/basic/basic.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/basic/basic.xml
index c6abd8c..847fd34 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/basic/basic.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/basic/basic.xml
@@ -61,7 +61,9 @@
           <import machine="STAF_LOCAL_HOSTNAME"
             file="'%s/testcases/replication/replication_setup.xml' 
               % (TESTS_DIR)"/>
-          <call function="'replication_setup'" />
+          <call function="'replication_setup'" >
+            { 'label'    : 'Replication Basic' }
+          </call>
     
           <import machine="STAF_LOCAL_HOSTNAME"
             file="'%s/testcases/replication/basic/replication_basic_setup.xml'
@@ -2048,7 +2050,9 @@
           <import machine="STAF_LOCAL_HOSTNAME"
             file="'%s/testcases/replication/replication_cleanup.xml' 
                   % (TESTS_DIR)"/>
-          <call function="'replication_cleanup'" />
+          <call function="'replication_cleanup'">
+            { 'label'    : 'Replication Basic' }
+          </call>
 
           <call function="'testSuite_Postamble'"/>
         
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/basic/replication_basic_setup.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/basic/replication_basic_setup.xml
index 150b5b4..b1573c8 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/basic/replication_basic_setup.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/basic/replication_basic_setup.xml
@@ -24,7 +24,7 @@
  ! CDDL HEADER END
  !
  !      Copyright 2007-2008 Sun Microsystems, Inc.
- !      Portions Copyright 2011 ForgeRock AS.
+ !      Portions Copyright 2011-2012 ForgeRock AS.
  ! -->
 <stax>
 
@@ -32,97 +32,126 @@
 
   <function name="replication_basic_setup">
 
-    <sequence>
+    <block name="'replication-basic-setup'">
+    
+      <testcase name="getTestCaseName('Basic Preamble')">
 
-      <!--- Setup the client for the Basic test suite -->      
-      <message>
-        'Replication: Basic: Setup. Get client ready for Basic tests.'
-      </message>          
-  
-      <script>
-        synchroSuffix = master.getSynchronizedSuffixList()[0].getSuffixDn()
-        entryDn = 'uid=scarter,%s' % synchroSuffix
-        grandchildEntryDn = 'uid=scarter,ou=People,o=replication tests,%s' \
-                            % synchroSuffix
-        mod_type = 'replace'
-        attr_type = 'roomnumber'
-        attr_value = '1111'        
-      </script>
+        <try>
+        
+          <sequence>
 
-      <script>      
-        filename = 'replication_add_root_suffix.ldif'
-        filePath = '%s/%s' % (local.temp,filename)
-        write_replication_add_root_suffix_ldif_file(filePath, synchroSuffix)
-      </script>
+            <call function="'testCase_Preamble'"/>
 
-      <!-- Copy the replication_add_root_suffix ldif to client host -->
-      <message>
-        'Copy %s file from %s to %s' % (filename,local.temp,client.getTmpDir())
-      </message>
-      <call function="'copyFile'">
-        { 'srcfile'    : filePath,
-          'destfile'   : '%s/%s' % (client.getTmpDir(),filename),
-          'remotehost' : client.getHostname() }
-      </call>      
-
-      <script>
-        filename = 'replication_add_single.ldif'
-        filePath = '%s/%s' % (local.temp,filename)
-        write_replication_add_single_ldif_file(filePath, synchroSuffix)               
-      </script>
-
-      <!-- Copy the replication_add_single ldif to client host -->
-      <message>
-        'Copy %s file from %s to %s' % (filename,local.temp,client.getTmpDir())
-      </message>
-      <call function="'copyFile'">
-        { 'srcfile'    : filePath,
-          'destfile'   : '%s/%s' % (client.getTmpDir(),filename),
-          'remotehost' : client.getHostname() }
-      </call>
-                  
-      <script>
-        filename = 'replication_add_multiple.ldif'
-        filePath = '%s/%s' % (local.temp,filename)
-        write_replication_add_multiple_ldif_file(filePath, synchroSuffix)               
-      </script>
-
-      <!-- Copy the replication_add_multiple ldif to client host -->
-      <message>
-        'Copy %s file from %s to %s' % (filename,local.temp,client.getTmpDir())
-      </message>
-      <call function="'copyFile'">
-        { 'srcfile'    : filePath,
-          'destfile'   : '%s/%s' % (client.getTmpDir(),filename),
-          'remotehost' : client.getHostname() }
-      </call>            
+            <!--- Setup the client for the Basic test suite -->      
+            <message>
+              'Replication: Basic: Setup. Get client ready for Basic tests.'
+            </message>          
+        
+            <script>
+              synchroSuffix = master.getSynchronizedSuffixList()[0].getSuffixDn()
+              entryDn = 'uid=scarter,%s' % synchroSuffix
+              grandchildEntryDn = 'uid=scarter,ou=People,o=replication tests,%s' \
+                                  % synchroSuffix
+              mod_type = 'replace'
+              attr_type = 'roomnumber'
+              attr_value = '1111'        
+            </script>
       
-      <script>
-        filename = 'replication_mod.ldif'
-        filePath = '%s/%s' % (local.temp,filename)
-        write_replication_mod_ldif_file(filePath, entryDn, mod_type, attr_type,
-                                        attr_value)
-      </script>
-
-      <!-- Copy the replication_mod ldif to client host -->
-      <message>
-        'Copy %s file from %s to %s' % (filename,local.temp,client.getTmpDir())
-      </message>
-      <call function="'copyFile'">
-        { 'srcfile'    : filePath,
-          'destfile'   : '%s/%s' % (client.getTmpDir(),filename),
-          'remotehost' : client.getHostname()
-        }
-      </call>          
-          
-                    
-      <call function="'checkRC'">
-        { 'returncode' : RC ,
-          'result'     : STAXResult
-        }
-      </call>
+            <script>      
+              filename = 'replication_add_root_suffix.ldif'
+              filePath = '%s/%s' % (local.temp,filename)
+              write_replication_add_root_suffix_ldif_file(filePath, synchroSuffix)
+            </script>
+      
+            <!-- Copy the replication_add_root_suffix ldif to client host -->
+            <message>
+              'Copy %s file from %s to %s' % (filename,local.temp,client.getTmpDir())
+            </message>
+            <call function="'copyFile'">
+              { 'srcfile'    : filePath,
+                'destfile'   : '%s/%s' % (client.getTmpDir(),filename),
+                'remotehost' : client.getHostname() }
+            </call>      
+      
+            <script>
+              filename = 'replication_add_single.ldif'
+              filePath = '%s/%s' % (local.temp,filename)
+              write_replication_add_single_ldif_file(filePath, synchroSuffix)               
+            </script>
+      
+            <!-- Copy the replication_add_single ldif to client host -->
+            <message>
+              'Copy %s file from %s to %s' % (filename,local.temp,client.getTmpDir())
+            </message>
+            <call function="'copyFile'">
+              { 'srcfile'    : filePath,
+                'destfile'   : '%s/%s' % (client.getTmpDir(),filename),
+                'remotehost' : client.getHostname() }
+            </call>
+                        
+            <script>
+              filename = 'replication_add_multiple.ldif'
+              filePath = '%s/%s' % (local.temp,filename)
+              write_replication_add_multiple_ldif_file(filePath, synchroSuffix)               
+            </script>
+      
+            <!-- Copy the replication_add_multiple ldif to client host -->
+            <message>
+              'Copy %s file from %s to %s' % (filename,local.temp,client.getTmpDir())
+            </message>
+            <call function="'copyFile'">
+              { 'srcfile'    : filePath,
+                'destfile'   : '%s/%s' % (client.getTmpDir(),filename),
+                'remotehost' : client.getHostname() }
+            </call>            
+            
+            <script>
+              filename = 'replication_mod.ldif'
+              filePath = '%s/%s' % (local.temp,filename)
+              write_replication_mod_ldif_file(filePath, entryDn, mod_type, attr_type,
+                                              attr_value)
+            </script>
+      
+            <!-- Copy the replication_mod ldif to client host -->
+            <message>
+              'Copy %s file from %s to %s' % (filename,local.temp,client.getTmpDir())
+            </message>
+            <call function="'copyFile'">
+              { 'srcfile'    : filePath,
+                'destfile'   : '%s/%s' % (client.getTmpDir(),filename),
+                'remotehost' : client.getHostname()
+              }
+            </call>          
+                
+                          
+            <call function="'checkRC'">
+              { 'returncode' : RC ,
+                'result'     : STAXResult
+              }
+            </call>
                                   
-    </sequence>
+              <tcstatus result="'pass'"></tcstatus>                      
+
+            </sequence> 
+  
+            <catch exception="'STAXException'" typevar="eType" var="eInfo">
+              <sequence>
+              <message log="1" level="'fatal'">
+                '%s: Failed to cleanup. eInfo(%s)' % (eType,eInfo)
+              </message>
+              <throw exception="'STAFException.TestSuite.CleanupException'" />
+              </sequence>
+            </catch>
+            <finally>
+              <!-- Test Case postamble -->
+              <call function="'testCase_Postamble'"/>
+            </finally>
+  
+          </try>        
+
+        </testcase>
+
+      </block>
       
   </function>
 
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/binarycopy/binarycopy.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/binarycopy/binarycopy.xml
index bf8eaae..4caa6a1 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/binarycopy/binarycopy.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/binarycopy/binarycopy.xml
@@ -24,7 +24,7 @@
  ! CDDL HEADER END
  !
  !      Copyright 2007-2010 Sun Microsystems, Inc.
- !      Portions Copyright 2011 ForgeRock AS.
+ !      Portions Copyright 2011-2012 ForgeRock AS.
  ! -->
 <stax>
   <defaultcall function="replication_binarycopy"/>
@@ -53,7 +53,9 @@
           <import machine="STAF_LOCAL_HOSTNAME"
                   file="'%s/testcases/replication/replication_setup.xml' 
                         % (TESTS_DIR)"/>
-          <call function="'replication_setup'" />
+          <call function="'replication_setup'" >
+            { 'label'    : 'Replication Binarycopy' }
+          </call>
 
           
           <!--- Test Case information
@@ -406,7 +408,9 @@
           <import machine="STAF_LOCAL_HOSTNAME"
                   file="'%s/testcases/replication/replication_cleanup.xml' 
                         % (TESTS_DIR)"/>
-          <call function="'replication_cleanup'" />
+          <call function="'replication_cleanup'" >
+            { 'label'    : 'Replication Binarycopy' }
+          </call>
           <call function="'testSuite_Postamble'"/>
         </sequence>
       </block>
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/changelog/changelog.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/changelog/changelog.xml
index 51a0681..a3ef9c5 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/changelog/changelog.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/changelog/changelog.xml
@@ -24,7 +24,7 @@
  ! CDDL HEADER END
  !
  !      Copyright 2008-2009 Sun Microsystems, Inc.
- !      Portions Copyright 2011 ForgeRock AS.
+ !      Portions Copyright 2011-2012 ForgeRock AS.
  ! -->
 <stax>
     
@@ -59,7 +59,8 @@
                   file="'%s/testcases/replication/replication_setup.xml' 
                         % (TESTS_DIR)"/>
           <call function="'replication_setup'">
-            { 'dataFile' : 'Example.ldif' }
+            { 'dataFile' : 'Example.ldif',
+              'label'    : 'Replication Changelog' }
           </call>         
 
 
@@ -1448,7 +1449,9 @@
           <import machine="STAF_LOCAL_HOSTNAME"
                   file="'%s/testcases/replication/replication_cleanup.xml' 
                         % (TESTS_DIR)"/>
-          <call function="'replication_cleanup'" />
+          <call function="'replication_cleanup'" >
+            { 'label'    : 'Replication Changelog' }
+          </call>
 
           <call function="'testSuite_Postamble'"/>
         </sequence>
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/conflict/conflict.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/conflict/conflict.xml
index 66ec322..4de257a 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/conflict/conflict.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/conflict/conflict.xml
@@ -66,7 +66,8 @@
                                       % REPLICATION_CONFIG_DIR,
               'dataFile'           : 'Short_Example.ldif',
               'isolateLdapServers' : True,
-              'enableDebugLogs'    : False
+              'enableDebugLogs'    : False,
+              'label'              : 'Replication Conflict'
             }
           </call>
                                     
@@ -3549,7 +3550,9 @@
           <import machine="STAF_LOCAL_HOSTNAME"
             file="'%s/testcases/replication/replication_cleanup.xml' 
                   % (TESTS_DIR)"/>
-          <call function="'replication_cleanup'" />
+          <call function="'replication_cleanup'" >
+            { 'label'    : 'Replication Conflict' }
+          </call>
                           
           <call function="'testSuite_Postamble'"/>
                   
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/encryption/encryption.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/encryption/encryption.xml
index ba9483a..ef5b0ea 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/encryption/encryption.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/encryption/encryption.xml
@@ -24,7 +24,7 @@
  ! CDDL HEADER END
  !
  !      Copyright 2007-2010 Sun Microsystems, Inc.
- !      Portions Copyright 2011 ForgeRock AS.
+ !      Portions Copyright 2011-2012 ForgeRock AS.
  ! -->
 <stax>
 
@@ -65,7 +65,8 @@
             { 'topologyFile'     : '%s/3server_topology.txt' \
                                     % REPLICATION_CONFIG_DIR,
               'secureReplication': True,
-              'dataFile'         : 'Example.ldif'
+              'dataFile'         : 'Example.ldif',
+              'label'            : 'Replication Encryption'
             }
           </call>
                                     
@@ -941,7 +942,9 @@
           <import machine="STAF_LOCAL_HOSTNAME"
             file="'%s/testcases/replication/replication_cleanup.xml' 
                   % (TESTS_DIR)"/>
-          <call function="'replication_cleanup'" />
+          <call function="'replication_cleanup'" >
+            { 'label'    : 'Replication Encryption' }
+          </call>
 
           <call function="'testSuite_Postamble'"/>
                   
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/failover/failover.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/failover/failover.xml
index 03afb99..3b9a4c3 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/failover/failover.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/failover/failover.xml
@@ -24,7 +24,7 @@
  ! CDDL HEADER END
  !
  !      Copyright 2007-2010 Sun Microsystems, Inc.
- !      Portions Copyright 2011 ForgeRock AS.
+ !      Portions Copyright 2011-2012 ForgeRock AS.
  ! -->
 <stax>
 
@@ -60,7 +60,8 @@
           <import machine="STAF_LOCAL_HOSTNAME"
             file="'%s/testcases/replication/replication_setup.xml' % (TESTS_DIR)"/>
           <call function="'replication_setup'">
-            {  'topologyFile' : '%s/3server_topology.txt' % REPLICATION_CONFIG_DIR }
+            {  'topologyFile' : '%s/3server_topology.txt' % REPLICATION_CONFIG_DIR ,
+               'label'        : 'Replication Failover' }
           </call>
                                     
           <script>
@@ -528,7 +529,9 @@
                                                 
           <import machine="STAF_LOCAL_HOSTNAME"
             file="'%s/testcases/replication/replication_cleanup.xml' % (TESTS_DIR)"/>
-          <call function="'replication_cleanup'" />
+          <call function="'replication_cleanup'" >
+            { 'label' : 'Replication Failover' }
+          </call>
                           
           <call function="'testSuite_Postamble'"/>
                   
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/ldifimport/ldifimport.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/ldifimport/ldifimport.xml
index 465b38f..51bb7c8 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/ldifimport/ldifimport.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/ldifimport/ldifimport.xml
@@ -24,7 +24,7 @@
  ! CDDL HEADER END
  !
  !      Copyright 2007-2010 Sun Microsystems, Inc.
- !      Portions Copyright 2011 ForgeRock AS.
+ !      Portions Copyright 2011-2012 ForgeRock AS.
  ! -->
 <stax>
 
@@ -62,7 +62,9 @@
           <import machine="STAF_LOCAL_HOSTNAME"
             file="'%s/testcases/replication/replication_setup.xml'
                   % (TESTS_DIR)"/>
-          <call function="'replication_setup'" />
+          <call function="'replication_setup'" >
+            { 'label'    : 'Replication LDIFimport' }
+          </call>
      
             
           <!--- Test Case information
@@ -420,7 +422,9 @@
           <import machine="STAF_LOCAL_HOSTNAME"
             file="'%s/testcases/replication/replication_cleanup.xml'
                   % (TESTS_DIR)"/>
-          <call function="'replication_cleanup'" />
+          <call function="'replication_cleanup'" >
+            { 'label'    : 'Replication LDIFimport' }
+          </call>
                           
           <call function="'testSuite_Postamble'"/>
                   
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/replication_cleanup.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/replication_cleanup.xml
index 9c66cb6..340aebd 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/replication_cleanup.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/replication_cleanup.xml
@@ -24,6 +24,7 @@
  ! CDDL HEADER END
  !
  !      Copyright 2007-2008 Sun Microsystems, Inc.
+ !      Portions Copyright 2012 ForgeRock AS.
  ! -->
 <stax>
 
@@ -39,84 +40,116 @@
         </function-arg-description>
         <function-arg-property name="type" value="string"/>
       </function-arg-def>
+      <function-arg-def name="label" 
+                        type="optional"
+                        default="'Replication'">
+        <function-arg-description>
+          Friendly label name
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>          
+      </function-arg-def>
     </function-map-args>
     <sequence>
 
       <block name="'replication-cleanup'">
 
-        <sequence>                      
-                  
-          <!-- Stop the servers in the topology -->      
-          <call function="'stopServers'">
-            [_splitServerList]
-          </call>
-          
-          <!-- Copy the server logs to the controller machine -->
-          <if expr="suiteSuffix != None">
-            <paralleliterate var="server" in="_splitServerList" indexvar="i">
-              <sequence>
-                <script>
-                  suffix     = suiteSuffix + '_%s' % (i + 1)
-                  serverHost = server.getHostname()
-                  serverName = '%s:%s' % (serverHost, server.getPort())
-                  serverPath = '%s/%s' % (server.getDir(), OPENDSNAME)
-                </script>
-              
-                <message>
-                  'Copy %s/logs/errors from %s to %s/errors_%s on %s' % \
-                  (serverPath, serverName, logs.sut, suffix, STAXServiceMachine)
-                </message>
-                <call function="'copyFile'">
-                  {
-                    'location'   : serverHost,
-                    'srcfile'    : '%s/logs/errors' % serverPath,
-                    'destfile'   : '%s/errors_%s' % (logs.sut, suffix),
-                    'remotehost' : STAXServiceMachine
-                  }
-                </call>
-                <message>
-                  'Copy %s/logs/access from %s to %s/access_%s on %s' % \
-                  (serverPath, serverName,logs.sut, suffix, STAXServiceMachine)
-                </message>
-                <call function="'copyFile'">
-                  {
-                    'location'   : serverHost,
-                    'srcfile'    : '%s/logs/access' % serverPath,
-                    'destfile'   : '%s/access_%s' % (logs.sut, suffix),
-                    'remotehost' : STAXServiceMachine
-                  }
-                </call>
-                <message>
-                  'Copy %s/logs/replication from %s to %s/replication_%s on %s' % \
-                  (serverPath, serverName, logs.sut, suffix, STAXServiceMachine)
-                </message>
-                <call function="'copyFile'">
-                  {
-                    'location'   : serverHost,
-                    'srcfile'    : '%s/logs/replication' % serverPath,
-                    'destfile'   : '%s/replication_%s' % (logs.sut, suffix),
-                    'remotehost' : STAXServiceMachine
-                  }
-                </call>
-              </sequence>
-            </paralleliterate>
-          </if>
-              
-          <!-- Remove  the topology created for the test suite -->
-          <message>
-            'Remove DS topology created for the Synchronization Basic Test Suite'
-          </message>          
-  
-          <call function="'removeTopology'">
-            { 'multipleInstanceTopology' : True }
-          </call>  
-  
-          <call function="'checkRC'">
-            { 'returncode' : RC ,
-              'result'     : STAXResult }
-          </call>
+        <testcase name="getTestCaseName('%s Cleanup' % label)">
 
-        </sequence>
+          <try>
+          
+            <sequence>
+              <call function="'testCase_Preamble'"/>                      
+                  
+              <!-- Stop the servers in the topology -->      
+              <call function="'stopServers'">
+                [_splitServerList]
+              </call>
+              
+              <!-- Copy the server logs to the controller machine -->
+              <if expr="suiteSuffix != None">
+                <paralleliterate var="server" in="_splitServerList" indexvar="i">
+                  <sequence>
+                    <script>
+                      suffix     = suiteSuffix + '_%s' % (i + 1)
+                      serverHost = server.getHostname()
+                      serverName = '%s:%s' % (serverHost, server.getPort())
+                      serverPath = '%s/%s' % (server.getDir(), OPENDSNAME)
+                    </script>
+                  
+                    <message>
+                      'Copy %s/logs/errors from %s to %s/errors_%s on %s' % \
+                      (serverPath, serverName, logs.sut, suffix, STAXServiceMachine)
+                    </message>
+                    <call function="'copyFile'">
+                      {
+                        'location'   : serverHost,
+                        'srcfile'    : '%s/logs/errors' % serverPath,
+                        'destfile'   : '%s/errors_%s' % (logs.sut, suffix),
+                        'remotehost' : STAXServiceMachine
+                      }
+                    </call>
+                    <message>
+                      'Copy %s/logs/access from %s to %s/access_%s on %s' % \
+                      (serverPath, serverName,logs.sut, suffix, STAXServiceMachine)
+                    </message>
+                    <call function="'copyFile'">
+                      {
+                        'location'   : serverHost,
+                        'srcfile'    : '%s/logs/access' % serverPath,
+                        'destfile'   : '%s/access_%s' % (logs.sut, suffix),
+                        'remotehost' : STAXServiceMachine
+                      }
+                    </call>
+                    <message>
+                      'Copy %s/logs/replication from %s to %s/replication_%s on %s' % \
+                      (serverPath, serverName, logs.sut, suffix, STAXServiceMachine)
+                    </message>
+                    <call function="'copyFile'">
+                      {
+                        'location'   : serverHost,
+                        'srcfile'    : '%s/logs/replication' % serverPath,
+                        'destfile'   : '%s/replication_%s' % (logs.sut, suffix),
+                        'remotehost' : STAXServiceMachine
+                      }
+                    </call>
+                  </sequence>
+                </paralleliterate>
+              </if>
+                  
+              <!-- Remove  the topology created for the test suite -->
+              <message>
+                'Remove DS topology created for the Synchronization Basic Test Suite'
+              </message>          
+      
+              <call function="'removeTopology'">
+                { 'multipleInstanceTopology' : True }
+              </call>  
+      
+              <call function="'checkRC'">
+                { 'returncode' : RC ,
+                  'result'     : STAXResult }
+              </call>
+
+              <tcstatus result="'pass'"></tcstatus>                      
+
+            </sequence> 
+  
+            <catch exception="'STAXException'" typevar="eType" var="eInfo">
+              <sequence>
+              <message log="1" level="'fatal'">
+                '%s: Failed to cleanup. eInfo(%s)' % (eType,eInfo)
+              </message>
+              <throw exception="'STAFException.TestSuite.CleanupException'" />
+              </sequence>
+            </catch>
+            <finally>
+              <!-- Test Case postamble -->
+              <call function="'testCase_Postamble'"/>
+            </finally>
+  
+          </try>        
+
+        </testcase>
 
       </block>
     
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/replication_setup.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/replication_setup.xml
index 6889565..dc914e3 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/replication_setup.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/replication_setup.xml
@@ -24,7 +24,7 @@
  ! CDDL HEADER END
  !
  !      Copyright 2007-2010 Sun Microsystems, Inc.
- !      Portions Copyright 2011 ForgeRock AS.
+ !      Portions Copyright 2011-2012 ForgeRock AS.
  ! -->
 <stax>
 
@@ -77,346 +77,332 @@
         </function-arg-description>
         <function-arg-property name="type" value="boolean"/>          
       </function-arg-def>
+      <function-arg-def name="label" 
+                        type="optional"
+                        default="'Replication'">
+        <function-arg-description>
+          Friendly label name
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>          
+      </function-arg-def>
     </function-map-args>    
     
     <sequence>
 
       <block name="'replication-setup'">
 
-        <sequence>
-      
-          <message>
-             'Create DS topology as described in %s' % topologyFile
-          </message>
-                 
-          <call function="'createTopology'">
-            { 'topologyDescFile'        : topologyFile,
-              'sharedDataFolder'        : 'replication',
-              'splitReplicationServers' : globalSplitServers
-            }
-          </call>  
-      
-          <call function="'checkRC'">
-            { 'returncode' : RC ,
-              'result'     : STAXResult
-            }
-          </call>
+        <testcase name="getTestCaseName('%s Setup' % label)">
 
-          <!-- Setup variables -->
-          <script>
-            client = _topologyServerList[0]
-            clientHost = client.getHostname()
-            clientPath = '%s/%s' % (client.getDir(),OPENDSNAME)
-             
-            server1 = _topologyServerList[0]
-            server2 = _topologyServerList[1]          
-              
-            master = _topologyServerList[0]
-            masterHost = master.getHostname()
-            masterReplicationServer = master.getChangelogServer()
-            masterPath = '%s/%s' % (master.getDir(),OPENDSNAME)
-
-            masterDataDir = '%s' % master.getDataDir()
-            clientDataDir = '%s' % client.getDataDir()
-            masterBackupDir = '%s' % master.getTmpDir()
-
-            synchroSuffix = master.getSynchronizedSuffixList()[0].getSuffixDn()
-            
-            consumerList = _topologyServerList[1:]
-              
-            domainMap = STAXGlobal({})
-          </script>       
-
-          <if expr="dataFile">
+          <try>
+          
             <sequence>
-              <script>
-                importDataFile = '%s/replication/%s' % (masterDataDir, dataFile)
-              </script>
-                
+              <call function="'testCase_Preamble'"/>
+      
               <message>
-                'Import data from %s into server %s:%s' \
-                % (importDataFile, masterHost, master.getPort())
+                 'Create DS topology as described in %s' % topologyFile
               </message>
-              
-              <!-- Import data into "master" Directory Server -->
-              <call function="'ImportLdifWithScript'">
-                { 'location'     : masterHost,
-                  'dsPath'       : masterPath,
-                  'backEnd'      : DIRECTORY_INSTANCE_BE,
-                  'ldifFile'     : importDataFile
+                     
+              <call function="'createTopology'">
+                { 'topologyDescFile'        : topologyFile,
+                  'sharedDataFolder'        : 'replication',
+                  'splitReplicationServers' : globalSplitServers
+                }
+              </call>  
+          
+              <call function="'checkRC'">
+                { 'returncode' : RC ,
+                  'result'     : STAXResult
                 }
               </call>
-            
-              <!-- Backup "master" server -->
-              <call function="'backup'">
-                { 'location'  : masterHost,
-                  'dsPath'    : masterPath,
-                  'backupDir' : masterBackupDir
-                }
-              </call>                                         
-            </sequence>
-          </if>
- 
-                          
-          <!-- Start the servers in the topology -->        
-          <call function="'startServers'">
-            [_splitServerList]
-          </call>
-          
-          <if expr="len(_topologyReplServerList) != 0">
-            <paralleliterate var="replServer" in="_topologyReplServerList">
-              <!-- Remove userRoot backend from replication servers -->
-              <sequence>
-                <message>
-                  'Remove userRoot backend from replication server %s:%s' % \
-                  (replServer.getHostname(), replServer.getPort())
-                </message>
-  
-                <call function="'dsconfig'">
-                  { 'location'            : replServer.getHostname(),
-                    'dsPath'              : '%s/%s' \
-                                            % (replServer.getDir(),OPENDSNAME),
-                    'dsInstanceHost'      : replServer.getHostname(),
-                    'dsInstanceAdminPort' : replServer.getAdminPort(),
-                    'dsInstanceDn'        : replServer.getRootDn(),
-                    'dsInstancePswd'      : replServer.getRootPwd(),
-                    'subcommand'          : 'delete-backend',
-                    'objectType'          : 'backend-name',
-                    'objectName'          : 'userRoot'
-                  }
-                </call>
-              </sequence>
-            </paralleliterate>
-          </if>
-              
-          <iterate var="server" in="_splitServerList[1:]">
-            <sequence>
-              <!-- Configure replication if required so by the server
-               !  (i.e. server is a changelog server and/or has synchronized 
-               !  suffixes) 
-              -->
-              <if expr="server.requiresSynchronization()">
-                <sequence>          
-                  <message>
-                    'Instance requires REPLICATION configuration.'
-                  </message>
-                    
-                  <script>
-                    if master.isOnlyLdapServer():
-                      masterReplPort = None
-                    else:
-                      masterReplPort = masterReplicationServer.getPort()
-                    
-                    if server.isOnlyLdapServer():
-                      serverReplPort = None
-                    else:
-                      replicationServer = server.getChangelogServer()
-                      serverReplPort = replicationServer.getPort() 
-                      
-                    if server.isOnlyReplServer():
-                      suffixServer = master
-                    else:
-                      suffixServer = server  
-
-                    replicatedSuffixList = suffixServer.getSynchronizedSuffixList()
-                    replicatedDnList = []
-                    for suffix in replicatedSuffixList:
-                      replicatedDnList.append(suffix.getSuffixDn())
-                  </script>
-                                        
-                  <message>
-                    'Enable replication for server:\nHost: %s\nLdap port: %s\n\
-                    Replication port: %s\nReplicated DN list: %s' \
-                      % (server.getHostname(), server.getPort(), 
-                         serverReplPort, replicatedDnList)
-                  </message>
-                                        
-                  <call function="'enableReplication'">
-                    { 'location'             : clientHost,
-                      'dsPath'               : clientPath,
-                      'refInstanceHost'      : masterHost,
-                      'refInstanceAdminPort' : master.getAdminPort(),
-                      'refInstanceDn'        : master.getRootDn(),
-                      'refInstancePswd'      : master.getRootPwd(),
-                      'refReplicationPort'   : masterReplPort,
-                      'refSecureReplication' : secureReplication,
-                      'refOnlyLdapServer'    : master.isOnlyLdapServer(),
-                      'refOnlyReplServer'    : master.isOnlyReplServer(),
-                      'dsInstanceHost'       : server.getHostname(),
-                      'dsInstanceAdminPort'  : server.getAdminPort(),
-                      'dsInstanceDn'         : server.getRootDn(),
-                      'dsInstancePswd'       : server.getRootPwd(),
-                      'dsReplicationPort'    : serverReplPort,
-                      'dsSecureReplication'  : secureReplication,
-                      'dsOnlyLdapServer'     : server.isOnlyLdapServer(),
-                      'dsOnlyReplServer'     : server.isOnlyReplServer(),
-                      'replicationDnList'    : replicatedDnList
-                    }                      
-                  </call>
-                </sequence>
-              </if>                
-                
-            </sequence>              
-          </iterate>           
-
-
-          <if expr="isolateLdapServers">
-            <!-- Make each Ldap Server point only to its own Replication
-             !   Server.
-             !   This is used by the Conflict testsuite, in order to be able
-             !   to simulate conflict scenarios -->
-            <paralleliterate var="server" in="_topologyServerList" indexvar="i">
-              <sequence>
-                <script>
-                  ldapServer = '%s:%s' % (server.getHostname(), 
-                                          server.getPort())
-                </script>
-      
-                <!-- Retrieve replication-domain name -->
-                <call function="'dsconfig'">
-                  { 'location'            : server.getHostname(),
-                    'dsPath'              : '%s/%s' \
-                                            % (server.getDir(),OPENDSNAME),
-                    'dsInstanceHost'      : server.getHostname(),
-                    'dsInstanceAdminPort' : server.getAdminPort(),
-                    'dsInstanceDn'        : server.getRootDn(),
-                    'dsInstancePswd'      : server.getRootPwd(),
-                    'subcommand'          : 'list-replication-domains',
-                    'objectType'          : 'provider-name',
-                    'objectName'          : 'Multimaster Synchronization',
-                    'optionsString'       : '--script-friendly'
-                  }
-                </call>
-                <if expr='RC == 0'>
-                  <script>
-                    replicationDomains = STAXResult[0][1]
-                    for line in replicationDomains.splitlines():
-                      if line.find(synchroSuffix) != -1:
-                        domain = line
-                        domainMap[ldapServer] = domain
-                        break
-                  </script>
-                </if>
-
-                <script>
-                  if globalSplitServers:
-                    splitServer = _topologyReplServerList[i]
-                    replicationServer = splitServer.getChangelogServer()
-                    replServer = '%s:%s' % (splitServer.getHostname(),
-                                            replicationServer.getPort())
-                  else:
-                    replicationServer = server.getChangelogServer()
-                    replServer = '%s:%s' % (server.getHostname(),
-                                            replicationServer.getPort())
+    
+              <!-- Setup variables -->
+              <script>
+                client = _topologyServerList[0]
+                clientHost = client.getHostname()
+                clientPath = '%s/%s' % (client.getDir(),OPENDSNAME)
+                 
+                server1 = _topologyServerList[0]
+                server2 = _topologyServerList[1]          
                   
-                  options = '--domain-name "%s" --set replication-server:%s' \
-                            % (domainMap[ldapServer], replServer)
-                </script>
-                <message>
-                  'Removing references to other replication servers \nfor \
-                  domain: %s \nfrom server: %s \nkeep replication server: %s' \
-                  % (domain, ldapServer, replServer)
-                </message>
-                <!-- Remove peer RS from replicated domain -->
-                <call function="'dsconfig'">
-                  { 'location'            : server.getHostname(),
-                    'dsPath'              : '%s/%s' \
-                                            % (server.getDir(),OPENDSNAME),
-                    'dsInstanceHost'      : server.getHostname(),
-                    'dsInstanceAdminPort' : server.getAdminPort(),
-                    'dsInstanceDn'        : server.getRootDn(),
-                    'dsInstancePswd'      : server.getRootPwd(),
-                    'subcommand'          : 'set-replication-domain-prop',
-                    'objectType'          : 'provider-name',
-                    'objectName'          : 'Multimaster Synchronization',
-                    'optionsString'       : options
-                  }
-                </call>
-              </sequence>
-            </paralleliterate>
-          </if>
-
-
-          <script>
-            assuredReplication = globalAssuredReplication
-          </script>
-          <if expr="assuredReplication">
-            <paralleliterate var="server" in="_topologyServerList">
-              <sequence>
-                <script>
-                  ldapServer = '%s:%s' % (server.getHostname(), 
-                                          server.getPort())
-                </script>
+                master = _topologyServerList[0]
+                masterHost = master.getHostname()
+                masterReplicationServer = master.getChangelogServer()
+                masterPath = '%s/%s' % (master.getDir(),OPENDSNAME)
+    
+                masterDataDir = '%s' % master.getDataDir()
+                clientDataDir = '%s' % client.getDataDir()
+                masterBackupDir = '%s' % master.getTmpDir()
+    
+                synchroSuffix = master.getSynchronizedSuffixList()[0].getSuffixDn()
                 
-                <if expr="isolateLdapServers">
-                  <!-- this means the domainMap has already been filled up -->
+                consumerList = _topologyServerList[1:]
+                  
+                domainMap = STAXGlobal({})
+              </script>       
+    
+              <if expr="dataFile">
+                <sequence>
                   <script>
-                    domain = domainMap[ldapServer]
+                    importDataFile = '%s/replication/%s' % (masterDataDir, dataFile)
                   </script>
-                  <else>
-                    <sequence>
-                      <!-- Retrieve replication-domain name -->
-                      <call function="'dsconfig'">
-                        { 'location'            : server.getHostname(),
-                          'dsPath'              : '%s/%s' \
-                                                  % (server.getDir(),OPENDSNAME),
-                          'dsInstanceHost'      : server.getHostname(),
-                          'dsInstanceAdminPort' : server.getAdminPort(),
-                          'dsInstanceDn'        : server.getRootDn(),
-                          'dsInstancePswd'      : server.getRootPwd(),
-                          'subcommand'          : 'list-replication-domains',
-                          'objectType'          : 'provider-name',
-                          'objectName'          : 'Multimaster Synchronization',
-                          'optionsString'       : '--script-friendly'
-                        }
+                    
+                  <message>
+                    'Import data from %s into server %s:%s' \
+                    % (importDataFile, masterHost, master.getPort())
+                  </message>
+                  
+                  <!-- Import data into "master" Directory Server -->
+                  <call function="'ImportLdifWithScript'">
+                    { 'location'     : masterHost,
+                      'dsPath'       : masterPath,
+                      'backEnd'      : DIRECTORY_INSTANCE_BE,
+                      'ldifFile'     : importDataFile
+                    }
+                  </call>
+                
+                  <!-- Backup "master" server -->
+                  <call function="'backup'">
+                    { 'location'  : masterHost,
+                      'dsPath'    : masterPath,
+                      'backupDir' : masterBackupDir
+                    }
+                  </call>                                         
+                </sequence>
+              </if>
+     
+                              
+              <!-- Start the servers in the topology -->        
+              <call function="'startServers'">
+                [_splitServerList]
+              </call>
+              
+              <if expr="len(_topologyReplServerList) != 0">
+                <paralleliterate var="replServer" in="_topologyReplServerList">
+                  <!-- Remove userRoot backend from replication servers -->
+                  <sequence>
+                    <message>
+                      'Remove userRoot backend from replication server %s:%s' % \
+                      (replServer.getHostname(), replServer.getPort())
+                    </message>
+      
+                    <call function="'dsconfig'">
+                      { 'location'            : replServer.getHostname(),
+                        'dsPath'              : '%s/%s' \
+                                                % (replServer.getDir(),OPENDSNAME),
+                        'dsInstanceHost'      : replServer.getHostname(),
+                        'dsInstanceAdminPort' : replServer.getAdminPort(),
+                        'dsInstanceDn'        : replServer.getRootDn(),
+                        'dsInstancePswd'      : replServer.getRootPwd(),
+                        'subcommand'          : 'delete-backend',
+                        'objectType'          : 'backend-name',
+                        'objectName'          : 'userRoot'
+                      }
+                    </call>
+                  </sequence>
+                </paralleliterate>
+              </if>
+                  
+              <iterate var="server" in="_splitServerList[1:]">
+                <sequence>
+                  <!-- Configure replication if required so by the server
+                   !  (i.e. server is a changelog server and/or has synchronized 
+                   !  suffixes) 
+                  -->
+                  <if expr="server.requiresSynchronization()">
+                    <sequence>          
+                      <message>
+                        'Instance requires REPLICATION configuration.'
+                      </message>
+                        
+                      <script>
+                        if master.isOnlyLdapServer():
+                          masterReplPort = None
+                        else:
+                          masterReplPort = masterReplicationServer.getPort()
+                        
+                        if server.isOnlyLdapServer():
+                          serverReplPort = None
+                        else:
+                          replicationServer = server.getChangelogServer()
+                          serverReplPort = replicationServer.getPort() 
+                          
+                        if server.isOnlyReplServer():
+                          suffixServer = master
+                        else:
+                          suffixServer = server  
+    
+                        replicatedSuffixList = suffixServer.getSynchronizedSuffixList()
+                        replicatedDnList = []
+                        for suffix in replicatedSuffixList:
+                          replicatedDnList.append(suffix.getSuffixDn())
+                      </script>
+                                            
+                      <message>
+                        'Enable replication for server:\nHost: %s\nLdap port: %s\n\
+                        Replication port: %s\nReplicated DN list: %s' \
+                          % (server.getHostname(), server.getPort(), 
+                             serverReplPort, replicatedDnList)
+                      </message>
+                                            
+                      <call function="'enableReplication'">
+                        { 'location'             : clientHost,
+                          'dsPath'               : clientPath,
+                          'refInstanceHost'      : masterHost,
+                          'refInstanceAdminPort' : master.getAdminPort(),
+                          'refInstanceDn'        : master.getRootDn(),
+                          'refInstancePswd'      : master.getRootPwd(),
+                          'refReplicationPort'   : masterReplPort,
+                          'refSecureReplication' : secureReplication,
+                          'refOnlyLdapServer'    : master.isOnlyLdapServer(),
+                          'refOnlyReplServer'    : master.isOnlyReplServer(),
+                          'dsInstanceHost'       : server.getHostname(),
+                          'dsInstanceAdminPort'  : server.getAdminPort(),
+                          'dsInstanceDn'         : server.getRootDn(),
+                          'dsInstancePswd'       : server.getRootPwd(),
+                          'dsReplicationPort'    : serverReplPort,
+                          'dsSecureReplication'  : secureReplication,
+                          'dsOnlyLdapServer'     : server.isOnlyLdapServer(),
+                          'dsOnlyReplServer'     : server.isOnlyReplServer(),
+                          'replicationDnList'    : replicatedDnList
+                        }                      
                       </call>
-                      <if expr='RC == 0'>
-                        <script>
-                          replicationDomains = STAXResult[0][1]
-                          for line in replicationDomains.splitlines():
-                            if line.find(synchroSuffix) != -1:
-                              domain = line
-                              domainMap[ldapServer] = domain
-                              break
-                        </script>
-                      </if>
                     </sequence>
-                  </else>
-                </if>
-                <script>
-                  options = '--domain-name "%s" --set assured-type:%s' \
-                            % (domain, assuredReplication)
-                </script>
-                <message>
-                  'Setting replication assured-type to: %s  for server: %s \
-                  domain: %s' % (assuredReplication, ldapServer, domain)
-                </message>
-                <!-- Set assured -->
-                <call function="'dsconfig'">
-                  { 'location'            : server.getHostname(),
-                    'dsPath'              : '%s/%s' \
-                                            % (server.getDir(),OPENDSNAME),
-                    'dsInstanceHost'      : server.getHostname(),
-                    'dsInstanceAdminPort' : server.getAdminPort(),
-                    'dsInstanceDn'        : server.getRootDn(),
-                    'dsInstancePswd'      : server.getRootPwd(),
-                    'subcommand'          : 'set-replication-domain-prop',
-                    'objectType'          : 'provider-name',
-                    'objectName'          : 'Multimaster Synchronization',
-                    'optionsString'       : options
-                  }
-                </call>
-
-                <if expr="assuredReplication == 'safe-data'">
+                  </if>                
+                    
+                </sequence>              
+              </iterate>           
+    
+    
+              <if expr="isolateLdapServers">
+                <!-- Make each Ldap Server point only to its own Replication
+                 !   Server.
+                 !   This is used by the Conflict testsuite, in order to be able
+                 !   to simulate conflict scenarios -->
+                <paralleliterate var="server" in="_topologyServerList" indexvar="i">
                   <sequence>
                     <script>
-                      assuredDataLevel = len(_topologyServerList)
-                      options = '--domain-name "%s" --set assured-sd-level:%s' \
-                                % (domain, assuredDataLevel)
+                      ldapServer = '%s:%s' % (server.getHostname(), 
+                                              server.getPort())
+                    </script>
+          
+                    <!-- Retrieve replication-domain name -->
+                    <call function="'dsconfig'">
+                      { 'location'            : server.getHostname(),
+                        'dsPath'              : '%s/%s' \
+                                                % (server.getDir(),OPENDSNAME),
+                        'dsInstanceHost'      : server.getHostname(),
+                        'dsInstanceAdminPort' : server.getAdminPort(),
+                        'dsInstanceDn'        : server.getRootDn(),
+                        'dsInstancePswd'      : server.getRootPwd(),
+                        'subcommand'          : 'list-replication-domains',
+                        'objectType'          : 'provider-name',
+                        'objectName'          : 'Multimaster Synchronization',
+                        'optionsString'       : '--script-friendly'
+                      }
+                    </call>
+                    <if expr='RC == 0'>
+                      <script>
+                        replicationDomains = STAXResult[0][1]
+                        for line in replicationDomains.splitlines():
+                          if line.find(synchroSuffix) != -1:
+                            domain = line
+                            domainMap[ldapServer] = domain
+                            break
+                      </script>
+                    </if>
+    
+                    <script>
+                      if globalSplitServers:
+                        splitServer = _topologyReplServerList[i]
+                        replicationServer = splitServer.getChangelogServer()
+                        replServer = '%s:%s' % (splitServer.getHostname(),
+                                                replicationServer.getPort())
+                      else:
+                        replicationServer = server.getChangelogServer()
+                        replServer = '%s:%s' % (server.getHostname(),
+                                                replicationServer.getPort())
+                      
+                      options = '--domain-name "%s" --set replication-server:%s' \
+                                % (domainMap[ldapServer], replServer)
                     </script>
                     <message>
-                      'Setting safe-data level to: %s  for server: %s \
-                      domain: %s' % (assuredDataLevel, ldapServer, domain)
+                      'Removing references to other replication servers \nfor \
+                      domain: %s \nfrom server: %s \nkeep replication server: %s' \
+                      % (domain, ldapServer, replServer)
+                    </message>
+                    <!-- Remove peer RS from replicated domain -->
+                    <call function="'dsconfig'">
+                      { 'location'            : server.getHostname(),
+                        'dsPath'              : '%s/%s' \
+                                                % (server.getDir(),OPENDSNAME),
+                        'dsInstanceHost'      : server.getHostname(),
+                        'dsInstanceAdminPort' : server.getAdminPort(),
+                        'dsInstanceDn'        : server.getRootDn(),
+                        'dsInstancePswd'      : server.getRootPwd(),
+                        'subcommand'          : 'set-replication-domain-prop',
+                        'objectType'          : 'provider-name',
+                        'objectName'          : 'Multimaster Synchronization',
+                        'optionsString'       : options
+                      }
+                    </call>
+                  </sequence>
+                </paralleliterate>
+              </if>
+    
+    
+              <script>
+                assuredReplication = globalAssuredReplication
+              </script>
+              <if expr="assuredReplication">
+                <paralleliterate var="server" in="_topologyServerList">
+                  <sequence>
+                    <script>
+                      ldapServer = '%s:%s' % (server.getHostname(), 
+                                              server.getPort())
+                    </script>
+                    
+                    <if expr="isolateLdapServers">
+                      <!-- this means the domainMap has already been filled up -->
+                      <script>
+                        domain = domainMap[ldapServer]
+                      </script>
+                      <else>
+                        <sequence>
+                          <!-- Retrieve replication-domain name -->
+                          <call function="'dsconfig'">
+                            { 'location'            : server.getHostname(),
+                              'dsPath'              : '%s/%s' \
+                                                      % (server.getDir(),OPENDSNAME),
+                              'dsInstanceHost'      : server.getHostname(),
+                              'dsInstanceAdminPort' : server.getAdminPort(),
+                              'dsInstanceDn'        : server.getRootDn(),
+                              'dsInstancePswd'      : server.getRootPwd(),
+                              'subcommand'          : 'list-replication-domains',
+                              'objectType'          : 'provider-name',
+                              'objectName'          : 'Multimaster Synchronization',
+                              'optionsString'       : '--script-friendly'
+                            }
+                          </call>
+                          <if expr='RC == 0'>
+                            <script>
+                              replicationDomains = STAXResult[0][1]
+                              for line in replicationDomains.splitlines():
+                                if line.find(synchroSuffix) != -1:
+                                  domain = line
+                                  domainMap[ldapServer] = domain
+                                  break
+                            </script>
+                          </if>
+                        </sequence>
+                      </else>
+                    </if>
+                    <script>
+                      options = '--domain-name "%s" --set assured-type:%s' \
+                                % (domain, assuredReplication)
+                    </script>
+                    <message>
+                      'Setting replication assured-type to: %s  for server: %s \
+                      domain: %s' % (assuredReplication, ldapServer, domain)
                     </message>
                     <!-- Set assured -->
                     <call function="'dsconfig'">
@@ -433,133 +419,179 @@
                         'optionsString'       : options
                       }
                     </call>
+    
+                    <if expr="assuredReplication == 'safe-data'">
+                      <sequence>
+                        <script>
+                          assuredDataLevel = len(_topologyServerList)
+                          options = '--domain-name "%s" --set assured-sd-level:%s' \
+                                    % (domain, assuredDataLevel)
+                        </script>
+                        <message>
+                          'Setting safe-data level to: %s  for server: %s \
+                          domain: %s' % (assuredDataLevel, ldapServer, domain)
+                        </message>
+                        <!-- Set assured -->
+                        <call function="'dsconfig'">
+                          { 'location'            : server.getHostname(),
+                            'dsPath'              : '%s/%s' \
+                                                    % (server.getDir(),OPENDSNAME),
+                            'dsInstanceHost'      : server.getHostname(),
+                            'dsInstanceAdminPort' : server.getAdminPort(),
+                            'dsInstanceDn'        : server.getRootDn(),
+                            'dsInstancePswd'      : server.getRootPwd(),
+                            'subcommand'          : 'set-replication-domain-prop',
+                            'objectType'          : 'provider-name',
+                            'objectName'          : 'Multimaster Synchronization',
+                            'optionsString'       : options
+                          }
+                        </call>
+                      </sequence>
+                    </if>
                   </sequence>
-                </if>
-              </sequence>
-            </paralleliterate>
-          </if>
-
-          <if expr="dataFile">
-            <sequence>
-              <message>
-                'Initialise topology from %s:%s' \
-                % (masterHost, master.getPort())
-              </message>
-                
-              <!-- Initialise the servers in the topology -->
-              <call function="'initializeReplication'">
-                { 'location'                : clientHost,
-                  'dsPath'                  : clientPath,
-                  'sourceInstanceHost'      : masterHost,
-                  'sourceInstanceAdminPort' : master.getAdminPort(),
-                  'replicationDnList'       : [synchroSuffix]
-                }
-              </call>
-              <if expr="0">
-              <iterate var="server" in="consumerList">
+                </paralleliterate>
+              </if>
+    
+              <if expr="dataFile">
                 <sequence>
-<!--                  <call function="'initializeReplication'">
+                  <message>
+                    'Initialise topology from %s:%s' \
+                    % (masterHost, master.getPort())
+                  </message>
+                    
+                  <!-- Initialise the servers in the topology -->
+                  <call function="'initializeReplication'">
                     { 'location'                : clientHost,
                       'dsPath'                  : clientPath,
-                      'dsInstanceHost'          : server.getHostname(),
-                      'dsInstanceAdminPort'     : server.getAdminPort(),
                       'sourceInstanceHost'      : masterHost,
                       'sourceInstanceAdminPort' : master.getAdminPort(),
                       'replicationDnList'       : [synchroSuffix]
                     }
-                  </call> -->
-
-                  <!-- Search initialisation task to check its status -->
-                  <call function="'ldapSearchWithScript'">
-                    {
-                      'location'       : server.getHostname(),
-                      'dsPath'         : '%s/%s' \
-                                         % (server.getDir(), OPENDSNAME),
-                      'dsInstanceHost' : server.getHostname(),
-                      'dsInstancePort' : server.getPort(),
-                      'dsInstanceDn'   : server.getRootDn(),
-                      'dsInstancePswd' : server.getRootPwd(),
-                      'dsBaseDN'       : 'cn=Tasks',
-                      'dsFilter'       : 'ds-task-initialize-domain-dn=%s' \
-                                         % synchroSuffix
-                    }                
-                  </call>                
-                  <script>
-                    searchRC = STAXResult[0][0]
-                    searchResult = STAXResult[0][1]
-                    resultLength = len(searchResult) > 0
-                  </script>
-                  <if expr="resultLength != 0">
+                  </call>
+                  <if expr="0">
+                  <iterate var="server" in="consumerList">
                     <sequence>
-                      <message>
-                        '++++++++ INITIALISATION TASK for %s:%s ++++++++\n%s' \
-                        % (server.getHostname(), server.getPort(), searchResult)
-                      </message>
+    <!--                  <call function="'initializeReplication'">
+                        { 'location'                : clientHost,
+                          'dsPath'                  : clientPath,
+                          'dsInstanceHost'          : server.getHostname(),
+                          'dsInstanceAdminPort'     : server.getAdminPort(),
+                          'sourceInstanceHost'      : masterHost,
+                          'sourceInstanceAdminPort' : master.getAdminPort(),
+                          'replicationDnList'       : [synchroSuffix]
+                        }
+                      </call> -->
+    
+                      <!-- Search initialisation task to check its status -->
+                      <call function="'ldapSearchWithScript'">
+                        {
+                          'location'       : server.getHostname(),
+                          'dsPath'         : '%s/%s' \
+                                             % (server.getDir(), OPENDSNAME),
+                          'dsInstanceHost' : server.getHostname(),
+                          'dsInstancePort' : server.getPort(),
+                          'dsInstanceDn'   : server.getRootDn(),
+                          'dsInstancePswd' : server.getRootPwd(),
+                          'dsBaseDN'       : 'cn=Tasks',
+                          'dsFilter'       : 'ds-task-initialize-domain-dn=%s' \
+                                             % synchroSuffix
+                        }                
+                      </call>                
+                      <script>
+                        searchRC = STAXResult[0][0]
+                        searchResult = STAXResult[0][1]
+                        resultLength = len(searchResult) > 0
+                      </script>
+                      <if expr="resultLength != 0">
+                        <sequence>
+                          <message>
+                            '++++++++ INITIALISATION TASK for %s:%s ++++++++\n%s' \
+                            % (server.getHostname(), server.getPort(), searchResult)
+                          </message>
+                        </sequence>
+                      </if>
                     </sequence>
+                  </iterate>                        
                   </if>
-                </sequence>
-              </iterate>                        
+                  
+                </sequence>              
               </if>
-              
-            </sequence>              
-          </if>
-            
-          <if expr="enableDebugLogs">
-            <paralleliterate var="server" in="_topologyServerList">
-              <sequence>
-                <!-- Set the debug logger to "enabled" -->
-                <call function="'dsconfigSet'">
-                  { 'location'            : server.getHostname(),
-                    'dsPath'              : '%s/%s' \
-                                            % (server.getDir(),OPENDSNAME),
-                    'dsInstanceHost'      : server.getHostname(),
-                    'dsInstanceAdminPort' : server.getAdminPort(),
-                    'dsInstanceDn'        : server.getRootDn(),
-                    'dsInstancePswd'      : server.getRootPwd(),
-                    'objectName'          : 'log-publisher',
-                    'propertyType'        : 'publisher',
-                    'propertyName'        : 'File-based Debug Logger',
-                    'attributeName'       : 'enabled',
-                    'attributeValue'      : 'true'
-                  }
-                </call>
-                <!-- Set the debug level to "info" -->
-                <call function="'dsconfigSet'">
-                  { 'location'            : server.getHostname(),
-                    'dsPath'              : '%s/%s' \
-                                            % (server.getDir(),OPENDSNAME),
-                    'dsInstanceHost'      : server.getHostname(),
-                    'dsInstanceAdminPort' : server.getAdminPort(),
-                    'dsInstanceDn'        : server.getRootDn(),
-                    'dsInstancePswd'      : server.getRootPwd(),
-                    'objectName'          : 'log-publisher',
-                    'propertyType'        : 'publisher',
-                    'propertyName'        : 'File-based Debug Logger',
-                    'attributeName'       : 'default-debug-level',
-                    'attributeValue'      : 'info'
-                  }
-                </call>
-                <!-- Set the debug logger log file to "logs/errors" -->              
-                <call function="'dsconfigSet'">
-                  { 'location'            : server.getHostname(),
-                    'dsPath'              : '%s/%s' \
-                                            % (server.getDir(),OPENDSNAME),
-                    'dsInstanceHost'      : server.getHostname(),
-                    'dsInstanceAdminPort' : server.getAdminPort(),
-                    'dsInstanceDn'        : server.getRootDn(),
-                    'dsInstancePswd'      : server.getRootPwd(),
-                    'objectName'          : 'log-publisher',
-                    'propertyType'        : 'publisher',
-                    'propertyName'        : 'File-based Debug Logger',
-                    'attributeName'       : 'log-file',
-                    'attributeValue'      : 'logs/errors'
-                  }
-                </call>
-              </sequence>
-            </paralleliterate>
-          </if>
+                
+              <if expr="enableDebugLogs">
+                <paralleliterate var="server" in="_topologyServerList">
+                  <sequence>
+                    <!-- Set the debug logger to "enabled" -->
+                    <call function="'dsconfigSet'">
+                      { 'location'            : server.getHostname(),
+                        'dsPath'              : '%s/%s' \
+                                                % (server.getDir(),OPENDSNAME),
+                        'dsInstanceHost'      : server.getHostname(),
+                        'dsInstanceAdminPort' : server.getAdminPort(),
+                        'dsInstanceDn'        : server.getRootDn(),
+                        'dsInstancePswd'      : server.getRootPwd(),
+                        'objectName'          : 'log-publisher',
+                        'propertyType'        : 'publisher',
+                        'propertyName'        : 'File-based Debug Logger',
+                        'attributeName'       : 'enabled',
+                        'attributeValue'      : 'true'
+                      }
+                    </call>
+                    <!-- Set the debug level to "info" -->
+                    <call function="'dsconfigSet'">
+                      { 'location'            : server.getHostname(),
+                        'dsPath'              : '%s/%s' \
+                                                % (server.getDir(),OPENDSNAME),
+                        'dsInstanceHost'      : server.getHostname(),
+                        'dsInstanceAdminPort' : server.getAdminPort(),
+                        'dsInstanceDn'        : server.getRootDn(),
+                        'dsInstancePswd'      : server.getRootPwd(),
+                        'objectName'          : 'log-publisher',
+                        'propertyType'        : 'publisher',
+                        'propertyName'        : 'File-based Debug Logger',
+                        'attributeName'       : 'default-debug-level',
+                        'attributeValue'      : 'info'
+                      }
+                    </call>
+                    <!-- Set the debug logger log file to "logs/errors" -->              
+                    <call function="'dsconfigSet'">
+                      { 'location'            : server.getHostname(),
+                        'dsPath'              : '%s/%s' \
+                                                % (server.getDir(),OPENDSNAME),
+                        'dsInstanceHost'      : server.getHostname(),
+                        'dsInstanceAdminPort' : server.getAdminPort(),
+                        'dsInstanceDn'        : server.getRootDn(),
+                        'dsInstancePswd'      : server.getRootPwd(),
+                        'objectName'          : 'log-publisher',
+                        'propertyType'        : 'publisher',
+                        'propertyName'        : 'File-based Debug Logger',
+                        'attributeName'       : 'log-file',
+                        'attributeValue'      : 'logs/errors'
+                      }
+                    </call>
+                  </sequence>
+                </paralleliterate>
+              </if>
 
-        </sequence>
+              <tcstatus result="'pass'"></tcstatus>                      
+
+            </sequence> 
+  
+            <catch exception="'STAXException'" typevar="eType" var="eInfo">
+              <sequence>
+              <message log="1" level="'fatal'">
+                '%s: Failed to cleanup. eInfo(%s)' % (eType,eInfo)
+              </message>
+              <throw exception="'STAFException.TestSuite.CleanupException'" />
+              </sequence>
+            </catch>
+            <finally>
+              <!-- Test Case postamble -->
+              <call function="'testCase_Postamble'"/>
+            </finally>
+  
+          </try>        
+
+        </testcase>
 
       </block>
     
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/resynchronization/resynchronization.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/resynchronization/resynchronization.xml
index 7c65a60..03e17ca 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/resynchronization/resynchronization.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/resynchronization/resynchronization.xml
@@ -24,7 +24,7 @@
  ! CDDL HEADER END
  !
  !      Copyright 2007-2010 Sun Microsystems, Inc.
- !      Portions Copyright 2011 ForgeRock AS.
+ !      Portions Copyright 2011-2012 ForgeRock AS.
  ! -->
 <stax>
   <defaultcall function="replication_resynchronization"/>
@@ -56,7 +56,8 @@
           <call function="'replication_setup'">
             { 'topologyFile' : '%s/3server_topology.txt' \
                                % REPLICATION_CONFIG_DIR,
-              'dataFile'     : 'Example.ldif'
+              'dataFile'     : 'Example.ldif' ,
+              'label'    : 'Replication Resync'
             }
           </call>
           
@@ -830,7 +831,9 @@
           <import machine="STAF_LOCAL_HOSTNAME"
                   file="'%s/testcases/replication/replication_cleanup.xml' 
                         % (TESTS_DIR)"/>
-          <call function="'replication_cleanup'" />
+          <call function="'replication_cleanup'" >
+            { 'label'    : 'Replication Resync' }
+          </call>
           
           <call function="'testSuite_Postamble'"/>
         </sequence>
diff --git a/opends/tests/staf-tests/functional-tests/testcases/replication/schema/schema.xml b/opends/tests/staf-tests/functional-tests/testcases/replication/schema/schema.xml
index cdee0fc..5277922 100644
--- a/opends/tests/staf-tests/functional-tests/testcases/replication/schema/schema.xml
+++ b/opends/tests/staf-tests/functional-tests/testcases/replication/schema/schema.xml
@@ -60,7 +60,9 @@
                                                                         
           <import machine="STAF_LOCAL_HOSTNAME"
            file="'%s/testcases/replication/replication_setup.xml' % TESTS_DIR"/>
-          <call function="'replication_setup'" />
+          <call function="'replication_setup'" >
+            { 'label'    : 'Replication Schema' }
+          </call>
                                     
           <script>
             synchroSuffix = master.getSynchronizedSuffixList()[0].getSuffixDn()    
@@ -1037,7 +1039,9 @@
                                                 
           <import machine="STAF_LOCAL_HOSTNAME"
             file="'%s/testcases/replication/replication_cleanup.xml' % TESTS_DIR"/>
-          <call function="'replication_cleanup'" />
+          <call function="'replication_cleanup'" >
+            { 'label'    : 'Replication Schema' }
+          </call>
                           
           <call function="'testSuite_Postamble'"/>
                   
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 3ad6f72..e5cc13c 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
@@ -55,7 +55,9 @@
           <import machine="STAF_LOCAL_HOSTNAME"
             file="'%s/testcases/replication/replication_setup.xml' 
               % (TESTS_DIR)"/>
-          <call function="'replication_setup'" />
+          <call function="'replication_setup'" >
+            { 'label'    : 'Replication Totalupdate' }
+          </call>
           
           <script>
             server1DataDir = '%s' % server1.getDataDir()
@@ -544,7 +546,9 @@
           <import machine="STAF_LOCAL_HOSTNAME"
             file="'%s/testcases/replication/replication_cleanup.xml' 
                  % (TESTS_DIR)"/>
-          <call function="'replication_cleanup'" />
+          <call function="'replication_cleanup'" >
+            { 'label'    : 'Replication Totalupdate' }
+          </call>
           
           <call function="'testSuite_Postamble'"/>
         </sequence>

--
Gitblit v1.10.0