From 26a43f09a64bd00265348996cac1443b36d4d645 Mon Sep 17 00:00:00 2001
From: andrug <andrug@localhost>
Date: Tue, 20 May 2008 12:00:59 +0000
Subject: [PATCH] ping staf on hosts to avoid staf exception

---
 opendj-sdk/opends/tests/system-tests/phases/parser/parser.xml            |    8 ++++
 opendj-sdk/opends/tests/system-tests/phases/scheduler/scheduler.xml      |   42 ++++++++++++++-------
 opendj-sdk/opends/tests/system-tests/phases/shared/functions/stafcmd.xml |   63 +++++++++++++++++++++++++++++++
 3 files changed, 99 insertions(+), 14 deletions(-)

diff --git a/opendj-sdk/opends/tests/system-tests/phases/parser/parser.xml b/opendj-sdk/opends/tests/system-tests/phases/parser/parser.xml
index e31c17d..c1f1953 100755
--- a/opendj-sdk/opends/tests/system-tests/phases/parser/parser.xml
+++ b/opendj-sdk/opends/tests/system-tests/phases/parser/parser.xml
@@ -71,6 +71,10 @@
       <!--========  Set some attributes to add in instance objects   ======-->
       <paralleliterate in="instances" var="instance">
         <sequence>
+          <call function="'pingStaf'">
+            { 'targetHost' : instance.getHost(),
+              'fileFd'     : NO_FILE}
+          </call>
           <call function="'getOSvariables'">
             { 'hostname' : instance.getHost() }
           </call>
@@ -145,6 +149,10 @@
       <if expr="len(clients) > 0">
         <paralleliterate in="clients" var="client">
           <sequence>
+            <call function="'pingStaf'">
+              { 'targetHost' : client.getHost(),
+                'fileFd'     : NO_FILE}
+            </call>
             <script>
               client.setLogDir('%s/client_%s_id%s' % \
               (LOG_DIR,client.getName(),client.getId()))
diff --git a/opendj-sdk/opends/tests/system-tests/phases/scheduler/scheduler.xml b/opendj-sdk/opends/tests/system-tests/phases/scheduler/scheduler.xml
index 66b3aff..947c6a2 100755
--- a/opendj-sdk/opends/tests/system-tests/phases/scheduler/scheduler.xml
+++ b/opendj-sdk/opends/tests/system-tests/phases/scheduler/scheduler.xml
@@ -530,23 +530,37 @@
           
           <if expr="workingDir != NOT_DEFINED">
             <sequence>
-              <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
-                      file="'%s/%s.xml' % (workingDir,client.getName())"/>
-              <call function="'%s' % client.getName()">
-              { 
-                'workingDir' : workingDir,
-                'client'     : client,
-                'instances'  : instances,
-                'duration'   : duration,
-                'suffix'     : suffix,
-                'outFile'    : outFile,
-                'fileFd'     : fileFd
-              }
+              <!-- Check that staf is running on the client -->
+              <call function="'pingStaf'">
+                { 'targetHost' : client.getHost(),
+                  'fileFd'     : fileFd}
               </call>
               <script>
-                errNum = STAXResult
-                timerKilled = FALSE
+                pingRC = STAXResult[0]
               </script>
+              <if expr="pingRC == 0">
+                <sequence>
+                  <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
+                          file="'%s/%s.xml' % (workingDir,client.getName())"/>
+                  <call function="'%s' % client.getName()">
+                  { 
+                    'workingDir' : workingDir,
+                    'client'     : client,
+                    'instances'  : instances,
+                    'duration'   : duration,
+                    'suffix'     : suffix,
+                    'outFile'    : outFile,
+                    'fileFd'     : fileFd
+                  }
+                  </call>
+                  <script>errNum = STAXResult</script>
+                </sequence>
+              <else>
+                <!-- staf does not answer ping on client host -->
+                <script> errNum = 1 </script>
+              </else>
+              </if>
+              <script>timerKilled = FALSE</script>
             </sequence>
           </if>
           
diff --git a/opendj-sdk/opends/tests/system-tests/phases/shared/functions/stafcmd.xml b/opendj-sdk/opends/tests/system-tests/phases/shared/functions/stafcmd.xml
index c79aafd..4ff13d2 100755
--- a/opendj-sdk/opends/tests/system-tests/phases/shared/functions/stafcmd.xml
+++ b/opendj-sdk/opends/tests/system-tests/phases/shared/functions/stafcmd.xml
@@ -26,6 +26,69 @@
  !      Copyright 2008 Sun Microsystems, Inc.
  ! -->
 <stax>
+  <function name="pingStaf" scope="local">
+    <function-prolog>
+      This function ping staf daemon on remoteHost
+    </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="targetHost" type="required">
+        <function-arg-description>
+          The name of the host to be ping
+        </function-arg-description>
+        <function-arg-property name="type" value="hostname"/>
+      </function-arg-def>
+      <function-arg-def name="fileFd" type="required">
+        <function-arg-description>
+          file descriptor to write message in
+        </function-arg-description>
+      </function-arg-def>
+    </function-map-args>
+    <sequence>
+    
+      <call function="'writeStartTagOperation'">
+      { 'tagName' : 'pingStaf',
+        'fileFd'  : fileFd }
+      </call>
+      
+      <call function="'writeMessage'">
+       { 'content'  : 'Ping staf on machine %s' % targetHost,
+         'fileFd'   : fileFd }
+      </call>
+      <stafcmd name="'STAF Command: Copy File'">
+        <location>'%s' % location</location>
+        <service>'ping'</service>
+        <request>'PING MACHINE %s' % targetHost </request>
+      </stafcmd>
+      <script>
+        cmdRC=RC
+        cmdResult=STAFResult
+      </script>
+      <call function="'checkRC'">
+        { 'returncode' : cmdRC,
+          'result'     : cmdResult,
+          'fileFd'     : fileFd }
+      </call>
+      <if expr="cmdRC != 0">
+        <script>errMsg = 'Can not ping staf on %s' % targetHost </script>
+      <else>
+        <script>errMsg = 'Can ping staf on %s' % targetHost </script>
+      </else>
+      </if>
+      <call function="'writeEndTagOperation'">{'fileFd' : fileFd}</call>
+      <return>
+        [ cmdRC , errMsg ]
+      </return>
+    </sequence>
+  </function>
+  
+  
   <function name="copyFile" scope="local">
     <function-prolog>
       This function copies a source file to destination file to host

--
Gitblit v1.10.0