From a0f07a7a8e7c9163a7f5d1e976cdca8b6d10310f Mon Sep 17 00:00:00 2001
From: gary_williams <gary_williams@localhost>
Date: Thu, 23 Aug 2007 07:08:53 +0000
Subject: [PATCH] ensure tests can be run remotely

---
 opends/tests/functional-tests/testcases/security/client_auth/client_auth_lib.xml   |    2 
 opends/tests/functional-tests/shared/functions/environment.xml                     |    6 +
 opends/tests/functional-tests/shared/functions/topology.xml                        |   36 +++++++++++-
 opends/tests/functional-tests/testcases/security/client_auth/client_auth_setup.xml |   36 +++++++++--
 opends/tests/functional-tests/shared/functions/ldap.xml                            |   22 +++---
 opends/tests/functional-tests/shared/functions/stafcmd.xml                         |   53 ++++++++++++++++-
 6 files changed, 128 insertions(+), 27 deletions(-)

diff --git a/opends/tests/functional-tests/shared/functions/environment.xml b/opends/tests/functional-tests/shared/functions/environment.xml
index 9ebbe70..5ae83b3 100755
--- a/opends/tests/functional-tests/shared/functions/environment.xml
+++ b/opends/tests/functional-tests/shared/functions/environment.xml
@@ -286,9 +286,11 @@
         logsTestDataDir='%s/testdata' % logsDir
         logsTempDir='%s/temp' % logsDir
 
-        relativeDataDir='shared/data'
+        relativeSharedDir='shared'
+        relativeJavaDir='%s/java' % relativeSharedDir
+        relativeDataDir='%s/data' % relativeSharedDir
         logsLocalDataDir='%s/%s' % (logsTestDataDir,relativeDataDir)
-        logsRemoteDataDir='%s/%s' % (DIRECTORY_INSTANCE_DIR,relativeDataDir)     
+        logsRemoteDataDir='%s/%s' % (DIRECTORY_INSTANCE_DIR,relativeDataDir) 
       </script>
 
       <message>
diff --git a/opends/tests/functional-tests/shared/functions/ldap.xml b/opends/tests/functional-tests/shared/functions/ldap.xml
index a4ba263..a26fef8 100755
--- a/opends/tests/functional-tests/shared/functions/ldap.xml
+++ b/opends/tests/functional-tests/shared/functions/ldap.xml
@@ -146,7 +146,7 @@
       This function performs an ldapmodify using the script
     </function-prolog>  
     <function-map-args>
-      <function-arg-def name="location" type="optional" default="STAXServiceMachine">
+      <function-arg-def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
         <function-arg-description>
           Location of target host
         </function-arg-description>
@@ -623,7 +623,7 @@
       This function performs an ldapsearch using the script
     </function-prolog>  
     <function-map-args>
-      <function-arg-def name="location" type="optional" default="STAXServiceMachine">
+      <function-arg-def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
         <function-arg-description>
           Location of target host
         </function-arg-description>
@@ -1436,7 +1436,7 @@
       This function performs an ldapdelete using the script
     </function-prolog>  
     <function-map-args>
-      <function-arg-def name="location" type="optional" default="STAXServiceMachine">
+      <function-arg-def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
         <function-arg-description>
           Location of target host
         </function-arg-description>
@@ -1876,7 +1876,7 @@
       This function performs an ldapcompare using the script
     </function-prolog>  
     <function-map-args>
-      <function-arg-def name="location" type="optional" default="STAXServiceMachine">
+      <function-arg-def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
         <function-arg-description>
           Location of target host
         </function-arg-description>
@@ -2346,7 +2346,7 @@
       This function performs an ldappasswordmodify using the script
     </function-prolog>  
     <function-map-args>
-      <function-arg-def name="location" type="optional" default="STAXServiceMachine">
+      <function-arg-def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
         <function-arg-description>
           Location of target host
         </function-arg-description>
@@ -2748,8 +2748,8 @@
           'command'   : 'java',
           'arguments' : '%s %s' % (STAFCmd,STAFCmdParams),
           'location'  : location,
-          'path'      : TESTS_JAVA_DIR,
-          'env'       : ['PATH=/bin:/usr/bin:%s/bin' % dsPath, 'JAVA_HOME=%s' % JAVA_HOME,'CLASSPATH=%s' % TESTS_JAVA_DIR]
+          'path'      : '%s/../%s' % (dsPath,relativeJavaDir),
+          'env'       : ['PATH=/bin:/usr/bin:%s/bin' % dsPath, 'JAVA_HOME=%s' % JAVA_HOME,'CLASSPATH=%s/../%s' % (dsPath,relativeJavaDir)]
         }
       </call>
       <script>
@@ -2858,8 +2858,8 @@
           'command'   : 'java',
           'arguments' : '%s %s' % (STAFCmd,STAFCmdParams),
           'location'  : location,
-          'env'       : ['PATH=/bin:/usr/bin:%s/bin' % dsPath, 'JAVA_HOME=%s' % JAVA_HOME,'CLASSPATH=%s' % TESTS_JAVA_DIR],
-          'path'      : TESTS_JAVA_DIR
+          'env'       : ['PATH=/bin:/usr/bin:%s/bin' % dsPath, 'JAVA_HOME=%s' % JAVA_HOME,'CLASSPATH=%s/../%s' % (dsPath,relativeJavaDir)],
+          'path'      : '%s/../%s' % (dsPath,relativeJavaDir)
         }
       </call>
       <script>
@@ -2977,8 +2977,8 @@
           'command'   : 'java',
           'arguments' : '%s %s' % (STAFCmd,STAFCmdParams),
           'location'  : location,
-          'env'       : ['PATH=/bin:/usr/bin:%s/bin' % dsPath, 'JAVA_HOME=%s' % JAVA_HOME,'CLASSPATH=%s' % TESTS_JAVA_DIR],
-          'path'      : TESTS_JAVA_DIR
+          'env'       : ['PATH=/bin:/usr/bin:%s/bin' % dsPath, 'JAVA_HOME=%s' % JAVA_HOME,'CLASSPATH=%s/../%s' % (dsPath,relativeJavaDir)],
+          'path'      : '%s/../%s' % (dsPath,relativeJavaDir)
         }
       </call>
       <script>
diff --git a/opends/tests/functional-tests/shared/functions/stafcmd.xml b/opends/tests/functional-tests/shared/functions/stafcmd.xml
index ba4c3a8..7d9e0ec 100755
--- a/opends/tests/functional-tests/shared/functions/stafcmd.xml
+++ b/opends/tests/functional-tests/shared/functions/stafcmd.xml
@@ -671,7 +671,54 @@
       </call>
 
       <return>cmdRC</return>
-      </sequence>
-    </function>  
-  
+    </sequence>
+
+  </function>	
+
+  <function name="getFile">
+    <function-prolog>
+      This function get the contents of a file
+    </function-prolog>
+    <function-map-args>
+      <function-arg-def name="location" type="optional" default="STAXServiceMachine">
+        <function-arg-description>
+          Location of target host
+        </function-arg-description>
+        <function-arg-property name="type" value="hostname"/>
+      </function-arg-def>
+      <function-arg-def name="filename" type="required">
+        <function-arg-description>
+          The name of the file
+        </function-arg-description>
+        <function-arg-property name="type" value="filename"/>
+      </function-arg-def>
+      <function-arg-def name="type" type="optional" default="'text'">
+        <function-arg-description>
+          The type of the file
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>
+      <function-arg-def name="format" type="optional" default="'native'">
+        <function-arg-description>
+          The format of the file
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>      
+    </function-map-args>
+    <sequence>
+      <stafcmd name="'STAF Command: Get File'">
+        <location>'%s' % location</location>
+        <service>'fs'</service>
+        <request>
+          'GET FILE %s %s FORMAT %s' % (filename,type,format)
+        </request>
+      </stafcmd>
+      <script>
+        cmdRC=RC
+        cmdResult=STAFResult
+      </script>
+      <return>[cmdRC,cmdResult]</return>
+    </sequence>
+  </function>
+  	
 </stax>
diff --git a/opends/tests/functional-tests/shared/functions/topology.xml b/opends/tests/functional-tests/shared/functions/topology.xml
index 580f9ed..4590637 100755
--- a/opends/tests/functional-tests/shared/functions/topology.xml
+++ b/opends/tests/functional-tests/shared/functions/topology.xml
@@ -161,6 +161,7 @@
       <!-- If the test data is already created then don't redo it -->
       <if expr="RC == 48">
         <sequence>
+
           <!-- Locally copy static data files to temporary staging area -->
           <!-- LDIF (.ldif) test data files -->
           <message>
@@ -173,6 +174,7 @@
               'extension'  : 'ldif'
             }
           </call>
+
           <!-- LDIF (.ldif) files for quickinstall -->
           <script>
             quickStartGroupDir='%s/%s/quickstart' % (TESTS_DIR,relativeDataDir)
@@ -212,7 +214,23 @@
               'extension'  : 'gz' 
             }
           </call>
-          
+
+          <!-- Archive java (.class) files -->
+          <script>
+            javaSharedDir='%s' % (TESTS_JAVA_DIR)
+            javaLocalDir='%s/shared/java' % (logsTestDataDir)
+          </script>
+          <message>
+            'Copy java class files locally to %s.' % javaLocalDir
+          </message>
+          <call function="'CopyFolderByExtension'">
+            { 'location'   : STAXServiceMachine,
+              'srcfolder'  : javaSharedDir,
+              'destfolder' : javaLocalDir,
+              'extension'  : 'class' 
+            }
+          </call>
+                    
           <!--  Delete the any existing testdata archive -->
           <message>
             'Delete %s/testdata.zip' % logsTempDir
@@ -225,7 +243,7 @@
           
           <!--  Zip up contents of tests directory -->
           <message>
-            'Zip up local data directory %s/testdata.zip' % logsTempDir
+            'Zip up local data directory to %s/testdata.zip' % logsTempDir
           </message>
           <call function="'zipUpFile'">
             { 'location'   : STAXServiceMachine,
@@ -236,7 +254,7 @@
           </call>
           
           <message>
-            'Zip up local quickstart directory %s/testdata.zip' % logsTempDir
+            'Zip up local quickstart directory to %s/testdata.zip' % logsTempDir
           </message>
           <call function="'zipUpFile'">
             { 'location'   : STAXServiceMachine,
@@ -245,6 +263,18 @@
               'relativeto' : logsTestDataDir 
             }
           </call>
+                      
+          <message>
+            'Zip up local java class files to %s/testdata.zip' % logsTempDir
+          </message>
+          <call function="'zipUpFile'">
+            { 'location'   : STAXServiceMachine,
+              'zipfile'    : '%s/testdata.zip' % logsTempDir , 
+              'folder'     : '%s' % javaLocalDir ,
+              'relativeto' : logsTestDataDir 
+            }                        
+          </call>
+          
         </sequence>
         <else>
           <message>
diff --git a/opends/tests/functional-tests/testcases/security/client_auth/client_auth_lib.xml b/opends/tests/functional-tests/testcases/security/client_auth/client_auth_lib.xml
index 3f9bcf2..e83e50d 100755
--- a/opends/tests/functional-tests/testcases/security/client_auth/client_auth_lib.xml
+++ b/opends/tests/functional-tests/testcases/security/client_auth/client_auth_lib.xml
@@ -42,7 +42,7 @@
     <script>
           SERVER_KEYPASS="servercert"
           SERVER_STOREPASS="servercert"
-          CERT_TMP="%s/../%s/CERT_%s" % (dsPath,relativeDataDir,DIRECTORY_INSTANCE_PORT)
+          CERT_TMP="%s/CERT_%s" % (logsRemoteDataDir,DIRECTORY_INSTANCE_PORT)
           CLIENT_KEYSTORE="%s/keystore" % (CERT_TMP)
           CLIENT_KEYPASS="password"
           CLIENT_STOREPASS="password"    
diff --git a/opends/tests/functional-tests/testcases/security/client_auth/client_auth_setup.xml b/opends/tests/functional-tests/testcases/security/client_auth/client_auth_setup.xml
index a9dcea1..37b5539 100755
--- a/opends/tests/functional-tests/testcases/security/client_auth/client_auth_setup.xml
+++ b/opends/tests/functional-tests/testcases/security/client_auth/client_auth_setup.xml
@@ -370,16 +370,28 @@
               'expectedRC'     :  0
             }
           </call>
-          
+
+          <call function="'getFile'">
+            { 'location'    : STAF_REMOTE_HOSTNAME,
+              'filename'    : USER_1_CERT_FILE_RFC
+            }
+          </call>
+
+          <message>
+            'Certificate contents:\n %s' % cmdResult
+          </message>
+                              
           <!-- Extract BEGIN CERTIFICATE and END CERTIFICATE -->
           <script>
-            cert_file = open(USER_1_CERT_FILE_RFC,"r")
+            certList=STAXResult[1].split('\n')
             ret_str = ""
-            for line in cert_file.readlines():
+            for line in certList:
               index_cert = line.find("CERTIFICATE")
               if index_cert == -1:
                 ret_str+=line.strip()
-              
+          </script>
+                          
+          <script>                        
             listAttr = []
             listAttr.append('dn: %s' % USER_1_DN)
             listAttr.append('changetype: modify')
@@ -444,12 +456,22 @@
               'expectedRC'     :  0
             }
           </call>
-          
+
+          <call function="'getFile'">
+            { 'location'    : STAF_REMOTE_HOSTNAME,
+              'filename'    : USER_2_CERT_FILE_RFC
+            }
+          </call>
+
+          <message>
+            'Certificate contents:\n %s' % cmdResult
+          </message>
+                              
           <!-- Extract BEGIN CERTIFICATE and END CERTIFICATE -->
           <script>
-            cert_file = open(USER_2_CERT_FILE_RFC,"r")
+            certList=STAXResult[1].split('\n')
             ret_str = ""
-            for line in cert_file.readlines():
+            for line in certList:
               index_cert = line.find("CERTIFICATE")
               if index_cert == -1:
                 ret_str+=line.strip()

--
Gitblit v1.10.0