From d14f7a3574a4bd3d05bac70d809e19c13cb239ad Mon Sep 17 00:00:00 2001
From: gary_williams <gary_williams@localhost>
Date: Mon, 11 Dec 2006 11:53:45 +0000
Subject: [PATCH] functional tests generate a HTML based test report for result
---
opends/tests/functional-tests/config/config.py | 4 ++
opends/tests/functional-tests/testcases/runTestJob.xml | 85 ++++++++++++++++++++++++++++++++++++++----
2 files changed, 81 insertions(+), 8 deletions(-)
diff --git a/opends/tests/functional-tests/config/config.py b/opends/tests/functional-tests/config/config.py
index 1081100..5ab7036 100644
--- a/opends/tests/functional-tests/config/config.py
+++ b/opends/tests/functional-tests/config/config.py
@@ -1,5 +1,9 @@
+TEST_OS_STRING = 'OS_STRING'
+TEST_HW_STRING = 'HW_STRING'
+TEST_JVM_STRING = 'JVM_STRING'
STAF_LOCAL_HOSTNAME = 'localhost'
STAF_REMOTE_HOSTNAME = 'localhost'
+STAF_JAVA_HOME = '/usr/jdk/jdk1.5.0'
STAF_HOME_DIR = '/usr/local/staf'
TMPDIR = '/tmp'
PSWDFILE = '/tmp/password'
diff --git a/opends/tests/functional-tests/testcases/runTestJob.xml b/opends/tests/functional-tests/testcases/runTestJob.xml
index d1c813e..8944d1c 100644
--- a/opends/tests/functional-tests/testcases/runTestJob.xml
+++ b/opends/tests/functional-tests/testcases/runTestJob.xml
@@ -35,26 +35,30 @@
<sequence>
<script>
+ STAXLogMessage = 1
logdir='%s' % TMPDIR
</script>
- <job name="'Test Job 1'" monitor="1" clearlogs="'Enabled'" logtcstartstop="'Enabled'">
+ <job name="'Job: %s %s' % (STAF_REMOTE_HOSTNAME,TEST_OS_STRING) " monitor="1" clearlogs="'Enabled'" logtcstartstop="'Enabled'">
<job-file>'%s/testcases/runFuncTests.xml' % TESTS_DIR</job-file>
<job-scriptfiles machine="'%s' % STAF_LOCAL_HOSTNAME">['%s/config/config.py' % TESTS_DIR,'%s/python/security.py' % TESTS_SHARED_DIR]</job-scriptfiles>
<job-action>
- <log>'Started sub-job %s' % (STAXSubJobID)</log>
+ <log>'Started sub-job %s on %s' % (STAXSubJobID,STAF_REMOTE_HOSTNAME)</log>
</job-action>
</job>
<if expr="RC == 0">
<message>'Sub-job %s completed. Result: %s' % (STAXSubJobID, STAXResult)</message>
<else>
- <message>'Sub-job %s could not be started. RC: %s Result: %s' % (STAXSubJobID,RC,STAFResult)</message>
+ <sequence>
+ <message log="1" level="'Error'">'Sub-job %s could not be started. RC: %s Result: %s' % (STAXSubJobID,RC,STAFResult)</message>
+ <return>1</return>
+ </sequence>
</else>
</if>
<stafcmd name="'STAF Command: Log Query All'">
- <location>'localhost'</location>
+ <location>'%s' % STAF_LOCAL_HOSTNAME </location>
<service>'log'</service>
<request>
'QUERY ALL MACHINE %s LOGNAME STAX_Job_%s' % (STAXServiceMachine,STAXSubJobID)
@@ -62,14 +66,14 @@
</stafcmd>
<message>
- 'RC=%s, STAFResult= %s' % (RC,STAFResult)
+ 'Log Query on STAX_Job_%s Completed. RC=%s' % (STAXSubJobID,RC)
</message>
<!-- Write Text File for results -->
<script>
resultFile= STAFResult
- outfile= '%s/results.txt' % logdir
- txtfh=open(outfile,'w')
+ textfile= '%s/results.txt' % logdir
+ txtfh=open(textfile,'w')
</script>
<iterate var="line" in="resultFile">
@@ -84,6 +88,10 @@
txtfh.close()
</script>
+ <message>
+ 'TEXT Report Written to %s.' % textfile
+ </message>
+
<!-- Write XML File for results -->
<script>
import re
@@ -189,6 +197,17 @@
<script>
xmlfh.write('<qa>\n')
xmlfh.write(' <functional-tests>\n')
+ xmlfh.write(' <identification>\n')
+ xmlfh.write(' <platform>\n')
+ xmlfh.write(' %s\n' % TEST_OS_STRING)
+ xmlfh.write(' </platform>\n')
+ xmlfh.write(' <hardware>\n')
+ xmlfh.write(' %s\n' % TEST_HW_STRING)
+ xmlfh.write(' </hardware>\n')
+ xmlfh.write(' <jvm>\n')
+ xmlfh.write(' %s\n' % TEST_JVM_STRING)
+ xmlfh.write(' </jvm>\n')
+ xmlfh.write(' </identification>\n')
xmlfh.write(' <results>\n')
</script>
@@ -247,7 +266,57 @@
xmlfh.close()
errorfh.close()
</script>
-
+
+ <message>
+ 'XML Report Written to %s.' % xmlfile
+ </message>
+
+ <!-- Transform Report XML into HTML -->
+ <script>
+ htmlfile= '%s/results.html' % logdir
+ xml2htmlname= 'xmlToHtml'
+ xml2htmldir= '%s/java/%s' % (TESTS_SHARED_DIR,xml2htmlname)
+ xml2htmlclass= '%s/%s.class' % (xml2htmldir,xml2htmlname)
+ xml2htmljava = '%s/%s.java' % (xml2htmldir,xml2htmlname)
+ xslfile= '%s/xsl/gen-alltests-report.xsl' % TESTS_SHARED_DIR
+ </script>
+
+ <stafcmd name="'STAF Command: Check for xml2html transformer'">
+ <location>'%s' % (STAF_LOCAL_HOSTNAME)</location>
+ <service>'fs'</service>
+ <request>
+ 'GET ENTRY %s TYPE' % xml2htmlclass
+ </request>
+ </stafcmd>
+
+ <if expr="RC == 48">
+ <sequence>
+ <message log="1" level="'Error'">
+ 'XML transformer (%s) does not exist.' % xml2htmlclass
+ </message>
+ <return>1</return>
+ </sequence>
+ </if>
+
+ <process name="'Transform Report XML into HTML'">
+ <location>'%s' % STAF_LOCAL_HOSTNAME</location>
+ <command>'%s/bin/java' % STAF_JAVA_HOME</command>
+ <parms>'-cp %s xmlToHtml %s %s %s' % (xml2htmldir,xslfile,xmlfile,htmlfile)</parms>
+ <stderr mode="'stdout'"/>
+ <returnstdout/>
+ </process>
+
+ <if expr="RC == 0">
+ <message>
+ 'HTML Report Written to %s.' % htmlfile
+ </message>
+ <else>
+ <message log="1" level="'Error'">
+ 'Failed to write HTML Report. RC: %s, STAFResult: %s, STAXResult: %s' % (RC,STAFResult,STAXResult)
+ </message>
+ </else>
+ </if>
+
</sequence>
</function>
--
Gitblit v1.10.0