From 691c2514e77d96372d3dd451b0824d545d11457c Mon Sep 17 00:00:00 2001
From: andrug <andrug@localhost>
Date: Wed, 23 Apr 2008 15:09:05 +0000
Subject: [PATCH] avoid staf exception when clients object list is empty

---
 opendj-sdk/opends/tests/system-tests/phases/parser/parser.xml |   24 ++++--
 opendj-sdk/opends/tests/system-tests/phases/main_run_lib.xml  |  196 +++++++++++++++++++++++++-----------------------
 opendj-sdk/opends/tests/system-tests/phases/main_run.xml      |    8 +
 3 files changed, 123 insertions(+), 105 deletions(-)

diff --git a/opendj-sdk/opends/tests/system-tests/phases/main_run.xml b/opendj-sdk/opends/tests/system-tests/phases/main_run.xml
index 25d5338..e75db42 100644
--- a/opendj-sdk/opends/tests/system-tests/phases/main_run.xml
+++ b/opendj-sdk/opends/tests/system-tests/phases/main_run.xml
@@ -353,8 +353,12 @@
       
       
       
-      <!-- ============ scheduler ==================================== -->
-      <if expr="runScheduler == 'true' and ERR_NUM_TOTAL == 0">
+      <!-- ============ SCHEDULER ==================================== -->
+      <!--== Get the enabled clients list from all modules ==-->
+      <call function="'getEnabledClients'">{'scheduler':scheduler}</call>
+      <script>clients = STAXResult </script>
+      <if expr="runScheduler == 'true' and ERR_NUM_TOTAL == 0
+                and len(clients) > 0">
         <sequence>
           <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
             file="'%s/phases/scheduler/scheduler.xml' % (TESTS_DIR)"/>
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 3534fac..6a68afd 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
@@ -209,94 +209,98 @@
       <call function="'getEnabledClients'">{'scheduler':scheduler}</call>
       <script>clients = STAXResult </script>
       
-      <!--======= Create instance log dir on instance's host =====-->
-      <paralleliterate in="clients" var="client">
+      <if expr="len(clients) > 0">
         <sequence>
-          <call function="'createFolder'">
-            { 'location'   : client.getHost(),
-              'foldername' : client.getLogDir(),
-              'fileFd'     : NO_FILE
-            }
-          </call>
-          <call function="'createFolder'">
-            { 'location'   : client.getHost(),
-              'foldername' : LOG_TMP_DIR,
-              'fileFd'     : NO_FILE
-            }
-          </call>
-        </sequence>
-      </paralleliterate>
-      
-      <!--====== Copy framework files needed to client hosts ======-->
-      <!-- Copy framework one time per host even if several        -->
-      <!-- client on same host                                     -->
-      <!--== Get the list of hosts for each client              ===-->
-      <script>
-        _list = []
-        _i = 0
-        _listName = []
-        for client in clients:
-          if client.getHost() not in _listName:
-            _listName.append(client.getHost())
-            _list.append([_i,client])
-            _i += 1
-      </script>
-      <paralleliterate in="_list" var="element">
-        <sequence>
-          <if expr="runScheduler == 'true' or runConfiguration == 'true'">
+          <!--======= Create instance log dir on instance's host =====-->
+          <paralleliterate in="clients" var="client">
             <sequence>
-              <script>
-                id = element[0]
-                client = element[1]
-              </script>
-              <!-- Parrallel copy, all instances except client 0 wait 1 sec -->
-              <!-- This prevent copying the same folder in case of NFS      -->
-              <if expr="id != 0">
-                <call function="'sleep'">
-                  {
-                    'sleepForMilliSeconds'  : '2000',
-                    'silentMode' : 'TRUE',
-                    'fileFd' : NO_FILE
-                  }
-                </call>
-              </if>
-              <!-- Copy shared clients -->
-              <call function="'copyFolder'">
-              {
-                'remoteHost'    : '%s%s' % (client.getHost(),DOMAIN[0]),
-                'fromDirectory' : '%s/clients' % TESTS_DIR,
-                'toDirectory'   : '%s/clients' % LOCAL_TESTS_DIR,
-                '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'    : '%s%s' % (client.getHost(),DOMAIN[0]),
-                  'fromDirectory' : '%s/scenario/%s/clients' % \
-                                    (TESTS_DIR,DIR_NAME),
-                  'toDirectory'   : '%s/scenario/%s/clients' % \
-                                    (LOCAL_TESTS_DIR,DIR_NAME),
-                  'fileFd'        : NO_FILE
+              <call function="'createFolder'">
+                { 'location'   : client.getHost(),
+                  'foldername' : client.getLogDir(),
+                  'fileFd'     : NO_FILE
                 }
-                </call>
+              </call>
+              <call function="'createFolder'">
+                { 'location'   : client.getHost(),
+                  'foldername' : LOG_TMP_DIR,
+                  'fileFd'     : NO_FILE
+                }
+              </call>
+            </sequence>
+          </paralleliterate>
+          
+          <!--====== Copy framework files needed to client hosts ======-->
+          <!-- Copy framework one time per host even if several        -->
+          <!-- client on same host                                     -->
+          <!--== Get the list of hosts for each client              ===-->
+          <script>
+            _list = []
+            _i = 0
+            _listName = []
+            for client in clients:
+              if client.getHost() not in _listName:
+                _listName.append(client.getHost())
+                _list.append([_i,client])
+                _i += 1
+          </script>
+          <paralleliterate in="_list" var="element">
+            <sequence>
+              <if expr="runScheduler == 'true' or runConfiguration == 'true'">
+                <sequence>
+                  <script>
+                    id = element[0]
+                    client = element[1]
+                  </script>
+                  <!-- Parrallel copy, all instances except             -->
+                  <!-- client 0 wait 1 sec. This prevent copying        -->
+                  <!-- the same folder in case of NFS                   -->
+                  <if expr="id != 0">
+                    <call function="'sleep'">
+                      {
+                        'sleepForMilliSeconds'  : '2000',
+                        'silentMode' : 'TRUE',
+                        'fileFd' : NO_FILE
+                      }
+                    </call>
+                  </if>
+                  <!-- Copy shared clients -->
+                  <call function="'copyFolder'">
+                  {
+                    'remoteHost'    : '%s%s' % (client.getHost(),DOMAIN[0]),
+                    'fromDirectory' : '%s/clients' % TESTS_DIR,
+                    'toDirectory'   : '%s/clients' % LOCAL_TESTS_DIR,
+                    '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'    : '%s%s' % (client.getHost(),DOMAIN[0]),
+                      '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>
-          </if>
+          </paralleliterate>
         </sequence>
-      </paralleliterate>
-      
+      </if>
       
       <message log="1">
         '== Found %s Error(s) during this phase' % (ERR_NUM[0])
@@ -393,19 +397,21 @@
       <call function="'getEnabledClients'">{'scheduler':scheduler}</call>
       <script>clients = STAXResult </script>
       
-      <iterate in="clients" var="client">
-        <sequence>
-          <call function="'copyFolder'">
-            { 'location'      : client.getHost(),
-              'remoteHost'    : STAXServiceMachine,
-              'fromDirectory' : client.getLogDir(),
-              'toDirectory'   : client.getLogDir(),
-              'fileFd'        : NO_FILE
-            }
-          </call>
-          
-        </sequence>
-      </iterate>
+      <if expr="len(clients) > 0">
+        <iterate in="clients" var="client">
+          <sequence>
+            <call function="'copyFolder'">
+              { 'location'      : client.getHost(),
+                'remoteHost'    : STAXServiceMachine,
+                'fromDirectory' : client.getLogDir(),
+                'toDirectory'   : client.getLogDir(),
+                'fileFd'        : NO_FILE
+              }
+            </call>
+            
+          </sequence>
+        </iterate>
+      </if>
       
       <!--== Copy xsl file needed to read the report ==-->
       <call function="'copyFile'">
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 7e113cf..e31c17d 100755
--- a/opendj-sdk/opends/tests/system-tests/phases/parser/parser.xml
+++ b/opendj-sdk/opends/tests/system-tests/phases/parser/parser.xml
@@ -142,14 +142,22 @@
       <!--== Get the enabled clients list from all modules ==-->
       <call function="'getEnabledClients'">{'scheduler':scheduler}</call>
       <script>clients = STAXResult </script>
-      <paralleliterate in="clients" var="client">
-        <sequence>
-          <script>
-            client.setLogDir('%s/client_%s_id%s' % \
-            (LOG_DIR,client.getName(),client.getId()))
-          </script>
-        </sequence>
-      </paralleliterate>
+      <if expr="len(clients) > 0">
+        <paralleliterate in="clients" var="client">
+          <sequence>
+            <script>
+              client.setLogDir('%s/client_%s_id%s' % \
+              (LOG_DIR,client.getName(),client.getId()))
+            </script>
+          </sequence>
+        </paralleliterate>
+      <else>
+        <script>
+          msg = '%s\nWARNING : client list is empty,' % msg
+          msg = '%s check clients are defined and modules are enabled\n' % msg
+        </script>
+      </else>
+      </if>
       
       
       <!--=================================================================-->

--
Gitblit v1.10.0