From 5660b3e2d64409279a411f5afb5eb933f7166a4d Mon Sep 17 00:00:00 2001
From: madiot <madiot@localhost>
Date: Sun, 23 Mar 2008 14:04:31 +0000
Subject: [PATCH] making dsml functional test suuite's components remotable

---
 opendj-sdk/opends/tests/functional-tests/staf-installer.xml            |    2 
 opendj-sdk/opends/tests/functional-tests/testcases/dsml/dsml_setup.xml |   44 +++++++++-----
 opendj-sdk/opends/tests/shared/functions/webcontainer.xml              |  132 ++++++++++++++++++++++++++++++-------------
 3 files changed, 119 insertions(+), 59 deletions(-)

diff --git a/opendj-sdk/opends/tests/functional-tests/staf-installer.xml b/opendj-sdk/opends/tests/functional-tests/staf-installer.xml
index b3aab67..d3840d8 100644
--- a/opendj-sdk/opends/tests/functional-tests/staf-installer.xml
+++ b/opendj-sdk/opends/tests/functional-tests/staf-installer.xml
@@ -1052,7 +1052,7 @@
         <available file="${bits.download.dir}/${bits.stax.archive}" />
       </condition>
       <condition property="bits.tomcat.downloaded.before">
-        <available file="${bits.download.dir}/${bits.tomcat.archive}"/>
+        <available file="${bits.webcontainer.download.dir}/${bits.tomcat.archive}"/>
       </condition>
       <condition property="bits.all.downloaded.before">
         <and>
diff --git a/opendj-sdk/opends/tests/functional-tests/testcases/dsml/dsml_setup.xml b/opendj-sdk/opends/tests/functional-tests/testcases/dsml/dsml_setup.xml
index 731ea6b..70dd3c5 100755
--- a/opendj-sdk/opends/tests/functional-tests/testcases/dsml/dsml_setup.xml
+++ b/opendj-sdk/opends/tests/functional-tests/testcases/dsml/dsml_setup.xml
@@ -46,12 +46,12 @@
         <sequence>
           <!--- Test Case information
               #@TestMarker          setup
-              #@TestName            setup: create DSML directory server
+              #@TestName            setup: prepare DSML directory server
               #@TestIssue           none
-              #@TestPurpose         Create the directory server necessary to the
+              #@TestPurpose         Prepare the directory server necessary to the
                                     test suite.
               #@TestPreamble        none
-              #@TestStep            Create Directory server as defined in config.py.
+              #@TestStep            prepare dsml directory server instance
               #@TestPostamble       none
               #@TestResult          Success if  returns 0.
           -->
@@ -106,7 +106,7 @@
                 'Start DS instance'
               </message>
               <call function="'StartDsWithScript'">
-               { 'location'  : STAF_REMOTE_HOSTNAME }
+               { 'location'  : DIRECTORY_INSTANCE_HOST }
               </call>
               <call function="'checktestRC'">
                 {
@@ -170,7 +170,7 @@
                                      dsmlBaseDNs.get(baseDN)[1])
                   </script>
                   <stafcmd name="'create import temp directory'">
-                    <location>'%s' % location</location>
+                    <location>'%s' % DIRECTORY_INSTANCE_HOST</location>
                     <service>'fs'</service>
                     <request>' CREATE DIRECTORY %s' % (importTempDir)</request>
                   </stafcmd>
@@ -179,7 +179,7 @@
                       'result'     : STAXResult }
                   </call>
                   <stafcmd name="'create database directory'">
-                    <location>'%s' % location</location>
+                    <location>'%s' % DIRECTORY_INSTANCE_HOST</location>
                     <service>'fs'</service>
                     <request>' CREATE DIRECTORY %s' % (ldapDB)</request>
                   </stafcmd>
@@ -276,9 +276,7 @@
                 'setup: deploy DSML gateway webapp as described in config.py'
               </message>
               <call function="'deployWebApplicationWAR'">
-                { 'location'   : STAF_REMOTE_HOSTNAME ,
-                'warFilePath' : '%s' % DSML_WARPATH,
-                'destWarFileName' : 'dsml.war'}
+                { 'warFilePath' : '%s' % DSML_WARPATH }
               </call>
               <call function="'checktestRC'">
                 {
@@ -307,10 +305,7 @@
               <message>
                 'setup: start webcontainer as described in config.py'
               </message>
-              <call function="'startWebcontainerWithScript'">
-                { 'location'   : STAF_REMOTE_HOSTNAME ,
-                'wcPath' : '%s/%s-%s' % (WC_DIRECTORY,WC_TYPE,WC_VERSION) }
-              </call>
+              <call function="'startWebcontainerWithScript'"/>
               <call function="'checktestRC'">
                 {
                 'returncode' : RC ,
@@ -326,11 +321,24 @@
             </sequence>
           </testcase>
 
+          <!--- Test Case information
+              #@TestMarker          setup
+              #@TestName            setup: configure DSML gateway DS port param
+              #@TestIssue           none
+              #@TestPurpose         Set the gateway web.xml param pointing to DS
+              #@TestPreamble        none
+              #@TestSteps           extract web.xml out of DSML war file locally
+              #@TestSteps           substitute default port 389 with DIRECTORY_INSTANCE_PORT
+              #@TestSteps           substitute default directory host localhost with DIRECTORY_INSTANCE_HOST
+              #@TestSteps           overwrite the destination DSML gateway web.xml
+              #@TestPostamble       none
+              #@TestResult          Success if statWebcontainerWithScript returns 0.
+          -->
           <testcase name="getTestCaseName('configure: dsml web.xml port')">
             <sequence>
               <call function="'testCase_Preamble'"/>
               <stafcmd name="'extract DSML gateway web.xml'">
-                <location>'local'</location>
+                <location>STAXServiceMachine</location>
                 <service>'zip'</service>
                 <request>'UNZIP ZIPFILE %s TODIRECTORY %s FILE WEB-INF/web.xml' % (DSML_WARPATH, TMPDIR)</request>
               </stafcmd>
@@ -338,15 +346,17 @@
                 webXmlInput=open('%s/WEB-INF/web.xml' % TMPDIR,'r')
                 import re
                 portRegEx = re.compile('389')
-                c=webXmlInput.read()
-                content=portRegEx.sub(DIRECTORY_INSTANCE_PORT, c)
+                hostRegEx = re.compile('localhost')
+                c0=webXmlInput.read()
+                c1=portRegEx.sub(DIRECTORY_INSTANCE_PORT, c0)
+                content=hostRegEx.sub(DIRECTORY_INSTANCE_HOST, c1)
                 webXmlInput.close()
                 webXmlOutput=open('%s/WEB-INF/web.xml.out' % TMPDIR,'w')
                 webXmlOutput.write(content)
                 webXmlOutput.close()
               </script>
               <call function="'copyFile'">
-                { 'location' : 'local',
+                { 'location' : STAXServiceMachine,
                   'remotehost' : '%s' % location,
                   'srcfile' : '%s/WEB-INF/web.xml.out' % TMPDIR,
                   'destfile' : '%s/%s-%s/webapps/dsml/WEB-INF/web.xml' % (TMPDIR,WC_TYPE,WC_VERSION)
diff --git a/opendj-sdk/opends/tests/shared/functions/webcontainer.xml b/opendj-sdk/opends/tests/shared/functions/webcontainer.xml
index b8ab390..7034beb 100755
--- a/opendj-sdk/opends/tests/shared/functions/webcontainer.xml
+++ b/opendj-sdk/opends/tests/shared/functions/webcontainer.xml
@@ -27,30 +27,45 @@
 ! -->
 <stax>
   
-  <function name="createWebcontainer">
+  <function name="createWebcontainer" scope="local">
     <function-prolog>
       This function creates a default webcontainer instance  
     </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="wcPath" type="optional" default="'%s' % WC_DIRECTORY">
+        <function-arg-description>
+          Pathname to installation root
+        </function-arg-description>
+        <function-arg-property name="type" value="filepath"/>
+      </function-arg-def>
+    </function-map-args>
+
     <try>
       
       <sequence>
         
         <!-- Unzip webcontainer into temporary folder -->
         <message>
-          'Extract temporary webcontainer zip archive to %s %s.' % (STAF_REMOTE_HOSTNAME,WC_DIRECTORY)
+          'Extract temporary webcontainer zip archive to %s %s.' % (location, wcPath)
         </message>
         <call function="'unZipFile'">
-          { 'location' : STAF_REMOTE_HOSTNAME, 
+          { 'location' : location, 
           'zipfile'  : '%s/%s' % (WC_ZIPPATH,WC_ZIPNAME), 
-          'unzipdir' : '%s' % WC_DIRECTORY }
+          'unzipdir' : '%s' % wcPath }
         </call>
         <!-- chmod +x all the .sh file in tomcat bin directory -->
         <stafcmd name="'create import temp directory'">
           <location>'%s' % location</location>
           <service>'fs'</service>
           <request>' LIST DIRECTORY %s/%s-%s/bin EXT sh' % \
-                   (WC_DIRECTORY, WC_TYPE, WC_VERSION)</request>
+                   (wcPath, WC_TYPE, WC_VERSION)</request>
         </stafcmd>
         <script>
           shFilesRC=RC
@@ -61,7 +76,7 @@
           <location>'%s' % location</location>
           <command mode="'shell'">'chmod +x %s' % shFilesResult</command>
           <parms/>
-          <workdir>'%s/%s-%s/bin' % (WC_DIRECTORY, WC_TYPE, WC_VERSION)</workdir>
+          <workdir>'%s/%s-%s/bin' % (wcPath, WC_TYPE, WC_VERSION)</workdir>
           <envs>['PATH=/bin:/usr/bin']</envs>
           <stderr mode="'stdout'"/>
           <stdout/>
@@ -72,20 +87,31 @@
         <message>
           'Configure webcontainer ports HTTP %s / HTTPS %s' % (WC_PORT, WC_SSL_PORT)
         </message>
+        <stafcmd name="'get tomcat configuration file'">
+          <location>'%s' % location</location>
+          <service>'fs'</service>
+          <request>' GET FILE %s/%s-%s/conf/server.xml ' % \
+                   (wcPath, WC_TYPE, WC_VERSION)</request>
+        </stafcmd>
         <script>
-          serverXmlInput=open('%s/%s-%s/conf/server.xml' % (WC_DIRECTORY,WC_TYPE,WC_VERSION),'r')
+          serverXmlInput=STAFResult
           import re
           portRegEx = re.compile('8080')
           sslPortRegEx = re.compile('8443')
-          c=serverXmlInput.read()
-          ci=portRegEx.sub(WC_PORT, c)
-          content=portRegEx.sub(WC_SSL_PORT, ci)
-          serverXmlInput.close()
-          serverXmlOutput=open('%s/%s-%s/conf/server.xml' % (WC_DIRECTORY,WC_TYPE,WC_VERSION),'w')
+          content=portRegEx.sub(WC_PORT, serverXmlInput)
+          content=sslPortRegEx.sub(WC_SSL_PORT, content)
+          serverXmlOutput=open('%s/%s-%s-%s_server.xml' % \
+                          (TMPDIR,STAF_REMOTE_HOSTNAME,WC_TYPE,WC_VERSION),'w')
           serverXmlOutput.write(content)
           serverXmlOutput.close()
         </script>
-        
+        <call function="'copyFile'">
+          {'srcfile' : '%s/%s-%s-%s_server.xml' % (TMPDIR, STAF_REMOTE_HOSTNAME, WC_TYPE, WC_VERSION),
+           'destfile' : '%s/%s-%s/conf/server.xml' % (wcPath, WC_TYPE, WC_VERSION),
+           'remotehost' : '%s' % STAF_REMOTE_HOSTNAME
+          }
+        </call>
+
         <!-- configure webcontainer's SSL environement -->
         <message>
           'Configure webcontainer SSL keystore '
@@ -104,11 +130,11 @@
         <sequence>
           <message>'caught %s with %s' % (eType,eInfo)</message>
           <message>
-            'Remove temporary webcontainer zip archive from %s %s' % (STAF_REMOTE_HOSTNAME,WC_DIRECTORY)
+            'Remove temporary webcontainer zip archive from %s %s' % (location,wcPath)
           </message>
           <call function="'deleteFolder'">
-            { 'location'   : STAF_REMOTE_HOSTNAME ,
-            'foldername' : '%s' % WC_DIRECTORY }
+            { 'location'   : location ,
+            'foldername' : '%s' % wcPath }
           </call>
         </sequence>
       </catch>
@@ -117,25 +143,31 @@
     
   </function>
   
-  <function name="deployWebApplicationWAR">
+  <function name="deployWebApplicationWAR" scope="local">
     <function-prolog>
       This function deploys a Web Application War file
     </function-prolog>
     
     <function-map-args>
-      <function-arg-def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
+      <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="warFilePath" type="required" default="''">
+      <function-arg-def  name="wcPath" type="optional" default="'%s' % WC_DIRECTORY">
+        <function-arg-description>
+          Pathname to installation root
+        </function-arg-description>
+        <function-arg-property name="type" value="filepath"/>
+      </function-arg-def>
+      <function-arg-def  name="warFilePath" type="required" default="''">
         <function-arg-description>
           Web application war file path
         </function-arg-description>
         <function-arg-property name="type" value="filepath"/>
       </function-arg-def>
-      <function-arg-def name="destWarFileName" type="optional" default="'dsml.war'">
+      <function-arg-def  name="destWarFileName" type="optional" default="'dsml.war'">
         <function-arg-description>
           Web application war destination file path
         </function-arg-description>
@@ -145,31 +177,32 @@
     <sequence>
       
       <message>
-        'setup: deploy web application %s to %s/%s-%s/webapps/%s' % (warFilePath, WC_DIRECTORY, WC_TYPE, WC_VERSION, destWarFileName) 
+        'setup: deploy web application %s to %s/%s-%s/webapps/%s' % (warFilePath, wcPath, WC_TYPE, WC_VERSION, destWarFileName) 
       </message>
 
       <call function="'copyFile'">
-        { 'location'   : STAF_REMOTE_HOSTNAME ,
+        { 'location'   : STAXServiceMachine,
         'srcfile' : '%s' % warFilePath,
-        'destfile' : '%s/%s-%s/webapps/%s' % (WC_DIRECTORY, WC_TYPE, WC_VERSION, destWarFileName) }
+        'destfile' : '%s/%s-%s/webapps/%s' % (wcPath, WC_TYPE, WC_VERSION, destWarFileName),
+        'remotehost' : location}
       </call>
       
     </sequence>
     
   </function>
   
-  <function name="stopWebcontainerWithScript">
+  <function name="stopWebcontainerWithScript" scope="local">
     <function-prolog>
       This function stops a webcontainer 
     </function-prolog>
     <function-map-args>
-      <function-arg-def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
+      <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="wcPath" type="optional" default="'%s' % WC_DIRECTORY">
+      <function-arg-def  name="wcPath" type="optional" default="'%s' % WC_DIRECTORY">
         <function-arg-description>
           Pathname to installation root
         </function-arg-description>
@@ -184,7 +217,8 @@
         if wcPath:
           wcBinPath='%s/bin' % wcPath
           STAFCmd='%s/shutdown.sh' % wcBinPath
-          STAFCmdEnv=['CATALINA_HOME=%s' % wcPath,'PATH=/bin:/usr/bin']
+          STAFCmdEnv=['CATALINA_HOME=%s' % wcPath,'PATH=/bin:/usr/bin'\
+                      'JAVA_HOME=%s' % JAVA_HOME]
       </script>
       
       <message>
@@ -213,18 +247,18 @@
     
   </function>
   
-  <function name="startWebcontainerWithScript">
+  <function name="startWebcontainerWithScript" scope="local">
     <function-prolog>
-      This function starts a webcontainer 
+      This function start a webcontainer 
     </function-prolog>
     <function-map-args>
-      <function-arg-def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
+      <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="wcPath" type="optional" default="'%s' % WC_DIRECTORY">
+      <function-arg-def  name="wcPath" type="optional" default="'%s/%s-%s' % (WC_DIRECTORY, WC_TYPE, WC_VERSION)">
         <function-arg-description>
           Pathname to installation root
         </function-arg-description>
@@ -239,7 +273,8 @@
         if wcPath:
           wcBinPath='%s/bin' % wcPath
           STAFCmd='%s/startup.sh' % wcBinPath
-          STAFCmdEnv=['CATALINA_HOME=%s' % wcPath,'PATH=/bin:/usr/bin']
+          STAFCmdEnv=['CATALINA_HOME=%s' % wcPath,'PATH=/bin:/usr/bin' \
+                      'JAVA_HOME=%s' % JAVA_HOME]
       </script>
       
       <message>
@@ -269,22 +304,37 @@
     
   </function>
   
-  <function name="removeWebcontainer">
+  <function name="removeWebcontainer" scope="local">
     <function-prolog>
       This function removes the webcontainer instance  
     </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="wcPath" type="optional" default="'%s' % WC_DIRECTORY">
+        <function-arg-description>
+          Pathname to installation root
+        </function-arg-description>
+        <function-arg-property name="type" value="filepath"/>
+      </function-arg-def>
+    </function-map-args>
+
     <try>
       
       <sequence>
         
         <!-- Remove webcontainer directory -->
         <message>
-          'Remove webcontainer from %s %s.' % (STAF_REMOTE_HOSTNAME,WC_DIRECTORY)
+          'Remove webcontainer from %s %s.' % (location,wcPath)
         </message>
         <call function="'deleteFolder'">
-          { 'location' : STAF_REMOTE_HOSTNAME, 
-          'foldername'  : '%s/%s-%s' % (WC_DIRECTORY, WC_TYPE, WC_VERSION) }
+          { 'location' : location, 
+          'foldername'  : '%s/%s-%s' % (wcPath, WC_TYPE, WC_VERSION) }
         </call>
         
         <if expr="RC != 0">
@@ -297,11 +347,11 @@
         <sequence>
           <message>'caught %s with %s' % (eType,eInfo)</message>
           <message>
-            'Remove temporary webcontainer zip archive from %s %s' % (STAF_REMOTE_HOSTNAME,WC_DIRECTORY)
+            'Remove temporary webcontainer zip archive from %s %s' % (location,wcPath)
           </message>
           <call function="'deleteFolder'">
-            { 'location'   : STAF_REMOTE_HOSTNAME ,
-            'foldername' : '%s/%s-%s' % (WC_DIRECTORY, WC_TYPE, WC_VERSION) }
+            { 'location'   : location ,
+            'foldername' : '%s/%s-%s' % (wcPath, WC_TYPE, WC_VERSION) }
           </call>
         </sequence>
       </catch>

--
Gitblit v1.10.0