From 80d60f1320bfba0b38de6145479bbb706280189a Mon Sep 17 00:00:00 2001
From: mkeyes <mkeyes@localhost>
Date: Mon, 29 Oct 2007 15:20:41 +0000
Subject: [PATCH] Adding missing files from last commit for the stress tests.
---
opendj-sdk/opends/tests/stress-tests/testcases/runStressTests.xml | 245 +++++++++++++++++
opendj-sdk/opends/tests/stress-tests/testcases/runTestJob.xml | 524 +++++++++++++++++++++++++++++++++++++
opendj-sdk/opends/tests/stress-tests/build | 51 +++
3 files changed, 820 insertions(+), 0 deletions(-)
diff --git a/opendj-sdk/opends/tests/stress-tests/build b/opendj-sdk/opends/tests/stress-tests/build
new file mode 100755
index 0000000..b5c5156
--- /dev/null
+++ b/opendj-sdk/opends/tests/stress-tests/build
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+# 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
+# information:
+# Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Portions Copyright 2006 Sun Microsystems, Inc.
+
+
+# Change to the location of this build script.
+cd `dirname $0`
+
+
+# See if JAVA_HOME is set. If not, then see if there is a java executable in
+# the path and try to figure it out.
+if test -z "${JAVA_HOME}"
+then
+ JAVA_HOME=`java -cp ../../resource FindJavaHome`
+ if test -z "${JAVA_HOME}"
+ then
+ echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
+ exit 1
+ else
+ export JAVA_HOME
+ fi
+fi
+
+OPENDS_LIB=`cd ../../lib;pwd`
+ANT_HOME=`cd ../..;pwd`/ext/ant
+export ANT_HOME
+# Execute the ant script and pass it any additional command-line arguments.
+$ANT_HOME/bin/ant -lib $OPENDS_LIB/mail.jar:$OPENDS_LIB/activation.jar -f staf-installer.xml ${*}
diff --git a/opendj-sdk/opends/tests/stress-tests/testcases/runStressTests.xml b/opendj-sdk/opends/tests/stress-tests/testcases/runStressTests.xml
new file mode 100755
index 0000000..9b883b8
--- /dev/null
+++ b/opendj-sdk/opends/tests/stress-tests/testcases/runStressTests.xml
@@ -0,0 +1,245 @@
+<?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
+ !
+ ! Portions Copyright 2006-2007 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="'loadEnvironment'" />
+
+ <!-- The Functional Tests -->
+ <import machine="STAF_LOCAL_HOSTNAME"
+ file="'%s/testcases/import_ldif/import_ldif.xml' % TESTS_DIR" />
+
+ <script>
+ # this function return a well-formatted testcase name
+ def getTestCaseName(name):
+ return '%s: %s: %s' % (CurrentTestPath['group'],CurrentTestPath['suite'],name)
+
+ # this functions adds a known issue to a testcase's known issues list
+ issuesList=[]
+ def knownIssue(issue):
+ issuesList.append(issue)
+
+ class functionToRun:
+ def __init__(self, name):
+ self.name = name
+
+ def getName(self):
+ return self.name
+
+ testlog=open('%s/tests-log.xml' % TMPDIR,'w')
+ testlog.write('<qa>\n')
+ testlog.write(' <functional-tests>\n')
+ testlog.write(' <results>\n')
+ testlog.close()
+
+ suitesFileName='%s/testcases/run-custom-suites.dat' % TESTS_DIR
+
+ if not os.path.exists(suitesFileName):
+ suitesFileName='%s/testcases/run-default-suites.dat' % TESTS_DIR
+
+ f = open(suitesFileName, 'r')
+ functionsToRun = []
+ for line in f.readlines():
+ functionsToRun.append(functionToRun(line.rstrip()))
+ f.close()
+ </script>
+ <iterate var="function" in="functionsToRun">
+ <sequence>
+ <message>'calling function [%s]' % function.getName()</message>
+ <call function="function.getName()" />
+ </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
+ -->
+ <if expr="os.path.exists('%s/lib/emma.jar' % dsPath)">
+ <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/lib/emma.jar 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 %s/../../../src' % (dsPath,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' % TMPDIR,'a')
+ testlog.seek(0,2)
+ testlog.write(" <all>\n")
+ testlog.write(" <coverage>\n")
+ testlog.write(" %s\n" % coverage)
+ testlog.write(" </coverage>\n")
+ testlog.write(" </all>\n")
+ testlog.close()
+ </script>
+ </sequence>
+ <else>
+ <script>
+ testlog=open('%s/tests-log.xml' % TMPDIR,'a')
+ testlog.seek(0,2)
+ testlog.write(" <all>\n")
+ testlog.write(" <coverage>\n")
+ testlog.write(" N/A\n")
+ testlog.write(" </coverage>\n")
+ testlog.write(" </all>\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'
+ 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='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)
+
+ testlog=open('%s/tests-log.xml' % TMPDIR,'a')
+ testlog.seek(0,2)
+ testlog.write(' </results>\n')
+ testlog.write(' <identification>\n')
+ testlog.write(' <version>\n')
+ testlog.write(' %s\n' % ServerVersion)
+ testlog.write(' </version>\n')
+ testlog.write(' <buildid>\n')
+ testlog.write(' %s\n' % ServerBuildId)
+ testlog.write(' </buildid>\n')
+ testlog.write(' <revision>\n')
+ testlog.write(' %s\n' % ServerSvnRevision)
+ testlog.write(' </revision>\n')
+ testlog.write(' <platform>\n')
+ testlog.write(' %s\n' % ServerSystemOS)
+ testlog.write(' </platform>\n')
+ testlog.write(' <jvm-version>\n')
+ testlog.write(' %s\n' % ServerJVMVersion)
+ testlog.write(' </jvm-version>\n')
+ testlog.write(' <jvm-vendor>\n')
+ testlog.write(' %s\n' % ServerJVMVendor)
+ testlog.write(' </jvm-vendor>\n')
+ testlog.write(' </identification>\n')
+ testlog.write(' </functional-tests>\n')
+ testlog.write('</qa>\n')
+ testlog.close()
+ </script>
+ </sequence>
+ </function>
+</stax>
diff --git a/opendj-sdk/opends/tests/stress-tests/testcases/runTestJob.xml b/opendj-sdk/opends/tests/stress-tests/testcases/runTestJob.xml
new file mode 100755
index 0000000..5ae3fd8
--- /dev/null
+++ b/opendj-sdk/opends/tests/stress-tests/testcases/runTestJob.xml
@@ -0,0 +1,524 @@
+<?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
+ !
+ ! Portions Copyright 2006-2007 Sun Microsystems, Inc.
+ ! -->
+
+<stax>
+ <defaultcall function="start_job"/>
+ <function name="start_job">
+ <function-single-arg>
+ <function-optional-arg name="config" default="''"/>
+ </function-single-arg>
+
+ <sequence>
+ <script>
+ STAXLogMessage = 1
+ </script>
+
+ <script>
+ if config:
+ import os, sys
+ myconfigpath,myconfigfile=os.path.split(config)
+ sys.path.append("%s" % myconfigpath )
+ from config import *
+ else:
+ myconfigpath='%s/config' % TESTS_DIR
+ myconfigfile='config.py'
+ </script>
+
+ <job name="'Job: %s %s' % (STAF_REMOTE_HOSTNAME,TEST_OS_STRING) " monitor="1" clearlogs="'Enabled'" logtcstartstop="'Enabled'">
+ <job-file>'%s/testcases/runStressTests.xml' % TESTS_DIR</job-file>
+ <job-scriptfiles machine="STAF_LOCAL_HOSTNAME">['%s/%s' % (myconfigpath,myconfigfile) ]</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>
+
+ <!--- Import required shared xml libraries -->
+ <import machine="STAF_LOCAL_HOSTNAME"
+ file="'%s/stafcmd.xml' % TESTS_FUNCTIONS_DIR" />
+
+ <!--
+ dirty workaround because utils.xml now depends on environment.xml
+ to avoid loading environment.xml I'll just set the required vars here
+ allegedly ugly
+ -=arnaud=-
+ -->
+ <script>
+ NO_CHECK = 'noCheck'
+ </script>
+ <import machine="STAF_LOCAL_HOSTNAME"
+ file="'%s/utils.xml' % (TESTS_FUNCTIONS_DIR)" />
+
+ <!-- Get Directory Server Variables -->
+ <call function="'GetVar'">
+ { 'location' : STAF_REMOTE_HOSTNAME,
+ 'type' : 'shared',
+ 'variable' : 'Job%s_ServerInfo' % STAXSubJobID
+ }
+ </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'
+ 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='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)
+
+ </script>
+
+ <message>'Server= %s' % ServerInfoDict </message>
+
+ <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>
+
+ <if expr="RC == 0">
+ <sequence>
+ <script>
+ resultQuery= STAFResult
+ </script>
+ <message>
+ 'Log Query on STAX_Job_%s Completed. RC=%s' % (STAXSubJobID,RC)
+ </message>
+ </sequence>
+ <else>
+ <sequence>
+ <message log="1" level="'Error'">
+ 'Unable to perform log query on STAX_Job_%s. RC: %s Result: %s' % (STAXSubJobID,RC,STAFResult)
+ </message>
+ <return>1</return>
+ </sequence>
+ </else>
+ </if>
+
+ <!-- Get logsDir Variable -->
+ <call function="'GetVar'">
+ { 'location' : STAF_REMOTE_HOSTNAME,
+ 'type' : 'shared',
+ 'variable' : 'Job%s_LogsDir' % STAXSubJobID
+ }
+ </call>
+
+ <if expr="RC == 0">
+ <script>
+ logsDir=STAFResult
+ </script>
+ <else>
+ <sequence>
+ <message>
+ 'Unable to retrieve LogsDir variable, RC=%s,Result=%s.' % (RC,STAFResult)
+ </message>
+ <script>
+ logsDir='%s' % TMPDIR
+ </script>
+ </sequence>
+ </else>
+ </if>
+
+ <script>
+ logsReportDir='%s/reports' % logsDir
+ </script>
+
+ <call function="'createFolder'">
+ { 'location' : STAF_LOCAL_HOSTNAME,
+ 'foldername' : logsReportDir }
+ </call>
+
+ <!-- Write Text File for results -->
+ <script>
+ textfile= '%s/results.txt' % logsReportDir
+ txtfh=open(textfile,'w')
+ </script>
+
+ <iterate var="line" in="resultQuery">
+
+ <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
+ xmlfile= '%s/results.xml' % logsReportDir
+ xmlfh=open(xmlfile,'w')
+ errorfile= '%s/results.errors' % logsReportDir
+ errorfh=open(errorfile,'w')
+ </script>
+
+ <!-- Build the test case dictionary object -->
+ <script>
+ testDict={}
+ testCaseList=[]
+ </script>
+
+ <iterate var="element" in="resultQuery">
+ <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('Warning: No match Start element %s.\n' % element)
+
+ elif 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('Warning: No match Stop element %s.\n' % element)
+
+ elif 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('Warning: No match Status element %s.\n' % element)
+
+ elif level == 'Info':
+ errorfh.write('Warning: Info element %s.\n' % element)
+
+ else:
+ errorfh.write('Error: Unknown 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(' <version>\n')
+ xmlfh.write(' %s\n' % ServerVersion)
+ xmlfh.write(' </version>\n')
+ xmlfh.write(' <buildid>\n')
+ xmlfh.write(' %s\n' % ServerBuildId)
+ xmlfh.write(' </buildid>\n')
+ xmlfh.write(' <revision>\n')
+ xmlfh.write(' %s\n' % ServerSvnRevision)
+ xmlfh.write(' </revision>\n')
+ xmlfh.write(' <platform>\n')
+ xmlfh.write(' %s\n' % ServerSystemOS)
+ xmlfh.write(' </platform>\n')
+ xmlfh.write(' <jvm-version>\n')
+ xmlfh.write(' %s\n' % ServerJVMVersion)
+ xmlfh.write(' </jvm-version>\n')
+ xmlfh.write(' <jvm-vendor>\n')
+ xmlfh.write(' %s\n' % ServerJVMVendor)
+ xmlfh.write(' </jvm-vendor>\n')
+ xmlfh.write(' </identification>\n')
+ xmlfh.write(' <results>\n')
+ </script>
+
+ <!-- XML Report Results -->
+ <script>
+ for tcname in testCaseList:
+
+ if testDict.has_key(tcname):
+ tcnamesplit=tcname.split(":")
+ if tcnamesplit[0]:
+ testgroup=tcnamesplit[0]
+ if tcnamesplit[1]:
+ testsuite=tcnamesplit[1]
+ else:
+ testsuite=testgroup
+ else:
+ testgroup=tcname
+ testsuite=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(' <testgroup name="%s">\n' % testgroup)
+ xmlfh.write(' <testsuite name="%s">\n' % testsuite)
+ xmlfh.write(' <testcase name="%s" result="%s" start="%s" stop="%s" duration="%s"/>\n' % (tcname,tcresult,tcstart,tcstop,tcduration))
+ xmlfh.write(' </testsuite>\n')
+ xmlfh.write(' </testgroup>\n')
+ </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>
+ xslfile= '%s/xsl/gen-alltests-report.xsl' % TESTS_SHARED_DIR
+ htmlfile= '%s/results.html' % logsReportDir
+ </script>
+
+ <message>
+ 'Writing HTML (with stylesheet %s) Report to %s.' % (xslfile,htmlfile)
+ </message>
+
+ <script>
+ _message=''
+ 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("%s/xsl/my-report.xsl" % TESTS_SHARED_DIR))).newTransformer().transform(StreamSource(FileInputStream("%s/tests-log.xml" % TMPDIR)), StreamResult(FileOutputStream("%s/my-report.html" % TMPDIR)))
+ _message='Generated drill-down HTML report'
+ except:
+ _message='Could not generate drill-down HTML report'
+ </script>
+ <message>_message</message>
+ <if expr="SEND_MAIL_AFTER_TEST_RUN == 'TRUE'">
+ <sequence>
+ <message>
+ 'Sending Email Test Report to %s.' % SEND_MAIL_TO
+ </message>
+
+ <script>
+ MailToList= SEND_MAIL_TO.split(",")
+ MailSubject= 'OpenDS Test Report for %s' % STAF_REMOTE_HOSTNAME
+ MailSendTo= ' '
+ </script>
+
+ <iterate var="Recipient" in="MailToList">
+ <script>
+ MailSendTo='to %s %s' % (Recipient,MailSendTo)
+ </script>
+ </iterate>
+
+ <stafcmd name="'STAF Command: Send test report %s' % MailSendTo">
+ <location>'%s' % STAF_LOCAL_HOSTNAME </location>
+ <service>'email'</service>
+ <request>
+ 'send %s contenttype "text/html" file %s subject "%s" noheader' % (MailSendTo,htmlfile,MailSubject)
+ </request>
+ </stafcmd>
+
+ <if expr="RC != 0">
+ <message log="1" level="'Error'">
+ 'Send test report failed. RC: %s STAFResult: %s' % (RC,STAFResult)
+ </message>
+ <else>
+ <message>
+ 'Send test report successful. RC: %s' % (RC)
+ </message>
+ </else>
+ </if>
+ </sequence>
+ </if>
+ </sequence>
+
+ </function>
+</stax>
--
Gitblit v1.10.0