From c1dc1a5f70f7616013e61477be9b38e363e93097 Mon Sep 17 00:00:00 2001
From: ugaston <ugaston@localhost>
Date: Mon, 17 Sep 2007 17:04:39 +0000
Subject: [PATCH] Update totalupdate testsuite with dsreplication call

---
 opends/tests/functional-tests/testcases/replication/totalupdate/totalupdate.xml |  128 ++++++++++++-------------
 opends/tests/functional-tests/shared/functions/topology.xml                     |  156 +++++++++++++++++++++++++++++++
 2 files changed, 217 insertions(+), 67 deletions(-)

diff --git a/opends/tests/functional-tests/shared/functions/topology.xml b/opends/tests/functional-tests/shared/functions/topology.xml
index c279ebf..c75a276 100755
--- a/opends/tests/functional-tests/shared/functions/topology.xml
+++ b/opends/tests/functional-tests/shared/functions/topology.xml
@@ -916,7 +916,161 @@
   </function>
 
 
-                          
+
+  <!-- Initialize replicated suffix with the contents of a source server using dsreplication -->
+  <function name="initializeReplication">
+    <function-prolog>
+      This function initializes replicated suffixes with the contents 
+      of a source server using dsreplication.
+    </function-prolog>
+    <function-map-args>
+      <function-arg-def name="location"
+                        type="optional"
+                        default="STAF_REMOTE_HOSTNAME">
+        <function-arg-description>
+          Location of target host
+        </function-arg-description>
+        <function-arg-property name="type" value="hostname" />
+      </function-arg-def>
+      
+      <function-arg-def name="dsPath"
+                        type="optional"
+                        default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
+        <function-arg-description>
+          Pathname to installation root
+        </function-arg-description>
+        <function-arg-property name="type" value="filepath" />
+      </function-arg-def>
+      
+      <function-arg-def name="dsInstanceHost"
+                        type="optional"
+                        default="STAF_REMOTE_HOSTNAME">
+        <function-arg-description>
+          Directory server hostname or IP address
+        </function-arg-description>
+        <function-arg-property name="type" value="hostname" />
+      </function-arg-def>
+      
+      <function-arg-def name="dsInstancePort" type="required">
+        <function-arg-description>
+          Directory server port number
+        </function-arg-description>
+        <function-arg-property name="type" value="Port number" />
+      </function-arg-def>
+         
+      <function-arg-def name="sourceInstanceHost"
+                        type="optional"
+                        default="STAF_REMOTE_HOSTNAME">
+        <function-arg-description>
+          Source Directory server hostname or IP address
+        </function-arg-description>
+        <function-arg-property name="type" value="hostname" />
+      </function-arg-def>
+      
+      <function-arg-def name="sourceInstancePort" type="required">
+        <function-arg-description>
+          Source Directory server port number
+        </function-arg-description>
+        <function-arg-property name="type" value="Port number" />
+      </function-arg-def>
+                                    
+      <function-arg-def name="replicationDnList" type="required">
+        <function-arg-description>
+          DN of the replicated suffix
+        </function-arg-description>
+        <function-arg-property name="type" value="DN list" />
+      </function-arg-def>        
+        
+      <function-arg-def name="adminUID" 
+                                   type="optional"
+                                   default="AdminUID">
+        <function-arg-description>
+          Global Administrator UID
+        </function-arg-description>
+        <function-arg-property name="type" value="UID" />
+      </function-arg-def>
+      
+      <function-arg-def name="adminPswd" 
+                                   type="optional"
+                                   default="AdminPswd">
+        <function-arg-description>
+          Global Administrator password
+        </function-arg-description>
+        <function-arg-property name="type" value="string" />
+      </function-arg-def>        
+      
+      <function-arg-def name="expectedRC" type="optional" default="0">
+        <function-arg-description>
+        Expected return code value. Default value is 0
+        </function-arg-description>
+        <function-arg-property name="type" value="string" />
+      </function-arg-def>
+    </function-map-args>
+    <sequence>
+      <!-- Local variables -->
+      <script>
+        mylocation=location
+        STAFCmdParams=''
+        STAFCmd=''
+        
+        if dsPath:
+          dsBinPath='%s/%s' % (dsPath,fileFolder)
+          STAFCmd='%s/%s%s' % (dsBinPath,DSREPLICATION,fileExt)
+        
+        STAFCmdParamsList=[]
+        STAFCmdParamsList.append('initialize')
+        STAFCmdParamsList.append('-n')                    
+        STAFCmdParamsList.append('-Q')
+          
+        if dsInstanceHost:
+          STAFCmdParamsList.append('-O %s' % dsInstanceHost)
+      
+        if dsInstancePort:
+          STAFCmdParamsList.append('--portDestination %s' % dsInstancePort)
+      
+        if sourceInstanceHost:
+          STAFCmdParamsList.append('-h %s' % sourceInstanceHost)
+      
+        if sourceInstancePort:
+          STAFCmdParamsList.append('-p %s' % sourceInstancePort)
+      
+        if replicationDnList:
+          for dn in replicationDnList:
+            STAFCmdParamsList.append('-b "%s"' % dn)
+                    
+        if adminUID:
+          STAFCmdParamsList.append('-I "%s"' % adminUID)
+      
+        if adminPswd:
+          STAFCmdParamsList.append('-w "%s"' % adminPswd)          
+                    
+        STAFCmdParams=' '.join(STAFCmdParamsList)
+      </script>
+      <call function="'runCommand'">
+        { 'name'      : 'Initialize Replication',
+          'location'  : location,
+          'command'   : STAFCmd,
+          'arguments' : STAFCmdParams
+        }
+      </call>
+      <script>
+        STAXCode=RC
+        STAXReason=STAXResult
+      </script>
+      <call function="'checktestRC'">
+        { 'returncode' : STAXCode,
+          'result'     : STAXReason,
+          'expected'   : expectedRC
+        }
+      </call>
+      <return>
+        STAXReason
+      </return>
+    </sequence>
+  </function>
+
+
+                                          
   
   <function name="readTopology">
     <function-prolog>
diff --git a/opends/tests/functional-tests/testcases/replication/totalupdate/totalupdate.xml b/opends/tests/functional-tests/testcases/replication/totalupdate/totalupdate.xml
index 0ce00b9..f404b2d 100644
--- a/opends/tests/functional-tests/testcases/replication/totalupdate/totalupdate.xml
+++ b/opends/tests/functional-tests/testcases/replication/totalupdate/totalupdate.xml
@@ -53,36 +53,36 @@
             
               <call function="'testCase_Preamble'"/>
               
-              <!-- Stop the Directory Server -->
+              <!-- Stop "master" Directory Server -->
               <call function="'StopDsWithScript'">
-                { 'location'  : server1.getHostname(),
-                  'dsPath'    : '%s/%s' % (server1.getDir(),OPENDSNAME),
-                  'dsHost'    : server1.getHostname(),
-                  'dsPort'    : server1.getPort(),
-                  'dsBindDN'  : server1.getRootDn(),
-                  'dsBindPwd' : server1.getRootPwd()
+                { 'location'  : masterHost,
+                  'dsPath'    : masterPath,
+                  'dsHost'    : masterHost,
+                  'dsPort'    : master.getPort(),
+                  'dsBindDN'  : master.getRootDn(),
+                  'dsBindPwd' : master.getRootPwd()
                 }
               </call>
               
               <!-- Check that the Directory Server is stopped -->
               
-              <!-- Import data into Directory Server -->
+              <!-- Import data into "master" Directory Server -->
               <call function="'ImportLdifWithScript'">
-                { 'location'     : server1.getHostname() ,
-                  'dsPath'       : '%s/%s' % (server1.getDir(),OPENDSNAME),
+                { 'location'     : masterHost,
+                  'dsPath'       : masterPath,
                   'dsBackEnd'    : 'userRoot',          
-                  'dsLdifFile'   : '%s/replication/Example.ldif' % server1DataDir
+                  'dsLdifFile'   : '%s/replication/Example.ldif' % masterDataDir
                 }
               </call>
               
               <!-- Check some data was imported into Directory Server -->
               <call function="'checkImport'">
-                { 'location'        : server1.getHostname(),
-                  'dsPath'          : '%s/%s' % (server1.getDir(),OPENDSNAME),
-                  'dsHost'          : server1.getHostname(),
-                  'dsPort'          : server1.getPort(),
-                  'dsDn'            : server1.getRootDn(),
-                  'dsPswd'          : server1.getRootPwd(),
+                { 'location'        : masterHost,
+                  'dsPath'          : masterPath,
+                  'dsHost'          : masterHost,
+                  'dsPort'          : master.getPort(),
+                  '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']
@@ -91,65 +91,61 @@
               
               <!-- Start the Directory Server -->
               <call function="'StartDsWithScript'">
-                { 'location'  : server1.getHostname(),
-                  'dsPath'    : '%s/%s' % (server1.getDir(),OPENDSNAME)
+                { 'location'  : masterHost,
+                  'dsPath'    : masterPath
                 }
               </call>
               
               <!-- Wait for DS to start -->
               <call function="'isAlive'">
-                { 'location'         : server1.getHostname(),
-                  'dsPath'           : '%s/%s' % (server1.getDir(),OPENDSNAME),
-                  'dsInstanceHost'   : server1.getHostname() ,
-                  'dsInstancePort'   : server1.getPort() ,
-                  'dsInstanceDn'     : server1.getRootDn() ,
-                  'dsInstancePswd'   : server1.getRootPwd() ,
+                { 'location'         : masterHost,
+                  'dsPath'           : masterPath,
+                  'dsInstanceHost'   : masterHost,
+                  'dsInstancePort'   : master.getPort() ,
+                  'dsInstanceDn'     : master.getRootDn() ,
+                  'dsInstancePswd'   : master.getRootPwd() ,
                   'noOfLoops'        : 10 ,
                   'noOfMilliSeconds' : 2000
                 }
               </call>
-              
-              <!-- Perform the total update -->
-              <call function="'TotalUpdateTask'">
-                { 'location'        : server1.getHostname(),
-                  'dsPath'          : '%s/%s' % (server2.getDir(),OPENDSNAME),                
-                  'dsInstanceHost'  : server2.getHostname(),
-                  'dsInstancePort'  : server2.getPort(),
-                  'dsInstanceDn'    : server2.getRootDn(),
-                  'dsInstancePswd'  : server2.getRootPwd(),
-                  'taskID'          : 'task',
-                  'domainDN'        : 'o=example',
-                  'replicaServerID' : '1'
-                }
-              </call>
-              
-              <script>
-                STAXCode, STAXReason=STAXResult
-              </script>
-              
-              <if expr="STAXCode != 0">
-                <sequence>
-                  <message>
-                    'Totalupdate failed (Code=%s,Reason=%s)' % (STAXCode,STAXReason)
-                  </message>
-                  <tcstatus result="'fail'" />
+
+
+              <iterate var="server" in="consumerList">
+                <sequence>                                                                            
+                  <!-- Perform the total update -->
+                  <call function="'initializeReplication'">
+                    { 'location'  :  clientHost,
+                      'dsPath'  :  clientPath,
+                      'dsInstanceHost'  :  server.getHostname(),
+                      'dsInstancePort'  :  server.getPort(),
+                      'sourceInstanceHost'  :  masterHost,
+                      'sourceInstancePort'  :  master.getPort(),
+                      '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(),
+                      '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>
-              </if>
-              
-              <!-- Verify the total update -->
-              <call function="'checkImport'">
-                { 'location'  : server2.getHostname(),
-                  'dsPath'    : '%s/%s' % (server2.getDir(),OPENDSNAME),
-                  'dsHost'    : server2.getHostname(),
-                  'dsPort'    : server2.getPort(),
-                  'dsDn'      : server2.getRootDn(),
-                  'dsPswd'    : server2.getRootPwd(),
-                  'expectedEntries' : ['uid=scarter,ou=People,o=example',
-                                       'uid=dmiller, ou=People, o=example',
-                                       'uid=rhunt, ou=People, o=example'],
-                  'startDS'  : 'no'
-                }
-              </call>
+              </iterate>
+                
+              <!-- 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>

--
Gitblit v1.10.0