From 13117e08c9cf5c7da1afcf5c0081f8df169a315c Mon Sep 17 00:00:00 2001
From: gary_williams <gary_williams@localhost>
Date: Wed, 31 Oct 2007 17:36:05 +0000
Subject: [PATCH] generate a summary text file

---
 opends/tests/functional-tests/testcases/runFuncTests.xml         |   23 +++++
 opends/tests/functional-tests/shared/xsl/my-report.xsl           |    8 -
 opends/tests/functional-tests/shared/xsl/gen-text-summary.xsl    |   50 ++++++++++++
 opends/tests/functional-tests/staf-installer/config.py.stubs     |    1 
 opends/tests/functional-tests/shared/xsl/gen-alltests-report.xsl |   22 ----
 opends/tests/functional-tests/testcases/runTestJob.xml           |  134 ++++++++++++++++++++++++--------
 6 files changed, 178 insertions(+), 60 deletions(-)

diff --git a/opends/tests/functional-tests/shared/xsl/gen-alltests-report.xsl b/opends/tests/functional-tests/shared/xsl/gen-alltests-report.xsl
index 69901db..7476492 100644
--- a/opends/tests/functional-tests/shared/xsl/gen-alltests-report.xsl
+++ b/opends/tests/functional-tests/shared/xsl/gen-alltests-report.xsl
@@ -144,7 +144,7 @@
           <xsl:value-of select="'center'"/>
         </xsl:attribute>
         <xsl:element name="b">
-          <xsl:value-of select="'JVM Version'"/>
+          <xsl:value-of select="'JVM'"/>
         </xsl:element>
       </xsl:element>
       <xsl:element name="td">
@@ -152,14 +152,6 @@
           <xsl:value-of select="'center'"/>
         </xsl:attribute>
         <xsl:element name="b">
-          <xsl:value-of select="'JVM Vendor'"/>
-        </xsl:element>
-      </xsl:element>      
-      <xsl:element name="td">
-        <xsl:attribute name="align">
-          <xsl:value-of select="'center'"/>
-        </xsl:attribute>
-        <xsl:element name="b">
           <xsl:value-of select="'Total'"/>
         </xsl:element>
       </xsl:element>
@@ -210,7 +202,7 @@
           <xsl:value-of select="'center'"/>
         </xsl:attribute>
         <xsl:element name="b">
-          <xsl:value-of select="$identification/platform"/>
+          <xsl:value-of select="$identification/os-label"/>
         </xsl:element>
       </xsl:element>
       <xsl:element name="td">
@@ -218,7 +210,7 @@
           <xsl:value-of select="'center'"/>
         </xsl:attribute>
         <xsl:element name="b">
-          <xsl:value-of select="$identification/jvm-version"/>
+          <xsl:value-of select="$identification/jvm-label"/>
         </xsl:element>
       </xsl:element>
       <xsl:element name="td">
@@ -226,14 +218,6 @@
           <xsl:value-of select="'center'"/>
         </xsl:attribute>
         <xsl:element name="b">
-          <xsl:value-of select="$identification/jvm-vendor"/>
-        </xsl:element>
-      </xsl:element>      
-      <xsl:element name="td">
-        <xsl:attribute name="align">
-          <xsl:value-of select="'center'"/>
-        </xsl:attribute>
-        <xsl:element name="b">
           <xsl:value-of select="$total-tests"/>
         </xsl:element>
       </xsl:element>
diff --git a/opends/tests/functional-tests/shared/xsl/gen-text-summary.xsl b/opends/tests/functional-tests/shared/xsl/gen-text-summary.xsl
new file mode 100644
index 0000000..6a40fe7
--- /dev/null
+++ b/opends/tests/functional-tests/shared/xsl/gen-text-summary.xsl
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="text"/>
+
+<xsl:template match="/">
+
+  <!-- Test Report Header -->
+  <xsl:variable name="identification"     select="qa/functional-tests/identification"/>
+
+  <!-- Test Case Totals -->
+  <xsl:variable name="testcase"     select="qa/functional-tests/results/testgroup/testsuite/testcase"/>
+  <xsl:variable name="total"  select="count($testcase)"/>
+  <xsl:variable name="pass"   select="count($testcase[@result='pass'])"/>
+  <xsl:variable name="fail"   select="count($testcase[@result='fail'])"/>
+  <xsl:variable name="inconc" select="count($testcase[@result='unknown'])"
+/>
+
+  <!-- Overall Test Percentage -->
+  <xsl:variable name="percent">
+    <xsl:choose>
+      <xsl:when test="$total &gt; 0">
+        <xsl:value-of select="round((($pass div $total) * 100) - 0.5
+)"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="0"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:value-of select="concat('result: ', normalize-space($percent),'&#xa;')"/>
+  <xsl:value-of select="concat('pass: ', normalize-space($pass),'&#xa;')"/>
+  <xsl:value-of select="concat('fail: ', normalize-space($fail),'&#xa;')"/>
+  <xsl:value-of select="concat('inconc: ', normalize-space($inconc),'&#xa;')"/>
+  <xsl:value-of select="concat('total: ', normalize-space($total),'&#xa;')"/>
+  <xsl:value-of select="concat('sut-version: ', normalize-space($identification/version),'&#xa;')"/>
+  <xsl:value-of select="concat('sut-buildid: ', normalize-space($identification/buildid),'&#xa;')"/>
+  <xsl:value-of select="concat('sut-revision: ', normalize-space($identification/revision),'&#xa;')"/>
+  <xsl:value-of select="concat('os-hostname: ', normalize-space($identification/hostname),'&#xa;')"/>
+  <xsl:value-of select="concat('os-platform: ', normalize-space($identification/platform),'&#xa;')"/>
+  <xsl:value-of select="concat('os-label: ', normalize-space($identification/os-label),'&#xa;')"/>
+  <xsl:value-of select="concat('jvm-version: ', normalize-space($identification/jvm-version),'&#xa;')"/>
+  <xsl:value-of select="concat('jvm-label: ', normalize-space($identification/jvm-label),'&#xa;')"/>
+  <xsl:value-of select="concat('jvm-vendor: ', normalize-space($identification/jvm-vendor),'&#xa;')"/>
+  <xsl:value-of select="concat('jvm-arch: ', normalize-space($identification/jvm-arch),'&#xa;')"/>
+
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/opends/tests/functional-tests/shared/xsl/my-report.xsl b/opends/tests/functional-tests/shared/xsl/my-report.xsl
index 250ba02..8de2054 100644
--- a/opends/tests/functional-tests/shared/xsl/my-report.xsl
+++ b/opends/tests/functional-tests/shared/xsl/my-report.xsl
@@ -163,8 +163,7 @@
           <th align="center">Build</th>
           <th align="center">Revision</th>
           <th align="center">Platform</th>
-          <th align="center">JVM Version</th>
-          <th align="center">JVM Vendor</th>
+          <th align="center">JVM</th>
           <th align="center" width="5%">Total</th>
           <th align="center" width="5%">Pass</th>
           <th align="center" width="5%">Fail</th>
@@ -175,9 +174,8 @@
         <tr>
           <th align="center"><xsl:value-of select="$identification/buildid"/></th>
           <th align="center"><xsl:value-of select="$identification/revision"/></th>
-          <th align="center"><xsl:value-of select="$identification/platform"/></th>
-          <th align="center"><xsl:value-of select="$identification/jvm-version"/></th>
-          <th align="center"><xsl:value-of select="$identification/jvm-vendor"/></th>
+          <th align="center"><xsl:value-of select="$identification/os-label"/></th>
+          <th align="center"><xsl:value-of select="$identification/jvm-label"/></th>
           <th align="center"><xsl:value-of select="$total"/></th>
           <th align="center"><xsl:value-of select="$pass"/></th>
           <th align="center"><xsl:value-of select="$fail"/></th>
diff --git a/opends/tests/functional-tests/staf-installer/config.py.stubs b/opends/tests/functional-tests/staf-installer/config.py.stubs
index 588a34d..623a34c 100644
--- a/opends/tests/functional-tests/staf-installer/config.py.stubs
+++ b/opends/tests/functional-tests/staf-installer/config.py.stubs
@@ -1,5 +1,4 @@
 TEST_OS_STRING              = '${os.name}'
-TEST_HW_STRING              = '${os.arch}'
 TEST_JVM_STRING             = '${java.version}(${sun.arch.data.model} bits)'
 STAF_LOCAL_HOSTNAME         = 'localhost'
 STAF_REMOTE_HOSTNAME        = 'localhost'
diff --git a/opends/tests/functional-tests/testcases/runFuncTests.xml b/opends/tests/functional-tests/testcases/runFuncTests.xml
index c36b3a7..f5c08c6 100755
--- a/opends/tests/functional-tests/testcases/runFuncTests.xml
+++ b/opends/tests/functional-tests/testcases/runFuncTests.xml
@@ -296,6 +296,23 @@
         else:
           ServerInfoDict='No key found (%s/%s)' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)
         
+        # Platform and JVM can be overridden from config file
+        try:
+          if TEST_OS_STRING:
+            ServerOsString=TEST_OS_STRING
+          else:
+            ServerOsString=ServerSystemOS
+        except NameError,details:
+            ServerOsString=ServerSystemOS
+
+        try:
+          if TEST_JVM_STRING:
+            ServerJVMString=TEST_JVM_STRING
+          else:
+            ServerJVMString=ServerJVMVersion
+        except NameError,details:
+            ServerJVMString=ServerJVMVersion
+
         testlog=open('%s/tests-log.xml' % logsTestsDir,'a')
         testlog.seek(0,2)
         testlog.write('    &lt;/results&gt;\n')
@@ -312,9 +329,15 @@
         testlog.write('      &lt;platform&gt;\n')
         testlog.write('        %s\n' % ServerSystemOS)
         testlog.write('      &lt;/platform&gt;\n')
+        testlog.write('      &lt;os-label&gt;\n')
+        testlog.write('        %s\n' % ServerOsString)
+        testlog.write('      &lt;/os-label&gt;\n')
         testlog.write('      &lt;jvm-version&gt;\n')
         testlog.write('        %s\n' % ServerJVMVersion)
         testlog.write('      &lt;/jvm-version&gt;\n')
+        testlog.write('      &lt;jvm-label&gt;\n')
+        testlog.write('        %s\n' % ServerJVMString)
+        testlog.write('      &lt;/jvm-label&gt;\n')
         testlog.write('      &lt;jvm-vendor&gt;\n')
         testlog.write('        %s\n' % ServerJVMVendor)
         testlog.write('      &lt;/jvm-vendor&gt;\n')        
diff --git a/opends/tests/functional-tests/testcases/runTestJob.xml b/opends/tests/functional-tests/testcases/runTestJob.xml
index dc58a97..ee37a26 100644
--- a/opends/tests/functional-tests/testcases/runTestJob.xml
+++ b/opends/tests/functional-tests/testcases/runTestJob.xml
@@ -46,7 +46,26 @@
         </sequence>
       </if>
 
-      <job name="'Job: %s %s' % (STAF_REMOTE_HOSTNAME,TEST_OS_STRING) " monitor="1" clearlogs="'Enabled'" logtcstartstop="'Enabled'">
+      <!-- Check some of the optional variables from config.py -->
+      <script>
+        try:
+          if TEST_OS_STRING:
+            ServerOsString=TEST_OS_STRING
+          else:
+            ServerOsString='Unknown Operating System'
+        except NameError,details:
+            ServerOsString='Unknown Operating System'    
+
+        try:
+          if TEST_JVM_STRING:
+            ServerJVMString=TEST_JVM_STRING
+          else:
+            ServerJVMString='Unknown JVM'
+        except NameError,details:
+            ServerJVMString='Unknown JVM'
+      </script>
+      
+      <job name="'Job: %s %s' % (STAF_REMOTE_HOSTNAME,ServerOsString) " monitor="1" clearlogs="'Enabled'" logtcstartstop="'Enabled'">
         <job-file>'%s/testcases/runFuncTests.xml' % TESTS_DIR</job-file>
         <job-scriptfiles machine="STAF_LOCAL_HOSTNAME"> STAXJobScriptFiles </job-scriptfiles>
         <job-action>
@@ -107,6 +126,8 @@
         ServerJavaVendor='unknown'
         ServerJVMVersion='unknown'
         ServerJVMVendor='unknown'
+        ServerJVMArchitecture='unknown'
+        ServerJVMLabel='unknown'
         ServerSystemOS='unknown'
         ServerSystemName='unknown'
         ServerSvnRevision='unknown'
@@ -156,7 +177,13 @@
                                                                                                 
         else:
           ServerInfoDict='No key found (%s/%s)' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)
-        
+
+        if ServerOsString == 'Unknown Operating System':
+          ServerOsString=ServerSystemOS        
+
+        if ServerJVMString == 'Unknown JVM':
+          ServerJVMString=ServerJVMVersion
+
       </script>
       
       <message>'Server= %s' % ServerInfoDict </message>     
@@ -358,18 +385,27 @@
         xmlfh.write('      &lt;revision&gt;\n')
         xmlfh.write('        %s\n' % ServerSvnRevision)
         xmlfh.write('      &lt;/revision&gt;\n')                 
+        xmlfh.write('      &lt;hostname&gt;\n')
+        xmlfh.write('        %s\n' % STAF_REMOTE_HOSTNAME)
+        xmlfh.write('      &lt;/hostname&gt;\n')
         xmlfh.write('      &lt;platform&gt;\n')
         xmlfh.write('        %s\n' % ServerSystemOS)
         xmlfh.write('      &lt;/platform&gt;\n')
         xmlfh.write('      &lt;jvm-version&gt;\n')
         xmlfh.write('        %s\n' % ServerJVMVersion)
         xmlfh.write('      &lt;/jvm-version&gt;\n')
+        xmlfh.write('      &lt;jvm-label&gt;\n')
+        xmlfh.write('        %s\n' % ServerJVMString)
+        xmlfh.write('      &lt;/jvm-label&gt;\n')
         xmlfh.write('      &lt;jvm-vendor&gt;\n')
         xmlfh.write('        %s\n' % ServerJVMVendor)
         xmlfh.write('      &lt;/jvm-vendor&gt;\n')
         xmlfh.write('      &lt;jvm-arch&gt;\n')
         xmlfh.write('        %s\n' % ServerJVMArchitecture)
-        xmlfh.write('      &lt;/jvm-arch&gt;\n')                
+        xmlfh.write('      &lt;/jvm-arch&gt;\n')
+        xmlfh.write('      &lt;os-label&gt;\n')
+        xmlfh.write('        %s\n' % ServerOsString)
+        xmlfh.write('      &lt;/os-label&gt;\n')                        
         xmlfh.write('    &lt;/identification&gt;\n')
         xmlfh.write('    &lt;results&gt;\n')
       </script>
@@ -447,48 +483,76 @@
       <message>
         'XML Report Written to %s.' % xmlfile
       </message>
-      
-      <!-- Transform Report XML into HTML -->
+
+      <script>      
+        class reportGeneration:
+          'Test Report Generation'
+          def transformReport(self,stylesheet,xml,output):
+            from java.io import FileInputStream
+            from java.io import FileOutputStream
+            from java.io import ByteArrayOutputStream
+            
+            from javax.xml.transform import TransformerFactory
+            from javax.xml.transform.stream import StreamSource
+            from javax.xml.transform.stream import StreamResult
+              
+            self.xslSource = StreamSource(FileInputStream("%s" % stylesheet))
+            self.xslTemplate = TransformerFactory.newInstance().newTemplates(self.xslSource)
+            self.transformer = self.xslTemplate.newTransformer()
+            
+            self.source = StreamSource(FileInputStream("%s" % xml))
+            self.result = StreamResult(FileOutputStream("%s" % output))
+
+            self.transformer.transform(self.source, self.result)        
+      </script>            
+
+      <!-- Generate the standard test report showing all testcases -->      
       <script>
+        _message='Generated standard test report.'
         xslfile= '%s/xsl/gen-alltests-report.xsl' % TESTS_SHARED_DIR
         htmlfile= '%s/results.html' % logsReportDir
+
+        standardReport=reportGeneration()      
+
+        try:
+          standardReport.transformReport(xslfile,xmlfile,htmlfile)
+        except IOError,details:
+          _message='Unable to generate standard test report %s.' % details
       </script>
-      
-      <message>
-        'Writing HTML (with stylesheet %s) Report to %s.' % (xslfile,htmlfile)
-      </message>
-      
-      <script>
-        _message=''
+      <message>_message</message>
+                    
+      <!-- Generate the drill down test report -->
+      <script>          
+        _message='Generated the drill down test report.'
         myreportxsl='%s/xsl/my-report.xsl' % TESTS_SHARED_DIR
         myreporthtml='%s/my-report.html' % logsReportDir
         mytestslog='%s/tests-log.xml' % logsTestsDir
+
+        drillDownReport=reportGeneration()      
+
         try:
-          from java.io import FileInputStream
-          from java.io import FileOutputStream
-          from java.io import ByteArrayOutputStream
-          
-          from javax.xml.transform import TransformerFactory
-          from javax.xml.transform.stream import StreamSource
-          from javax.xml.transform.stream import StreamResult
-          
-          xslSource = StreamSource(FileInputStream("%s" % xslfile))
-          xslTemplate = TransformerFactory.newInstance().newTemplates(xslSource)
-          transformer = xslTemplate.newTransformer()
-          
-          source = StreamSource(FileInputStream("%s" % xmlfile))
-          result = StreamResult(FileOutputStream("%s" % htmlfile))
-          # the original report
-          transformer.transform(source, result)
-          
-          #the new report transformation
-          TransformerFactory.newInstance().newTemplates(StreamSource(FileInputStream(myreportxsl))).newTransformer().transform(StreamSource(FileInputStream(mytestslog)), StreamResult(FileOutputStream(myreporthtml)))
-          _message='Generated drill-down HTML report'
-        except:
-          _message='Could not generate drill-down HTML report'
+          drillDownReport.transformReport(myreportxsl,mytestslog,myreporthtml)
+        except IOError,details:
+          _message='Unable to generate drill down test report %s.' % details
       </script>
       <message>_message</message>
 
+      <!-- Generate the summary text file -->
+      <script>          
+        _message='Generated the summary text report'
+        mysummaryxsl='%s/xsl/gen-text-summary.xsl' % TESTS_SHARED_DIR
+        mysummarytext='%s/summary.txt' % logsReportDir
+        mysummaryxml=xmlfile
+
+        summaryReport=reportGeneration()      
+
+        try:
+          summaryReport.transformReport(mysummaryxsl,mysummaryxml,mysummarytext)
+        except IOError,details:
+          _message='Unable to generate summary text file %s.' % details
+      </script>
+      <message>_message</message>
+            
       <!-- FixMe: Compatability with Hudson -->      
       <if expr="os.path.exists(myreporthtml)">
         <sequence>
@@ -504,7 +568,7 @@
       <!-- FixMe: Compatability with Hudson -->
       <if expr="os.path.exists(mytestslog)">
         <sequence>
-          <message>'Copy %s to %s' % (myreporthtml,TMPDIR)</message>
+          <message>'Copy %s to %s' % (mytestslog,TMPDIR)</message>
           <call function="'copyFile'">
             { 'srcfile'    : mytestslog,
               'destfile'   : '%s/tests-log.xml' % TMPDIR

--
Gitblit v1.10.0