From 4a15de03a0b770fedf3113d94d70aa8486d08eec Mon Sep 17 00:00:00 2001
From: andrug <andrug@localhost>
Date: Fri, 28 Mar 2008 09:39:33 +0000
Subject: [PATCH] allow a scenario to have its own clients

---
 opendj-sdk/opends/tests/system-tests/phases/scheduler/scheduler.xml |   50 ++++++++++++++++++++-----
 opendj-sdk/opends/tests/system-tests/phases/main_run_lib.xml        |   24 ++++++++++++
 2 files changed, 64 insertions(+), 10 deletions(-)

diff --git a/opendj-sdk/opends/tests/system-tests/phases/main_run_lib.xml b/opendj-sdk/opends/tests/system-tests/phases/main_run_lib.xml
index f9c1f06..6e72d90 100644
--- a/opendj-sdk/opends/tests/system-tests/phases/main_run_lib.xml
+++ b/opendj-sdk/opends/tests/system-tests/phases/main_run_lib.xml
@@ -220,6 +220,7 @@
               <script>
                 fullHostName = '%s%s' % (client.getHost(),DOMAIN[0])
               </script>
+              <!-- Copy shared clients -->
               <call function="'copyFolder'">
               {
                 'remoteHost'    : fullHostName,
@@ -228,6 +229,29 @@
                 'fileFd'        : NO_FILE
               }
               </call>
+              <!-- Copy clients that are under the scenario directory -->
+              <call function="'isFile'">
+              {
+                'location' : STAXServiceMachine,
+                'fileName' : '%s/scenario/%s/clients' % (TESTS_DIR,DIR_NAME),
+              }
+              </call>
+              <script>
+                fileExist = STAXResult
+              </script>
+              <if expr="fileExist == TRUE">
+                <call function="'copyFolder'">
+                {
+                  'remoteHost'    : fullHostName,
+                  'fromDirectory' : '%s/scenario/%s/clients' % \
+                                    (TESTS_DIR,DIR_NAME),
+                  'toDirectory'   : '%s/scenario/%s/clients' % \
+                                    (LOCAL_TESTS_DIR,DIR_NAME),
+                  'fileFd'        : NO_FILE
+                }
+                </call>
+              </if>
+              
             </sequence>
           </if>
         </sequence>
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 a4a34cc..a126449 100755
--- a/opendj-sdk/opends/tests/system-tests/phases/scheduler/scheduler.xml
+++ b/opendj-sdk/opends/tests/system-tests/phases/scheduler/scheduler.xml
@@ -330,27 +330,59 @@
       <!--=== run the client, exit if time exceed duration time ===-->
       <script>
         timerKilled = TRUE
-        clientXmlFile = '%s/clients/%s/%s.xml' % \
-                        (LOCAL_TESTS_DIR,client.getName(),client.getName())
+        workingDir  = NOT_DEFINED
+        localWorkingDir = '%s/scenario/%s/clients/%s' % \
+                           (LOCAL_TESTS_DIR,DIR_NAME,client.getName())
+        sharedWorkingdir = '%s/clients/%s/' % \
+                           (LOCAL_TESTS_DIR,client.getName())
       </script>
       <timer duration="'%ss' % duration">
         <sequence>
-          <!-- check if client exists before launching it-->
+          <!-- check if local client exists before launching it-->
           <call function="'isFile'">
           {
             'location' : STAXServiceMachine,
-            'fileName' : clientXmlFile
+            'fileName' : '%s/%s.xml' % (localWorkingDir,client.getName())
           }
           </call>
           <script>
-            fileExist = STAXResult
+            localClientExist = STAXResult
           </script>
-          <if expr="fileExist == TRUE">
+          <!-- check if remote client exists before launching it-->
+          <call function="'isFile'">
+          {
+            'location' : STAXServiceMachine,
+            'fileName' : '%s/%s.xml' % (sharedWorkingdir,client.getName())
+          }
+          </call>
+          <script>
+            sharedClientExist = STAXResult
+          </script>
+          
+          <!-- use local client by default else the shared client -->
+          <if expr="localClientExist == TRUE">
+            <script> workingDir = localWorkingDir </script>
+          <elseif expr="sharedClientExist == TRUE">
+            <script> workingDir = sharedWorkingdir </script>
+          </elseif>
+          <else>
+            <sequence>
+              <message>
+                'ERROR : cant find files %s and %s' % \
+                (localClientXmlFile,clientXmlFile)
+              </message>
+              <script>ERR_NUM[0] += 1</script>
+            </sequence>
+          </else>
+          </if>
+          
+          <if expr="workingDir != NOT_DEFINED">
             <sequence>
               <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
-                      file="'%s' % clientXmlFile"/>
+                      file="'%s/%s.xml' % (workingDir,client.getName())"/>
               <call function="'%s' % client.getName()">
               { 
+                'workingDir' : workingDir,
                 'client'     : client,
                 'instances'  : instances,
                 'duration'   : duration,
@@ -362,10 +394,8 @@
                 timerKilled = FALSE
               </script>
             </sequence>
-          <else>
-            <message>'ERROR : cant find file %s' % clientXmlFile </message>
-          </else>
           </if>
+          
         </sequence>
       
       </timer>

--
Gitblit v1.10.0