From 75f4159ccb721fbbf43d8da1caa06fd6c2aa0fbe Mon Sep 17 00:00:00 2001
From: andrug <andrug@localhost>
Date: Tue, 18 Mar 2008 13:53:21 +0000
Subject: [PATCH] get opendsbuildId... evenif installation phase is not run

---
 opendj-sdk/opends/tests/system-tests/phases/installation/installation_opends.xml |  127 +++++++++++++++++++++++++-----------------
 opendj-sdk/opends/tests/system-tests/phases/parser/parser.py                     |    1 
 opendj-sdk/opends/tests/system-tests/phases/main_run_lib.xml                     |   12 +++
 3 files changed, 86 insertions(+), 54 deletions(-)

diff --git a/opendj-sdk/opends/tests/system-tests/phases/installation/installation_opends.xml b/opendj-sdk/opends/tests/system-tests/phases/installation/installation_opends.xml
index 7cc8acb..1549a6c 100755
--- a/opendj-sdk/opends/tests/system-tests/phases/installation/installation_opends.xml
+++ b/opendj-sdk/opends/tests/system-tests/phases/installation/installation_opends.xml
@@ -105,10 +105,11 @@
       
       
       <!--== Update missing parameters -->
-      <call function="'updateMissingParameters'">
-      {'instances' : instances}
-      </call>
-      
+      <iterate in="instances" var="instance">
+        <call function="'updateMissingParameters'">
+        {'instance' : instance}
+        </call>
+      </iterate>
     </sequence>
   </function>  
 
@@ -375,61 +376,83 @@
   <!-- ************************************************************ -->
   <function name="updateMissingParameters" scope="local">
     <function-map-args>
-      <function-arg-def name="instances" type="required">
+      <function-arg-def name="instance" type="required">
       </function-arg-def>
     </function-map-args>
     
     <sequence>
-      <!--========  Update missing parameters   ======-->
-      <iterate in="instances" var="instance">
-        <sequence>
+      <!--== Get instance informations ==-->
+      <process name="'%s: Get server infos' % instance.getName()">
+        <location>instance.getHost()</location>
+        <command mode="'shell'">
+          "%s/bin/start-ds -s" % instance.getInstallDir()
+        </command>
+        <envs>['PATH=/bin:/usr/bin:']</envs>
+        <stderr mode="'stdout'"/>
+        <stdout/>
+        <returnstdout/>
+      </process>
+      <!--== Parse and store the outputs returned by the CLI  ==-->
+      <script>
+        instanceInfos = STAXResult[0][1].split('\n')
         
-          <!--== Get instance informations ==-->
-          <process name="'%s: Get server infos' % instance.getName()">
-            <location>instance.getHost()</location>
-            <command mode="'shell'">
-              "%s/bin/start-ds -s" % instance.getInstallDir()
-            </command>
-            <envs>['PATH=/bin:/usr/bin:']</envs>
-            <stderr mode="'stdout'"/>
-            <stdout/>
-            <returnstdout/>
-          </process>
-          <!--== Parse and store the outputs returned by the CLI  ==-->
-          <script>
-            instanceInfos = STAXResult[0][1].split('\n')
-            
-            version = instanceInfos[0].replace("OpenDS Directory Server ","")
-            dict = {}
-            
-            for line in instanceInfos:
-              key = line[0:line.find(':')].strip()
-              value= line[line.find(':')+1:len(line)].strip()
-              dict[key]=value
-            
-            build = dict['Build ID']
-            
-            os = dict['Operating System']
-            os = os.replace("generic ","")
-            
-            jvmVersion   = dict['JVM Version']
-            jvmVendor    = dict['JVM Vendor']
-            if jvmVendor == 'Sun Microsystems Inc.':
-              jvmVendor  = 'sun'
-            jvmArch      = dict['JVM Architecture'].replace("-bit","")
-            
-            
-            jvm = '%s-%s-server-%s' % (jvmVersion,jvmVendor,jvmArch)
-            
-            # Store infos in instance object
-            instance.setJavaVersion(jvm)
-            instance.setBuildId(build)
-            instance.setOs(os)
-          </script>
-        </sequence>
-      </iterate>
+        version = instanceInfos[0].replace("OpenDS Directory Server ","")
+        dict = {}
+        
+        for line in instanceInfos:
+          key = line[0:line.find(':')].strip()
+          value= line[line.find(':')+1:len(line)].strip()
+          dict[key]=value
+        
+        build = dict['Build ID']
+        
+        os = dict['Operating System']
+        os = os.replace("generic ","")
+        
+        jvmVersion   = dict['JVM Version']
+        jvmVendor    = dict['JVM Vendor']
+        if jvmVendor == 'Sun Microsystems Inc.':
+          jvmVendor  = 'sun'
+        jvmArch      = dict['JVM Architecture'].replace("-bit","")
+        
+        
+        jvm = '%s-%s-server-%s' % (jvmVersion,jvmVendor,jvmArch)
+        
+        # Store infos in instance object
+        instance.setJavaVersion(jvm)
+        instance.setBuildId(build)
+        instance.setOs(os)
+      </script>
     </sequence>
   </function>
   
   
+  
+  
+  <!-- ************************************************************ -->
+  <function name="getOpendsBuildID" scope="local">
+    <function-map-args>
+      <function-arg-def name="instance" type="required">
+      </function-arg-def>
+    </function-map-args>
+    
+    <sequence>
+      <!--====  get build id if instance has already been installed  ====-->
+      <call function="'isFile'">
+      {
+        'location' : instance.getHost(),
+        'fileName' : instance.getInstallDir()
+      }
+      </call>
+      <script>
+        installDirExist = STAXResult
+      </script>
+      <!--== if installDir exists, get buildID ==-->
+      <if expr="installDirExist == TRUE">
+        <call function="'updateMissingParameters'">
+          {'instance' : instance}
+        </call>
+      </if>
+    </sequence>
+ </function>
 </stax>
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 b120fc9..bce2f03 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
@@ -100,7 +100,6 @@
         '=================== PREAMBLE  ========================='
       </message>
       
-      
       <!--== Do some stuff on instances machines ==-->
       <paralleliterate in="instances" var="instance">
         <sequence>
@@ -126,6 +125,17 @@
               'fileFd'     : NO_FILE
             }
           </call>
+          <!--== Get opends buildid is instance is already installed ==-->
+          <if expr="instance.getProduct() == 'opends'">
+            <sequence>
+              <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
+               file="'%s/phases/installation/installation_opends.xml' %
+               (TESTS_DIR)"/>
+              <call function="'getOpendsBuildID'">
+                { 'instance' : instance }
+              </call>
+            </sequence>
+          </if>
         </sequence>
       </paralleliterate>
       
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 4e1619f..b9ac5dc 100755
--- a/opendj-sdk/opends/tests/system-tests/phases/parser/parser.py
+++ b/opendj-sdk/opends/tests/system-tests/phases/parser/parser.py
@@ -267,7 +267,6 @@
     self.portJMX     = portJMX
     self.portREPL    = portREPL
     self.javaVersion = NOT_DEFINED
-    self.buildId     = NOT_DEFINED
     
   def getProduct(self):
     return self.product

--
Gitblit v1.10.0