runFuncTests.xml revision d81978a0815d5b8a75633c35e3e1f8708d36f017
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "/shared/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
!
! Copyright 2006-2008 Sun Microsystems, Inc.
! -->
<stax>
<defaultcall function="main" />
<function name="main">
<sequence>
<!--- Load the environment for the test suite execution -->
<import machine="STAF_LOCAL_HOSTNAME"
file="'%s/environment.xml' % TESTS_FUNCTIONS_DIR" />
<call function="'loadGlobalEnvironment'" />
<!-- Build list of test groups to run -->
<script>
listOfChildren=[]
class groupToRun:
def __init__(self, name):
self.name = name
def getName(self):
return self.name
testlog=open('%s/tests-log.xml' % logs.tests,'w')
testlog.write('&lt;qa&gt;\n')
testlog.write(' &lt;functional-tests&gt;\n')
testlog.write(' &lt;results&gt;\n')
testlog.close()
groupsFileName='%s/testcases/run-custom-suites.dat' % TESTS_DIR
if not os.path.exists(groupsFileName):
groupsFileName='%s/testcases/run-default-suites.dat' % TESTS_DIR
f = open(groupsFileName, 'r')
groupsToRun = []
for line in f.readlines():
if line.startswith('#'):
continue
else:
groupsToRun.append(groupToRun(line.rstrip()))
f.close()
</script>
<!-- TODO: If no groupsToRun then iterate will throw exception -->
<iterate var="group" in="groupsToRun" >
<sequence>
<!-- The job that executes the tests -->
<script>
STAXParentID=STAXJobID
</script>
<job name="'%s: %s, %s, %s' % (STAXParentID,STAF_REMOTE_HOSTNAME,TEST_OS_STRING,group.getName())" monitor="1" clearlogs="'Enabled'" logtcstartstop="'Enabled'">
<job-file>
'%s/testcases/%s/%s.xml' % (TESTS_DIR,group.getName(),group.getName())
</job-file>
<job-function>
'main_%s' % group.getName()
</job-function>
<job-function-args eval='1'>
STAXParentID
</job-function-args>
<job-scriptfiles machine="STAF_LOCAL_HOSTNAME">
STAXJobScriptFiles
</job-scriptfiles>
<job-action>
<log>
'Started test group %s, child ID %s, parent ID %s on %s' % (group.getName(),STAXSubJobID,STAXParentID,STAF_LOCAL_HOSTNAME)
</log>
</job-action>
</job>
<if expr="RC == 0">
<sequence>
<message>
'Completed test group %s, child ID %s. Result: %s' % (group.getName(),STAXSubJobID, STAXResult)
</message>
<script>
listOfChildren.append(STAXSubJobID)
</script>
</sequence>
<else>
<sequence>
<message log="1" level="'Error'">
'Test group %s, child ID %s could not be started. RC: %s Result: %s' % (group.getName(),STAXSubJobID,RC,STAFResult)
</message>
</sequence>
</else>
</if>
</sequence>
</iterate>
<!-- in this section we'll compute the coverage for all the tests
if coverage is turned on
so far I could only get through this on either machines with a lot
of memory or small sets of tests
-->
<script>
emmaJar='%s/%s/lib/emma.jar' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)
</script>
<if expr="os.path.exists(emmaJar)">
<sequence>
<script>
coverageFiles=''
for group in os.listdir('%s/coverage/' % TMPDIR):
coverageFiles+='%s/coverage/%s/coverage.ec' % (TMPDIR,group)
</script>
<call function="'runCommand'">
{ 'name' : 'Generate global coverage xml report',
'command' : 'java',
'arguments' : ' -Xms64M -Xmx1024M -cp %s emma report -r xml,html -in %s/coverage.em,%s -Dreport.xml.out.file=%s/coverage/coverage.xml -Dreport.html.out.file=%s/coverage/coverage.html -sp %/src' % (emmaJar,dsPath,coverageFiles,TMPDIR,TMPDIR,TMPDIR),
'path' : TMPDIR
}
</call>
<script>
from java.io import FileInputStream
from javax.xml.transform.stream import StreamSource
from javax.xml.transform.stream import StreamResult
from javax.xml.parsers import DocumentBuilderFactory
from org.w3c.dom import *
factory = DocumentBuilderFactory.newInstance()
builder = factory.newDocumentBuilder()
input = FileInputStream("%s/coverage/coverage.xml" % TMPDIR)
document = builder.parse(input)
dom = document.getDocumentElement()
coverageNodes = dom.getElementsByTagName("all").item(0).getChildNodes()
for coverageNodeIndex in range(coverageNodes.getLength()):
thisNode = coverageNodes.item(coverageNodeIndex)
if thisNode.getNodeName() == 'coverage':
thisNodeAttributes = thisNode.getAttributes()
if thisNodeAttributes.getNamedItem("type").getNodeValue() == 'block, %':
rawCoverage = thisNodeAttributes.getNamedItem("value").getNodeValue()
coverage = rawCoverage.split('%')[0]
testlog=open('%s/tests-log.xml' % logs.tests,'a')
testlog.seek(0,2)
testlog.write(" &lt;all&gt;\n")
testlog.write(" &lt;coverage&gt;\n")
testlog.write(" %s\n" % coverage)
testlog.write(" &lt;/coverage&gt;\n")
testlog.write(" &lt;/all&gt;\n")
testlog.close()
</script>
</sequence>
<else>
<script>
testlog=open('%s/tests-log.xml' % logs.tests,'a')
testlog.seek(0,2)
testlog.write(" &lt;all&gt;\n")
testlog.write(" &lt;coverage&gt;\n")
testlog.write(" N/A\n")
testlog.write(" &lt;/coverage&gt;\n")
testlog.write(" &lt;/all&gt;\n")
testlog.close()
</script>
</else>
</if>
<!-- here goes the section where we get the product's info -->
<call function="'GetVar'">
{ 'location' : STAF_REMOTE_HOSTNAME,
'type' : 'shared',
'variable' : 'Job%s_ServerInfo' % STAXJobID
}
</call>
<if expr="RC != 0">
<script>
STAFResult='{}'
</script>
</if>
<!-- Build the Servers Information Dictionary -->
<script>
ServersInfoDict=eval(STAFResult)
ServerVersion='unknown'
ServerBuildId='unknown'
ServerJavaVersion='unknown'
ServerJavaVendor='unknown'
ServerJVMVersion='unknown'
ServerJVMVendor='unknown'
ServerJVMArchitecture='unknown'
ServerSystemOS='unknown'
ServerSystemName='unknown'
ServerSvnRevision='unknown'
if ServersInfoDict.has_key('%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)):
ServerInfoDict=ServersInfoDict['%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)]
ServerInfoKey='server version'
if ServerInfoDict.has_key(ServerInfoKey):
ServerVersion=ServerInfoDict[ServerInfoKey]
ServerInfoKey='server buildid'
if ServerInfoDict.has_key(ServerInfoKey):
ServerBuildId=ServerInfoDict[ServerInfoKey]
ServerInfoKey='java version'
if ServerInfoDict.has_key(ServerInfoKey):
ServerJavaVersion=ServerInfoDict[ServerInfoKey]
ServerInfoKey='java vendor'
if ServerInfoDict.has_key(ServerInfoKey):
ServerJavaVendor=ServerInfoDict[ServerInfoKey]
ServerInfoKey='jvm version'
if ServerInfoDict.has_key(ServerInfoKey):
ServerJVMVersion=ServerInfoDict[ServerInfoKey]
ServerInfoKey='jvm vendor'
if ServerInfoDict.has_key(ServerInfoKey):
ServerJVMVendor=ServerInfoDict[ServerInfoKey]
ServerInfoKey='jvm architecture'
if ServerInfoDict.has_key(ServerInfoKey):
ServerJVMArchitecture=ServerInfoDict[ServerInfoKey]
ServerInfoKey='system os'
if ServerInfoDict.has_key(ServerInfoKey):
ServerSystemOS=ServerInfoDict[ServerInfoKey]
ServerInfoKey='system name'
if ServerInfoDict.has_key(ServerInfoKey):
ServerSystemName=ServerInfoDict[ServerInfoKey]
ServerInfoKey='svn revision'
if ServerInfoDict.has_key(ServerInfoKey):
ServerSvnRevision=ServerInfoDict[ServerInfoKey]
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' % logs.tests,'a')
testlog.seek(0,2)
testlog.write(' &lt;/results&gt;\n')
testlog.write(' &lt;identification&gt;\n')
testlog.write(' &lt;version&gt;\n')
testlog.write(' %s\n' % ServerVersion)
testlog.write(' &lt;/version&gt;\n')
testlog.write(' &lt;buildid&gt;\n')
testlog.write(' %s\n' % ServerBuildId)
testlog.write(' &lt;/buildid&gt;\n')
testlog.write(' &lt;revision&gt;\n')
testlog.write(' %s\n' % ServerSvnRevision)
testlog.write(' &lt;/revision&gt;\n')
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')
testlog.write(' &lt;tests-dir&gt;\n')
testlog.write(' %s\n' % logs.directory)
testlog.write(' &lt;/tests-dir&gt;\n')
testlog.write(' &lt;/identification&gt;\n')
testlog.write(' &lt;/functional-tests&gt;\n')
testlog.write('&lt;/qa&gt;\n')
testlog.close()
</script>
<return>listOfChildren</return>
</sequence>
</function>
</stax>