<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<!DOCTYPE stax SYSTEM "stax.dtd">
|
<!--
|
! CDDL HEADER START
|
!
|
! The contents of this file are subject to the terms of the
|
! Common Development and Distribution License, Version 1.0 only
|
! (the "License"). You may not use this file except in compliance
|
! with the License.
|
!
|
! You can obtain a copy of the license at
|
! trunk/opends/resource/legal-notices/OpenDS.LICENSE
|
! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
|
! See the License for the specific language governing permissions
|
! and limitations under the License.
|
!
|
! When distributing Covered Code, include this CDDL HEADER in each
|
! file and include the License file at
|
! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
|
! add the following below this CDDL HEADER, with the fields enclosed
|
! by brackets "[]" replaced with your own identifying * information:
|
! Portions Copyright [yyyy] [name of copyright owner]
|
!
|
! CDDL HEADER END
|
!
|
! Portions Copyright 2006 Sun Microsystems, Inc.
|
! -->
|
|
<stax>
|
|
<defaultcall function="start_job"/>
|
|
<function name="start_job">
|
|
<sequence>
|
|
<script>
|
STAXLogMessage = 1
|
logdir='%s' % TMPDIR
|
</script>
|
|
<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 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>
|
<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>'%s' % STAF_LOCAL_HOSTNAME </location>
|
<service>'log'</service>
|
<request>
|
'QUERY ALL MACHINE %s LOGNAME STAX_Job_%s' % (STAXServiceMachine,STAXSubJobID)
|
</request>
|
</stafcmd>
|
|
<message>
|
'Log Query on STAX_Job_%s Completed. RC=%s' % (STAXSubJobID,RC)
|
</message>
|
|
<!-- Write Text File for results -->
|
<script>
|
resultFile= STAFResult
|
textfile= '%s/results.txt' % logdir
|
txtfh=open(textfile,'w')
|
</script>
|
|
<iterate var="line" in="resultFile">
|
|
<script>
|
txtfh.write('%s\n' % line)
|
</script>
|
|
</iterate>
|
|
<script>
|
txtfh.close()
|
</script>
|
|
<message>
|
'TEXT Report Written to %s.' % textfile
|
</message>
|
|
<!-- Write XML File for results -->
|
<script>
|
import re
|
resultFile= STAFResult
|
xmlfile= '%s/results.xml' % logdir
|
xmlfh=open(xmlfile,'w')
|
errorfile= '%s/results.errors' % logdir
|
errorfh=open(errorfile,'w')
|
</script>
|
|
<!-- Build the test case dictionary object -->
|
<script>
|
testDict={}
|
testCaseList=[]
|
</script>
|
|
<iterate var="element" in="STAFResult">
|
<script>
|
level=element['level']
|
message=element['message']
|
timestamp=element['timestamp']
|
|
startValueDict={}
|
stopValueDict={}
|
statusValueDict={}
|
|
if level == 'Start':
|
|
tcpattern=re.compile("(Testcase): (.*)")
|
tcmatch = tcpattern.search(message)
|
|
if tcmatch:
|
tctype=tcmatch.group(1)
|
tcname=tcmatch.group(2)
|
|
if testDict.has_key(tcname):
|
|
for key in testDict[tcname].keys():
|
value=testDict[tcname][key]
|
startValueDict[key]=value
|
|
startValueDict['start']=timestamp
|
testDict[tcname]=startValueDict
|
|
testCaseList.append(tcname)
|
|
else:
|
errorfh.write('No match element %s.\n' % element)
|
|
if level == 'Stop':
|
|
tcpattern=re.compile("(Testcase): (.*), ElapsedTime: (.*)")
|
tcmatch = tcpattern.search(message)
|
|
if tcmatch:
|
tctype=tcmatch.group(1)
|
tcname=tcmatch.group(2)
|
tctime=tcmatch.group(3)
|
|
if testDict.has_key(tcname):
|
|
for key in testDict[tcname].keys():
|
value=testDict[tcname][key]
|
stopValueDict[key]=value
|
|
stopValueDict['stop']=timestamp
|
stopValueDict['duration']=tctime
|
testDict[tcname]=stopValueDict
|
|
else:
|
errorfh.write('No match element %s.\n' % element)
|
|
if level == 'Status':
|
|
tcpattern=re.compile("(Testcase): (.*), Pass: (.*), Fail: (.*), ElapsedTime: (.*), NumStarts: (.*)")
|
tcmatch = tcpattern.search(message)
|
|
if tcmatch:
|
tctype=tcmatch.group(1)
|
tcname=tcmatch.group(2)
|
tcpass=tcmatch.group(3)
|
tcfail=tcmatch.group(4)
|
tctime=tcmatch.group(5)
|
tcnums=tcmatch.group(6)
|
|
if testDict.has_key(tcname):
|
|
for key in testDict[tcname].keys():
|
value=testDict[tcname][key]
|
statusValueDict[key]=value
|
|
statusValueDict['pass']=tcpass
|
statusValueDict['fail']=tcfail
|
testDict[tcname]=statusValueDict
|
|
else:
|
errorfh.write('No match element %s.\n' % element)
|
|
</script>
|
</iterate>
|
|
<!-- XML Report Pre -->
|
<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>
|
|
<!-- XML Report Results -->
|
<script>
|
for tcname in testCaseList:
|
|
if testDict.has_key(tcname):
|
|
if testDict[tcname].has_key('pass'):
|
tcpass=testDict[tcname]['pass']
|
else:
|
tcpass='0'
|
|
if testDict[tcname].has_key('fail'):
|
tcfail=testDict[tcname]['fail']
|
else:
|
tcfail='0'
|
|
if testDict[tcname].has_key('start'):
|
tcstart=testDict[tcname]['start']
|
else:
|
tcstart='unknown'
|
|
if testDict[tcname].has_key('stop'):
|
tcstop=testDict[tcname]['stop']
|
else:
|
tcstop='unknown'
|
|
if testDict[tcname].has_key('duration'):
|
tcduration=testDict[tcname]['duration']
|
else:
|
duration='unknown'
|
|
else:
|
errorfh.write('No key for testcase %s.\n' % tcname)
|
|
if int(tcfail) == 0 and int(tcpass) > 0:
|
tcresult='pass'
|
elif int(tcfail) == 0 and int(tcpass) == 0:
|
tcresult='unknown'
|
else:
|
tcresult='fail'
|
|
xmlfh.write(' <testcase name="%s" result="%s" start="%s" stop="%s" duration="%s"/>\n' % (tcname,tcresult,tcstart,tcstop,tcduration))
|
</script>
|
|
<!-- XML Report Post -->
|
<script>
|
xmlfh.write(' </results>\n')
|
xmlfh.write(' </functional-tests>\n')
|
xmlfh.write('</qa>\n')
|
</script>
|
|
<script>
|
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>
|
|
</stax>
|