From b0a465e7bacfe61b72dd746680c3fe33b8d614ce Mon Sep 17 00:00:00 2001
From: andrug <andrug@localhost>
Date: Sun, 29 Jun 2008 17:30:03 +0000
Subject: [PATCH] QA: System Test: Review: Add new dedicated jython object to manage external tools

---
 opendj-sdk/opends/tests/system-tests/phases/parser/parser.py                       |  137 +++++++++++++++++++++------
 opendj-sdk/opends/tests/system-tests/phases/parser/parser.xml                      |   96 ++++++++++++++++--
 opendj-sdk/opends/tests/system-tests/scenario/conf.dtd                             |   10 +-
 opendj-sdk/opends/tests/system-tests/phases/main_run_lib.xml                       |   24 ++--
 opendj-sdk/opends/tests/system-tests/phases/main_run.xml                           |   13 +-
 opendj-sdk/opends/tests/system-tests/phases/configuration/configuration_opends.xml |    2 
 6 files changed, 215 insertions(+), 67 deletions(-)

diff --git a/opendj-sdk/opends/tests/system-tests/phases/configuration/configuration_opends.xml b/opendj-sdk/opends/tests/system-tests/phases/configuration/configuration_opends.xml
index 342ec27..1e8446d 100755
--- a/opendj-sdk/opends/tests/system-tests/phases/configuration/configuration_opends.xml
+++ b/opendj-sdk/opends/tests/system-tests/phases/configuration/configuration_opends.xml
@@ -1001,7 +1001,7 @@
               
               <call function="'copyFile'">
               {
-                'srcFile'    : scenario.getJdmkrtPath(),
+                'srcFile'    : externalTools.getJdmkrtPath(),
                 'destFile'   : jdmkrt,
                 'location'   : STAXServiceMachine,
                 'remoteHost' : instance.getHost(),
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 f7f5647..4830034 100644
--- a/opendj-sdk/opends/tests/system-tests/phases/main_run.xml
+++ b/opendj-sdk/opends/tests/system-tests/phases/main_run.xml
@@ -192,12 +192,13 @@
         file="'%s/phases/parser/parser.xml' % (TESTS_DIR)"/>
       <call function="'parser'">configurationFile</call>
       <script>
-        result    = STAXResult
-        msg       = result[0]
-        instances = result[1]
-        suffix    = result[2]
-        scheduler = result[3]
-        scenario  = result[4]
+        result        = STAXResult
+        msg           = result[0]
+        instances     = result[1]
+        suffix        = result[2]
+        scheduler     = result[3]
+        scenario      = result[4]
+        externalTools = result[5]
         PHASE_PARSER.setRun('true')
         PHASE_PARSER.setErrNum(ERR_NUM[0])
         ERR_NUM_TOTAL  = ERR_NUM_TOTAL + ERR_NUM[0]
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 bdf0f0e..d35db2f 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
@@ -350,16 +350,20 @@
       <!-- Set path to clients -->
       <!-- set local client by default if exist in the scenario -->
       <!-- else get the shared client if exist -->
-      <call function="'getEnabledClients'">{'scheduler':scheduler}</call>
-      <script>clients = STAXResult </script>
-      <if expr="len(clients) > 0">
-        <paralleliterate in="clients" var="client">
-          <sequence>
-            <call function="'clientSetPath'">
-            { 'client' : client }
-            </call>
-          </sequence>
-        </paralleliterate>
+      <if expr="runScheduler == 'true'">
+        <sequence>
+          <call function="'getEnabledClients'">{'scheduler':scheduler}</call>
+          <script>clients = STAXResult </script>
+          <if expr="len(clients) > 0">
+            <paralleliterate in="clients" var="client">
+              <sequence>
+                <call function="'clientSetPath'">
+                { 'client' : client }
+                </call>
+              </sequence>
+            </paralleliterate>
+          </if>
+        </sequence>
       </if>
       
       
diff --git a/opendj-sdk/opends/tests/system-tests/phases/parser/parser.py b/opendj-sdk/opends/tests/system-tests/phases/parser/parser.py
index f8e96d4..6fbce1a 100755
--- a/opendj-sdk/opends/tests/system-tests/phases/parser/parser.py
+++ b/opendj-sdk/opends/tests/system-tests/phases/parser/parser.py
@@ -100,6 +100,35 @@
     return self.percentage
 
 
+#
+# Class for external tools
+#
+
+###########################
+class ExtTools:
+  "Describes all the external tools needed"
+  def __init__(self):
+    self.jdmkrtPath     = NOT_DEFINED
+    self.jcommonPath    = NOT_DEFINED
+    self.jfreechartPath = NOT_DEFINED
+    
+  def getJdmkrtPath(self):
+    return self.jdmkrtPath
+    
+  def setJdmkrtPath(self,jdmkrtPath):
+    self.jdmkrtPath = jdmkrtPath
+    
+  def getJcommonPath(self):
+    return self.jcommonPath
+    
+  def setJcommonPath(self,jcommonPath):
+    self.jcommonPath = jcommonPath
+    
+  def getJfreechartPath(self):
+    return self.jfreechartPath
+    
+  def setJfreechartPath(self,jfreechartPath):
+    self.jfreechartPath = jfreechartPath
 
 #
 # Class for suffix
@@ -635,9 +664,10 @@
       
       result = parseGlobalParameters(thisChild)
       msg = '%s \n %s' % (msg,result[0])
-      scenario   = result[1]
-      opendsZip  = result[2]
-      domain     = result[3]
+      scenario      = result[1]
+      opendsZip     = result[2]
+      domain        = result[3]
+      externalTools = result[4]
     
     #
     # Parsing instance node
@@ -725,7 +755,8 @@
       if cInstance.getName() == cSuffixInstance.getName():
         cSuffixInstance.setInstanceRef(cInstance)
       
-  return [msg,instances,suffix,phases,scenario,domain]
+      
+  return [msg,instances,suffix,phases,scenario,externalTools,domain]
   # end of main function  
   
   
@@ -1290,9 +1321,7 @@
   scenario        = NOT_DEFINED
   opendsZip       = NOT_DEFINED
   domain          = NOT_DEFINED
-  cJdmkrtPath     = NOT_DEFINED
-  cJcommonPath    = NOT_DEFINED
-  cJfreeChartPath = NOT_DEFINED
+  externalTools   = ExtTools()
   
   #
   # Parsing second level
@@ -1320,16 +1349,10 @@
         msg = '%s\n%s' % (msg,cResult[0])
       
       elif (thisSubChild.getNodeType() == Node.ELEMENT_NODE and
-          thisSubChild.getNodeName() == 'jdmkrt'):
-        cJdmkrtPath = _getPropValue(thisSubChild)
-      
-      elif (thisSubChild.getNodeType() == Node.ELEMENT_NODE and
-          thisSubChild.getNodeName() == 'jfreechart'):
-        cJfreeChartPath = _getPropValue(thisSubChild)
-      
-      elif (thisSubChild.getNodeType() == Node.ELEMENT_NODE and
-          thisSubChild.getNodeName() == 'jcommon'):
-        cJcommonPath = _getPropValue(thisSubChild)
+          thisSubChild.getNodeName() == 'externalTools'):
+        cResult = parseExternalTools(thisSubChild)
+        externalTools = cResult[1]
+        msg = '%s\n%s' % (msg,cResult[0])
       
       # must be at the end of the if case
       elif (thisSubChild.getNodeType() == Node.TEXT_NODE or
@@ -1349,16 +1372,9 @@
     
   if (opendsZip == NOT_DEFINED):
     msg = '%s\n ERROR: parseGlobalParameters() : opendsZip not defined' % (msg)
-    
-  if (cJdmkrtPath != NOT_DEFINED):
-    scenario.setJdmkrtPath(cJdmkrtPath)
-  if (cJfreeChartPath != NOT_DEFINED):
-    scenario.setJfreechartPath(cJfreeChartPath)
-  if (cJcommonPath != NOT_DEFINED):
-    scenario.setJcommonPath(cJcommonPath)
 
 
-  return [msg,scenario,opendsZip,domain]
+  return [msg,scenario,opendsZip,domain,externalTools]
 
 
 
@@ -1367,11 +1383,11 @@
 # Parse global parameters node 
 #
 def parseScenario(thisChild):
-  preMsg      = 'ERROR: parseGlobalParameters():'
+  preMsg      = 'ERROR: parseScenario():'
   msg         = ''
-  result      = []
-  name        = NOT_DEFINED
-  description = NOT_DEFINED
+  cJdmkrtPath     = NOT_DEFINED
+  cJcommonPath    = NOT_DEFINED
+  cJfreeChartPath = NOT_DEFINED
   
   #
   # Parsing second level
@@ -1399,8 +1415,8 @@
         # text node information,skip, no need
         continue
       else:
-        msg = '%s\n ERROR: parseGlobalParameters(): unknown node named %s' % \
-              (msg, thisSubChild.getNodeName())
+        msg = '%s\n %s: unknown node named %s' % \
+              (msg, preMsg, thisSubChild.getNodeName())
         
   #
   # no subchildren for globalParameters node
@@ -1417,4 +1433,63 @@
   return [msg,Scenario(name,description)]
 
 
+#============================================================================
+#
+# Parse global parameters node 
+#
+def parseExternalTools(thisChild):
+  preMsg          = 'ERROR: parseExternalTools():'
+  msg             = ''
+  cJdmkrtPath     = NOT_DEFINED
+  cJcommonPath    = NOT_DEFINED
+  cJfreeChartPath = NOT_DEFINED
+  cExtTools       = ExtTools()
+  
+  #
+  # Parsing second level
+  #
+  if thisChild.hasChildNodes():
+    
+    subChildren = thisChild.getChildNodes()
+    
+    for j in range(subChildren.getLength()):
+    
+      thisSubChild = subChildren.item(j)
+      
+      if (thisSubChild.getNodeType() == Node.ELEMENT_NODE and
+          thisSubChild.getNodeName() == 'jdmkrt'):
+        cJdmkrtPath = _getPropValue(thisSubChild)
+      
+      elif (thisSubChild.getNodeType() == Node.ELEMENT_NODE and
+          thisSubChild.getNodeName() == 'jfreechart'):
+        cJfreeChartPath = _getPropValue(thisSubChild)
+      
+      elif (thisSubChild.getNodeType() == Node.ELEMENT_NODE and
+          thisSubChild.getNodeName() == 'jcommon'):
+        cJcommonPath = _getPropValue(thisSubChild)
+      
+      # must be at the end of the if case
+      elif (thisSubChild.getNodeType() == Node.TEXT_NODE or
+            thisSubChild.getNodeType() == Node.COMMENT_NODE):
+        # text node information,skip, no need
+        continue
+      else:
+        msg = '%s\n %s: unknown node named %s' % \
+              (msg, preMsg, thisSubChild.getNodeName())
+        
+  #
+  # no subchildren for globalParameters node
+  #
+  else:
+    msg = '%s\n %s no child for this node' % (preMsg,msg)
+    
+  if (cJdmkrtPath != NOT_DEFINED):
+    cExtTools.setJdmkrtPath(cJdmkrtPath)
+  if (cJfreeChartPath != NOT_DEFINED):
+    cExtTools.setJfreechartPath(cJfreeChartPath)
+  if (cJcommonPath != NOT_DEFINED):
+    cExtTools.setJcommonPath(cJcommonPath)
+    
+  return [msg,cExtTools]
+
 
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 ec70e7f..2530438 100755
--- a/opendj-sdk/opends/tests/system-tests/phases/parser/parser.xml
+++ b/opendj-sdk/opends/tests/system-tests/phases/parser/parser.xml
@@ -56,17 +56,17 @@
         
         sys.path.append("%s/phases/parser" % TESTS_DIR )
         from parser import *
-        parserResult = main(STAXResult)
-        msg          = parserResult[0]
-        instances    = parserResult[1]
-        suffix       = parserResult[2]
-        scheduler    = parserResult[3]
-        scenario     = parserResult[4]
-        if (parserResult[5] != NOT_DEFINED):
-          DOMAIN[0]  = '.%s' % parserResult[5]
+        parserResult  = main(STAXResult)
+        msg           = parserResult[0]
+        instances     = parserResult[1]
+        suffix        = parserResult[2]
+        scheduler     = parserResult[3]
+        scenario      = parserResult[4]
+        externalTools = parserResult[5]
+        if (parserResult[6] != NOT_DEFINED):
+          DOMAIN[0]  = '.%s' % parserResult[6]
       </script>
       
-      
       <!--=================================================================-->
       <!--========  Set some attributes to add in instance objects   ======-->
       <paralleliterate in="instances" var="instance">
@@ -140,7 +140,7 @@
           </script>
           <!-- Check jdmk dependcy if snmp is enabled -->
           <if expr="instance.getSNMPPort() != NOT_DEFINED 
-                    and scenario.getJdmkrtPath() == NOT_DEFINED">
+                    and externalTools.getJdmkrtPath() == NOT_DEFINED">
             <sequence>
               <message>
                 'ERROR, jdmkrt path not defined, needed for instance %s' % \
@@ -174,15 +174,15 @@
             <script>
               merr = ''
               if client.getName() == 'monitoring':
-                if scenario.getJdmkrtPath() == NOT_DEFINED:
+                if externalTools.getJdmkrtPath() == NOT_DEFINED:
                   merr = '%s\nERROR, jdmkrt path not defined,' % merr
                   merr = '%s needed for monitoring client' % merr
                   ERR_NUM[0] += 1
-                if scenario.getJcommonPath() == NOT_DEFINED:
+                if externalTools.getJcommonPath() == NOT_DEFINED:
                   merr = '%s\nERROR, jcommon path not defined,' % merr
                   merr = '%s needed for monitoring client' % merr
                   ERR_NUM[0] += 1
-                if scenario.getJfreechartPath() == NOT_DEFINED:
+                if externalTools.getJfreechartPath() == NOT_DEFINED:
                   merr = '%s\nERROR, jfreechart path not defined,' % merr
                   merr = '%s needed for monitoring client' % merr
                   ERR_NUM[0] += 1
@@ -202,7 +202,75 @@
       
       
       <!--=================================================================-->
-      <!--========  Basic configuration checks       ======-->
+      <!--========  Basic checks for extTools object                 ======-->
+      
+      <!-- check jdmk jar file exists -->
+      <if expr="externalTools.getJdmkrtPath() != NOT_DEFINED">
+        <sequence>
+          <call function="'isFile'">
+          {
+            'location' : STAXServiceMachine,
+            'fileName' : externalTools.getJdmkrtPath()
+          }
+          </call>
+          <script>
+            fileExist = STAXResult
+          </script>
+          <if expr="fileExist == FALSE">
+            <script>
+              msg = '%s\nERROR : canf find file %s' % \
+                    (msg,externalTools.getJdmkrtPath())
+            </script>
+          </if>
+        </sequence>
+      </if>
+      <!-- check jcommon jar file exists -->
+      <if expr="externalTools.getJcommonPath() != NOT_DEFINED">
+        <sequence>
+          <call function="'isFile'">
+          {
+            'location' : STAXServiceMachine,
+            'fileName' : externalTools.getJcommonPath()
+          }
+          </call>
+          <script>
+            fileExist = STAXResult
+          </script>
+          <if expr="fileExist == FALSE">
+            <script>
+              msg = '%s\nERROR : canf find file %s' % \
+                    (msg,externalTools.getJcommonPath())
+            </script>
+          </if>
+        </sequence>
+      </if>
+      <!-- check jfreechart jar file exists -->
+      <if expr="externalTools.getJfreechartPath() != NOT_DEFINED">
+        <sequence>
+          <call function="'isFile'">
+          {
+            'location' : STAXServiceMachine,
+            'fileName' : externalTools.getJfreechartPath()
+          }
+          </call>
+          <script>
+            fileExist = STAXResult
+          </script>
+          <if expr="fileExist == FALSE">
+            <script>
+              msg = '%s\nERROR : canf find file %s' % \
+                    (msg,externalTools.getJfreechartPath())
+            </script>
+          </if>
+        </sequence>
+      </if>
+      
+      
+      
+      
+      
+      <!--=================================================================-->
+      <!--========  Basic configuration checks                       ======-->
       
       <!-- replace localhost by real host name -->
       <script>
diff --git a/opendj-sdk/opends/tests/system-tests/scenario/conf.dtd b/opendj-sdk/opends/tests/system-tests/scenario/conf.dtd
index 4e4300b..310edf8 100755
--- a/opendj-sdk/opends/tests/system-tests/scenario/conf.dtd
+++ b/opendj-sdk/opends/tests/system-tests/scenario/conf.dtd
@@ -29,8 +29,7 @@
 
 <!-- ========== GLOBAL PARAMETERS NODE ========================= -->
 <!ELEMENT globalParameters (scenario,opendsZip,directoryManagerDn?,
-                            directoryManagerPswd?,domain?,
-                            jdmkrt?,jfreechart?,jcommon?)>
+                            directoryManagerPswd?,domain?,externalTools?)>
   <!ELEMENT scenario (name,description)>
     <!ELEMENT name (#PCDATA)>
     <!ELEMENT description (#PCDATA)>
@@ -38,9 +37,10 @@
   <!ELEMENT directoryManagerDn (#PCDATA)>
   <!ELEMENT directoryManagerPswd (#PCDATA)>
   <!ELEMENT domain (#PCDATA)>
-  <!ELEMENT jdmkrt (#PCDATA)>
-  <!ELEMENT jfreechart (#PCDATA)>
-  <!ELEMENT jcommon (#PCDATA)>
+  <!ELEMENT externalTools (jdmkrt?,jfreechart?,jcommon?)>
+    <!ELEMENT jdmkrt (#PCDATA)>
+    <!ELEMENT jfreechart (#PCDATA)>
+    <!ELEMENT jcommon (#PCDATA)>
 
 <!-- ========== INSTANCE NODE ========================= -->
 <!ELEMENT instance (host,installDir,ports?,security?,tuning?)>

--
Gitblit v1.10.0