2788N/A<?
xml version="1.0" encoding="UTF-8" standalone="no"?>
2788N/A ! The contents of this file are subject to the terms of the 2788N/A ! Common Development and Distribution License, Version 1.0 only 2788N/A ! (the "License"). You may not use this file except in compliance 2788N/A ! You can obtain a copy of the license at 2788N/A ! See the License for the specific language governing permissions 2788N/A ! and limitations under the License. 2788N/A ! When distributing Covered Code, include this CDDL HEADER in each 2788N/A ! file and include the License file at 2788N/A ! add the following below this CDDL HEADER, with the fields enclosed 2788N/A ! by brackets "[]" replaced with your own identifying information: 2788N/A ! Portions Copyright [yyyy] [name of copyright owner] 3215N/A ! Copyright 2007-2008 Sun Microsystems, Inc. 2788N/A This function checks a return code against an expected return code
2788N/A <
function-
arg-
def name="returncode" type="required">
2788N/A return code received from command
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="integer"/>
2788N/A <
function-
arg-
def name="result" type="required">
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="integer"/>
2788N/A <
function-
arg-
def name="expected" type="optional" default="0">
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="integer"/>
3194N/A <
if expr="expected == 'noCheck'">
2788N/A <
if expr="returncode == expected">
2788N/A 'RC=%s, Result=Ok' % (returncode)
2788N/A 'RC=%s, Result=%s' % (returncode,result)
2788N/A <
message log="1" level="'Error'">
2788N/A 'RC=%s, Expected %s, Result=%s' % (returncode,expected,result)
2788N/A <
function name="checktestRC">
2788N/A This function checks the return code against an expected return code for a testcase
2788N/A <
function-
arg-
def name="returncode" type="required">
2788N/A return code received from command
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="integer"/>
2788N/A <
function-
arg-
def name="result" type="required">
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="integer"/>
2788N/A <
function-
arg-
def name="expected" type="optional" default="0">
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="integer"/>
3951N/A <
function-
arg-
def name="issue" type="optional" default="None">
3951N/A Issue id. Corresponds to an issue number.
3951N/A </
function-
arg-
description>
3951N/A <
function-
arg-
property name="type" value="string"/>
3194N/A <
if expr="expected == 'noCheck'">
2788N/A <
if expr="returncode == expected">
2788N/A <
if expr="STAXCurrentTestcase != None">
3951N/A <
tcstatus result="'pass'"/>
3600N/A <
if expr="VERBOSE_MODE == 'True'">
3600N/A 'SUCCESS: RC=%s, Expected %s, Result=%s' % (returncode,expected,result)
3600N/A 'SUCCESS: RC=%s, Expected %s' % (returncode,expected)
2788N/A <
if expr="STAXCurrentTestcase != None">
3951N/A <
tcstatus result="'fail'"/>
3951N/A <
call function="'setKnownIssue'">
2788N/A <
message log="1" level="'Error'">
2788N/A 'ERROR : RC=%s, Expected %s, Result=%s' % (returncode,expected,result)
3951N/A <
function name="setKnownIssue">
3951N/A This function set the known issue flag and maintains list of known issues
3951N/A <
function-
arg-
def name="issueId" type="required">
3951N/A </
function-
arg-
description>
3951N/A <
function-
arg-
property name="type" value="string"/>
3962N/A if issueId not in issuesList:
3951N/A print 'Issues list undefined. Unable to add issue %s' % issueId
3951N/A <
message log="1" level="'Error'">
3951N/A 'ERROR: HIT **** Known Issue (%s) ****' % issueId
3951N/A 'KnownIssue: %s' % issuesList
2788N/A<!-- Set the test status to PASS --> 2788N/A <
function name="testPassed">
2788N/A This function set the status of the tests: PASS
2788N/A <
message>'Set test status to PASS'</
message>
2788N/A <
tcstatus result="'pass'"/>
2788N/A<!-- Set the test status to FAIL --> 2788N/A <
function name="testFailed">
2788N/A This function set the status of the tests: FAIL
2788N/A <
message>'Set test status to FAIL'</
message>
2788N/A <
tcstatus result="'fail'"/>
4238N/A <
function name="searchString" scope="local">
4238N/A This function search for a string in the retrun string of a testcase
4238N/A Return 0 if the string is found, 1 otherwise
4238N/A <
function-
arg-
def name="expectedString" type="required">
4238N/A the substring expected from the command
4238N/A </
function-
arg-
description>
4238N/A <
function-
arg-
property name="type" value="string"/>
4238N/A <
function-
arg-
def name="returnString" type="required">
4238N/A the return string received from command
4238N/A </
function-
arg-
description>
4238N/A <
function-
arg-
property name="type" value="string"/>
4238N/A <
function-
arg-
def name="knownIssue" type="optional" default="None">
4238N/A Known issue. Corresponds to an issue number.
4238N/A </
function-
arg-
description>
4238N/A <
function-
arg-
property name="type" value="string"/>
4238N/A <
function-
arg-
def name="expectedRC" type="optional" default="0">
4238N/A Expected return code value. Default value is 0.
4238N/A Wildcard 'noCheck' to not check the RC
4238N/A </
function-
arg-
description>
4238N/A <
function-
arg-
property name="type" value="string"/>
4238N/A <!-- Check that returnString is really a string --> 4238N/A <
message log="1" level="'Error'">
4238N/A <
return>[myRC, myReason]</
return>
4238N/A <!-- Search for the expectedString --> 4238N/A 'SUCCESS : Found substring, %s, in the return string' \
4238N/A <
message log="1" level="'Error'">
4238N/A 'ERROR : Did not find substring, %s, in the return string, %s' \
4238N/A % (expectedString, returnString)
4238N/A myReason = 'String not found'
4238N/A <!-- Manage expectedRC and knownIssue --> 4238N/A <
if expr="expectedRC != 'noCheck'">
4238N/A <
if expr="myRC == expectedRC">
4238N/A <
tcstatus result="'pass'"/>
4238N/A <
if expr="knownIssue == None">
4238N/A <
tcstatus result="'fail'"/>
4238N/A <
call function="'setKnownIssue'">
4238N/A <
return>[myRC, myReason]</
return>
4238N/A <!-- DEPRECATED, use searchString function --> 2788N/A <
function name="checktestString">
2788N/A This function checks the return string against an expected return substring for a testcase
2788N/A <
function-
arg-
def name="expectedString" type="required">
2788N/A the substring expected from the command
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="string"/>
2788N/A <
function-
arg-
def name="returnString" type="required">
2788N/A the return string received from command
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="string"/>
3951N/A <
function-
arg-
def name="issue" type="optional" default="None">
3951N/A Known issue. Corresponds to an issue number.
3951N/A </
function-
arg-
description>
3951N/A <
function-
arg-
property name="type" value="string" />
3973N/A <!-- Check that returnString is really a string --> 3973N/A <
message log="1" level="'Error'">
3973N/A <
tcstatus result="'fail'"/>
2788N/A <
tcstatus result="'pass'"/>
2788N/A 'SUCCESS : Found substring, %s, in the return string' % (expectedString)
3951N/A <
tcstatus result="'fail'"/>
3951N/A <
call function="'setKnownIssue'">
2788N/A <
message log="1" level="'Error'">
2788N/A 'ERROR : Did not find substring, %s, in the return string, %s' % (expectedString, returnString)
4238N/A <!-- DEPRECATED, use searchString function --> 2788N/A <
function name="checktestStringNotPresent">
2788N/A This function checks the return string against an expected return substring that should not be present for a testcase
2788N/A <
function-
arg-
def name="testString" type="required">
2788N/A the substring being tested from the command
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="string"/>
2788N/A <
function-
arg-
def name="returnString" type="required">
2788N/A the return string received from command
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="string"/>
3951N/A <
function-
arg-
def name="issue" type="optional" default="None">
3951N/A Known issue. Corresponds to an issue number.
3951N/A </
function-
arg-
description>
3951N/A <
function-
arg-
property name="type" value="string" />
2788N/A <
tcstatus result="'pass'"/>
2788N/A 'Did Not Find substring, %s, in the return string' % (testString)
3951N/A <
tcstatus result="'fail'"/>
3951N/A <
call function="'setKnownIssue'">
2788N/A <
message log="1" level="'Error'">
2788N/A 'Found substring, %s, in the return string, %s' % (testString, returnString)
4238N/A <!-- DEPRECATED, use searchString function --> 2788N/A <
function name="searchStringForSubstring">
2788N/A This function simply searches a string for a substring
2788N/A <
function-
arg-
def name="testString" type="required">
2788N/A the substring being tested from the command
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="string"/>
2788N/A <
function-
arg-
def name="returnString" type="required">
2788N/A the return string received from command
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="string"/>
2788N/A <
function-
arg-
def name="expectedResult" type="optional" default="'2'">
2788N/A the expected result, 0 for false (not present), 1 for true (present), 2 for old behavior
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="string"/>
2788N/A <!-- Until all the test cases are refactored to use the expectedResult param, 2788N/A we need this if-else conditional. --> 2788N/A <
if expr="expectedResult == '2'">
2788N/A <
script>returnCode='0'</
script>
2788N/A 'Did Not Find substring, %s, in the return string' % (testString)
2788N/A <
script>returnCode='1'</
script>
2788N/A 'Found substring, %s, in the return string' % (testString)
2788N/A <
return>returnCode</
return>
2788N/A <
script>returnCode='0'</
script>
2788N/A <
if expr="expectedResult == '0'">
2788N/A <
tcstatus result="'pass'"/>
2788N/A 'SUCCESS : Did Not Find substring, %s, in the return string' % (testString)
2788N/A <
tcstatus result="'fail'"/>
3847N/A <
message log="1" level="'Error'">
2788N/A 'ERROR : Did Not Find substring, %s, in the return string' % (testString)
2788N/A <
script>returnCode='1'</
script>
2788N/A <
if expr="expectedResult == '1'">
2788N/A <
tcstatus result="'pass'"/>
2788N/A 'SUCCESS : Found substring, %s, in the return string' % (testString)
2788N/A <
tcstatus result="'fail'"/>
3847N/A <
message log="1" level="'Error'">
2788N/A 'ERROR : Found substring, %s, in the return string' % (testString)
2788N/A <
return>returnCode</
return>
2788N/A <
function name="isAlive" scope="local">
2788N/A Checks that the ldap server is running
2788N/A <
function-
arg-
def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="hostname"/>
4153N/A <
function-
arg-
def name="dsPath" type="optional" default="'%s/%s' % (DIRECTORY_INSTANCE_BIN,OPENDSNAME)">
2788N/A Pathname to installation root
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="pathname"/>
2788N/A <
function-
arg-
def name="noOfLoops" type="required">
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="integer"/>
2788N/A <
function-
arg-
def name="noOfMilliSeconds" type="required">
2788N/A Number of seconds to wait between iterations
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="seconds"/>
2788N/A <
function-
arg-
def name="dsInstanceHost" type="optional" default="DIRECTORY_INSTANCE_HOST">
2788N/A Directory server hostname or IP address
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="hostname"/>
2788N/A <
function-
arg-
def name="dsInstancePort" type="optional" default="DIRECTORY_INSTANCE_PORT">
2788N/A Directory server port number
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="Port number"/>
2788N/A <
function-
arg-
def name="dsInstanceDn" type="optional" default="DIRECTORY_INSTANCE_DN">
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="DN"/>
2788N/A <
function-
arg-
def name="dsInstancePswd" type="optional" default="DIRECTORY_INSTANCE_PSWD">
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="string"/>
2788N/A <
script>ldapRC=9999</
script>
2788N/A <
loop from="1" to="noOfLoops" while="ldapRC != 0">
2788N/A <
call function="'SearchObject'">
2788N/A 'dsInstanceHost' : myhost ,
2788N/A 'dsInstancePort' : myport ,
2788N/A 'dsInstancePswd' : mypswd ,
2788N/A 'dsFilter' : 'objectclass=*' ,
2788N/A { 'sleepForMilliSeconds' : noOfMilliSeconds }
2788N/A Sleep for number of milliseconds
2788N/A <
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="hostname"/>
2788N/A <
function-
arg-
def name="sleepForMilliSeconds" type="required">
2788N/A Number of milliseconds to sleep
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="seconds"/>
2788N/A <
stafcmd name="'STAF Command: Delay'">
2788N/A <
location>'%s' % location</
location>
2788N/A 'delay %i' % sleepForMilliSeconds
2788N/A <
call function="'checkRC'">
3194N/A <
function name="getOSvariables">
2788N/A <
function-
arg-
def name="hostname" type="required">
2788N/A Name of host on which to retrieve variables
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="hostname"/>
2788N/A <
stafcmd name="'STAF Command: Get OS Name'">
2788N/A <
location>'%s' % hostname</
location>
2788N/A <
return>STAFResult</
return>
2788N/A <
function name="testCase_StartBanner">
2788N/A Pretty prints a banner at the start of a test.
2788N/A <
message level="'start'">'testcase: %s' % STAXCurrentTestcase</
message>
2788N/A <
message>'****************************************************'</
message>
2788N/A <
message>'*** STARTING TEST CASE %s.' % STAXCurrentTestcase</
message>
2788N/A <
function name="testCase_EndBanner">
2788N/A Pretty prints a banner at the end of a test.
2788N/A <
message>'*** ENDING TEST CASE %s.' % STAXCurrentTestcase</
message>
2788N/A <
message>'****************************************************'</
message>
2788N/A <
message level="'stop'">'testcase: %s' % STAXCurrentTestcase</
message>
2788N/A <
function name="testCase_Preamble">
2788N/A Performs all the preoperations for a test case
2788N/A testcaseStartTime=strftime("%Y%m%d@%H:%M:%S",localtime())
2788N/A for logType in ['errors','access']:
2788N/A logfile=open('%s/%
s/
logs/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME,logType),'a')
2788N/A <
call function="'testCase_StartBanner'" />
2788N/A <
function name="testCase_Postamble">
2788N/A Performs all the post operations for a test suite
2788N/A <!-- Check the SignalRaised flag --> 2788N/A 'A signal (%s) was raised during this test case' % SignalRaised
2788N/A <
tcstatus result="'fail'"/>
2788N/A <!-- Reset the SignalRaised flag --> 2788N/A <!-- Query the test case results --> 2788N/A <
call function="'queryTestcase'" />
2788N/A numPass=int(STAFResult['numPasses'])
2788N/A numFail=int(STAFResult['numFails'])
2788N/A _status='KNOWN ISSUES %s' % str(issuesList)
2788N/A <
message level="'status'">'## Test Verdict: %s ##' % _status</
message>
2788N/A <
call function="'testCase_EndBanner'" />
2788N/A testcaseEndTime = strftime("%Y%m%d@%H:%M:%S",localtime())
2788N/A <
call function="'queryLogs'">
2788N/A { 'location' : STAXServiceMachine,
2788N/A 'logname' : 'STAX_Job_%s_User' % STAXJobID,
2788N/A 'startfrom' : testcaseStartTime,
2788N/A 'endat' : testcaseEndTime }
2788N/A def __init__(self, group, suite, fullname, start, stop, failures, successes, issues, duration):
2788N/A xml = ' <test>%s' % newLine
2788N/A xml += ' <issues>%s' % newLine
2788N/A xml += ' <issue>%s</issue>%s' % (issue,newLine)
2788N/A xml += ' </issues>%s' % newLine
2788N/A xml += ' <log>%s' % newLine
2788N/A xml += ' <![CDATA[%s' % newLine
2788N/A xml += ' ]]>%s' % newLine
2788N/A xml += ' </log>%s' % newLine
2788N/A xml += ' <error>%s' % newLine
2788N/A xml += ' <![CDATA[%s' % newLine
2788N/A xml += ' ]]>%s' % newLine
2788N/A xml += ' </error>%s' % newLine
2788N/A xml += ' <access>%s' % newLine
2788N/A xml += ' <![CDATA[%s' % newLine
2788N/A xml += ' ]]>%s' % newLine
2788N/A xml += ' </access>%s' % newLine
2788N/A xml += ' </test>%s' % newLine
2788N/A def appendLog(self, category, log):
2788N/A wrappedLog+='%s%s%s' % (_leftPadding,_logChunk,newLine)
2788N/A wrappedLog += '%s%s%s' % (_leftPadding,_line,newLine)
2788N/A testcaseDuration=testcaseStop-testcaseStart
2788N/A thisTest = Test(CurrentTestPath['group'],CurrentTestPath['suite'],STAXCurrentTestcase, testcaseStartTime,testcaseEndTime,numFail,numPass,issuesList,testcaseDuration)
2788N/A # loop through the log lines
2788N/A # this test is BEFORE the append so we don't get the
2788N/A # end of testcase banner in the XML but only the relevant data
2788N/A # if the current element is actually this test's output then log it
2788N/A # this test is AFTER the append log so we don't get the
2788N/A # "starting testcase ..." header in the XML
2788N/A tmp = element['message'].split(':')
2788N/A # this is a verification that we start logging for the right
2788N/A # test case. this is especially useful for tests that execute
2788N/A # within the same second (that is the resolution of the STAF
2788N/A # parse the server's error log
2788N/A # TODO: figure out how to do this for multiple instance for the replication
2788N/A for logType in ['errors','access']:
2788N/A logfile=open('%s/%
s/
logs/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME,logType),'a')
2788N/A logfile=open('%s/%
s/
logs/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME,logType), 'r')
2788N/A # clean the temporary log files for this test
2788N/A # this MUST be done AFTER the call to toXML or the logs will appear empty
2788N/A <
message>'%s' % _message</
message>
2788N/A <
function name="testSuite_Preamble">
2788N/A Performs all the pre operations for a test suite
2788N/A <!-- Take the values from the current test path --> 2788N/A CurrentTestPath['group']='unknown-group'
2788N/A CurrentTestPath['suite']='unknown-suite'
2788N/A ThisGroupName=CurrentTestPath['group']
2788N/A ThisSuiteName=CurrentTestPath['suite']
2788N/A <!-- Start time of test suite --> 2788N/A TestSuiteStartTime=strftime("%Y%m%d@%H:%M:%S",localtime())
2788N/A '#### %s/%s suite preamble ####' % (ThisGroupName,ThisSuiteName)
2788N/A <
function name="testSuite_Postamble">
2788N/A Performs all the post operations for a test suite
2788N/A <!-- Take the values from the current test path --> 2788N/A ThisSuiteName=CurrentTestPath['suite']
2788N/A ThisSuiteName='unknown-suite'
2788N/A ThisGroupName=CurrentTestPath['group']
2788N/A ThisGroupName='unknown-group'
2788N/A '#### %s/%s suite postamble ####' % (ThisGroupName,ThisSuiteName)
2788N/A <!-- Start time of test suite --> 2788N/A TestSuiteEndTime=strftime("%Y%m%d@%H:%M:%S",localtime())
2788N/A <!-- Format the test group and suite names to create folder --> 2788N/A FormattedTestcase=format_testcase()
3855N/A TestLogFile='%s/%s' % (TestLogDir,FormattedTestsuite)
2788N/A <
call function="'WriteLogsForTestCase'">
2788N/A { 'starttime' : TestSuiteStartTime,
2788N/A 'endtime' : TestSuiteEndTime,
2788N/A del CurrentTestPath['suite']
2788N/A <
function name="testGroup_Preamble">
2788N/A Performs all the pre operations for a test group
2788N/A <!-- Take the values from the current test path --> 2788N/A CurrentTestPath['group']='unknown-group'
2788N/A ThisGroupName=CurrentTestPath['group']
2788N/A # the reason for that is that the topology is created AFTER the
2788N/A # first test group has started (as part of the first setup)
2788N/A # the following groups are going to use the same topology
3816N/A mylog="::coverage - checking for %s/%
s/
lib/
emma.jar\n" % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)
2788N/A mylog+=" ::mkdir %
s/
coverage/%s on\n" % (TMPDIR,CurrentTestPath['group'])
2788N/A <
message>'##### %s group preamble #####' % ThisGroupName</
message>
2788N/A <
function name="testGroup_Postamble">
2788N/A Performs all the post operations for a test group
2788N/A ThisGroupName=CurrentTestPath['group']
2788N/A ThisGroupName='unknown-group'
2788N/A <
message>'##### %s group postamble #####' % ThisGroupName</
message>
2788N/A <
call function="'runCommand'">
2788N/A { 'name' : 'Generate coverage xml report for test group %s' % CurrentTestPath['group'],
2788N/A del CurrentTestPath['group']
3855N/A <
function name="WriteLogsForTestCase" scope="local">
2788N/A Queries the staf logs for the test case and write to file as text
2788N/A <
function-
arg-
def name="starttime" type="required">
2788N/A timestamp to start logging from
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="timestamp"/>
2788N/A <
function-
arg-
def name="endtime" type="required">
2788N/A timestamp to start logging to
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="timestamp"/>
3855N/A <
function-
arg-
def name="logFile" type="required">
2788N/A name of file to write the logs
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="filepath"/>
3855N/A <!-- Query STAF to obtain the logs for the test case --> 2788N/A <
call function="'queryLogs'">
2788N/A { 'location' : STAXServiceMachine,
2788N/A 'logname' : 'STAX_Job_%s_User' % STAXJobID,
3855N/A <!-- Write out the logs into an XML file --> 3855N/A <
call function="'WriteXmlLogs'">
2788N/A { 'queryresult' : STAFResult,
3855N/A <!-- Transform the XML file into an HTML file --> 3855N/A <
call function="'WriteHtmlLogs'">
3855N/A <
function name="WriteXmlLogs" scope="local">
2788N/A Process staf log query results and write them to a file
2788N/A <
function-
arg-
def name="queryresult" type="required">
2788N/A result of the staf log query
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="string"/>
3855N/A <
function-
arg-
def name="output" type="required">
3855N/A name of the XML file to where results are written
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="string"/>
3855N/A <
message>'Creating XML log file %s' % logFile</
message>
2788N/A <
call function="'createFolder'">
2788N/A { 'location' : STAXServiceMachine,
3855N/A # Create the qa base element
3870N/A # Try to pass only the pretty print of the test suite name
3870N/A suite=CurrentTestPath['suite'].split('.')[2].strip()
3870N/A formattedTestcase = format_testcase()
2956N/A <
if expr="queryresult == '[]'">
2956N/A output1 = 'queryresult is empty'
2956N/A output2 = 'check the date between the OS, the logs'
2956N/A output3 = 'and the local time zone'
2956N/A output = '%s %s %s' % (output1,output2,output3)
2956N/A <
call function="'checktestRC'">
2956N/A <
iterate var="element" in="queryresult">
2956N/A timestamp=element['timestamp']
3855N/A _message='Generated XML test case report.'
3855N/A testlogfh=open('%s' % logFile,'w')
3855N/A except AttributeError,details:
3855N/A _message='Unable to generate XML test case report %s.' % details
3855N/A _message='Unable to generate XML test case report !!!'
3855N/A <
message>_message</
message>
3855N/A <
function name="WriteHtmlLogs" scope="local">
3862N/A Process XML file and transform that to an HTML log file
3855N/A <
function-
arg-
def name="input" type="required">
3855N/A name of the XML file to where results are obtained
3855N/A </
function-
arg-
description>
3855N/A <
function-
arg-
property name="type" value="string"/>
3855N/A <
function-
arg-
def name="output" type="required">
3855N/A name of the HTML file to where results are written
3855N/A </
function-
arg-
description>
3855N/A <
function-
arg-
property name="type" value="string"/>
3855N/A <
function-
arg-
def name="stylesheet" type="required">
3855N/A name of the XSL stylesheet used to transform results
3855N/A </
function-
arg-
description>
3855N/A <
function-
arg-
property name="type" value="string"/>
3855N/A <
message>'Inputting XML file %s' % xmlFile</
message>
3855N/A <
message>'Transform XSL file %s' % xslFile</
message>
3855N/A <
message>'Creating HTML file %s' % htmlFile</
message>
3862N/A _message='Generated test case logs.'
3862N/A testCaseLogs=report_generation()
3862N/A _message='Unable to generate test case logs %s.' % details
3862N/A _message='Unable to generate test case logs %s.' % details
3862N/A _message='Unable to generate test case logs !!!'
3855N/A <
message>'%s' % _message</
message>
2788N/A <
function name="CheckMatches">
2788N/A check the number of matching sub-string in a string
2788N/A <
function-
arg-
def name="string2find" type="required">
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="string"/>
2788N/A <
function-
arg-
def name="mainString" type="required">
2788N/A the main string where the search is done
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="string"/>
2957N/A <
function-
arg-
def name="caseSensitive" type="optional" default="True">
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="string"/>
2788N/A <
function-
arg-
def name="nbExpected" type="optional" default="1">
2788N/A number of expected sub-string that must be in the main string
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="integer"/>
2788N/A caseSensitiveInfo = '[case sensitive mode]'
2788N/A caseSensitiveInfo = '[case insensitive mode]'
2788N/A myMessage = 'SUCCESS : %s matches %s time(s) (expected %s) %s' % (string2find,nbFound,nbExpected,caseSensitiveInfo)
2788N/A myMessage = 'ERROR : %s matches %s time(s) (expected %s) in "%s" %s' % (string2find,nbFound,nbExpected,mainString,caseSensitiveInfo)
2788N/A <
tcstatus result="'pass'"/>
2788N/A <
tcstatus result="'fail'"/>
2788N/A <
message log="1" level="'Error'">
2788N/A <
return>myRC,myMessage</
return>
3973N/A <
function name="runFunction" scope="local">
2788N/A <
function-
arg-
def name="functionName" type="required">
2788N/A Name of the function to run
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
def name="functionArguments" type="optional">
2788N/A Arguments to be passed on to the called function.
2788N/A This can be a map or a list of arguments, whatever the called function
2788N/A expects will be carried on here.
2788N/A . for a map, pass the arguments like this:
2788N/A { 'argumentA' : 'argumentAvalue' ,
2788N/A . for a list, pass the arguments like this:
2788N/A [ 'argumentAvalue, 1, ... ]
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
def name="expectedRC" type="optional" default="0">
2788N/A The expected return code of the function to run.
2788N/A This is then passed onto the checkRC function.
2788N/A It is also used to throw an exception if the argument
2788N/A functionException is provided and set the test case status if the
2788N/A argument functionSetsTCStatus is provided
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="integer"/>
2788N/A <
function-
arg-
def name="functionException" type="optional">
2788N/A The exception to throw if the return code differs from the expected
2788N/A RC. The exception is appended to STAXException.
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
def name="functionMessage" type="optional">
2788N/A An optional message to display before running the function
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
def name="functionSetsTCStatus" type="optional">
2788N/A Whether the function to run sets the testcase status or not.
2788N/A If this is set, the test case status is set according to whether
2788N/A or not the function meets the expected return code.
2788N/A True or False should be used for this argument.
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
def name="functionFailureTC" type="optional">
2788N/A If this argument is provided, a testcase will be created with
2788N/A this argument's value for name and set to fail only upon failure
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
def name="functionSignal" type="optional">
2788N/A If this argument is provided, a signal will be raised upon unsuccesful
2788N/A execution of the function to run
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
def name="functionCallBack" type="optional">
2788N/A If this argument is provided then functionCallBack will be called
2788N/A after the execution of function name.
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
def name="functionCallBackArguments" type="optional">
2788N/A This allows to specify arguments for the call back function
2788N/A </
function-
arg-
description>
2788N/A <!-- defining the booleans here should temporary while I find a nicer 2788N/A solution. We have a chicken and egg problem between the 2788N/A loadGlobalEnvironment and loadSharedLibraries functions in 3973N/A _expectedRC=int(expectedRC)
3973N/A <
message log="1" level="'info'" if="_displayMessage == True">
3973N/A <
message log="1" level="'debug'">
3973N/A 'runFunction: %s: called with parameters [%s]' % (functionName,functionArguments)
2788N/A <
call function="functionName">functionArguments</
call>
3973N/A _functionResult = STAXResult
3973N/A <
message log="1" level="'debug'">
3973N/A 'runFunction: %s: returned [%s] with [%s]' % (functionName,RC,STAXResult)
2788N/A <!-- this section handles the optional case when we need to set the 2788N/A <
if expr="_doSetTCStatus == True">
3973N/A <
if expr="_functionRC == _expectedRC">
2788N/A <
script>_tcStatus='pass'</
script>
2788N/A <
tcstatus result="_tcStatus" />
2788N/A <!-- this section handles the optional case when we need to throw an 2788N/A exception upon unexpected function return code 2788N/A <
if expr="_throwException == True" >
3973N/A <
if expr="_functionRC != _expectedRC" >
2788N/A <
throw exception="'STAXException.%s' % functionException" />
2788N/A <!-- this section handles the optional case when we need to set a 2788N/A test case status to fail to reflect the failure in the test report. 2788N/A <
if expr="_createFailureTC == True" >
3973N/A <
if expr="_functionRC != _expectedRC" >
2788N/A <
testcase name="'!!! %s [%s]' % (functionFailureTC,functionName)">
2788N/A <
tcstatus result="'fail'" />
2788N/A <!-- TODO: implement the signal raising mechanism --> 2788N/A <!-- TODO: implement the call back function mechanism --> 3973N/A <!-- bubble the function return code and result up one level --> 3973N/A <
return>[_functionRC,_functionResult]</
return>
2788N/A <
function name="runCommand" >
2788N/A A general wrapper to run a command without having to write a dedicated
2788N/A <
function-
arg-
def name="command" type="required">
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
def name="path" type="optional" default="dsBinPath">
2788N/A the path where the command is to be run from
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
def name="arguments" type="optional" default="''">
2788N/A the path where the command is to be found
2788N/A </
function-
arg-
description>
3949N/A <
function-
arg-
def name="envCmd" 2788N/A the environment variables to set. The default set here should just
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
def name="location" 2788N/A default="STAXServiceMachine">
2788N/A Which machine should the command be executed on
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
def name="name" 2788N/A default="'Running %s' % command" 2788N/A The name to give the process (only matters in the STAX Monitor really)
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
def name="stripOutput" default="True" type="optional">
2788N/A A boolean (use True or False here, case matters) to enable disable
2788N/A stripping the output of a command
2788N/A TODO: consider allowing passing a function name to enable custom
2788N/A output manipulation (overkill?)
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="enum">
2788N/A <
function-
arg-
property-
description>
2788N/A This argument can only have boolean values
2788N/A </
function-
arg-
property-
description>
2788N/A <
function-
arg-
property-
data type="choice" value="True"/>
2788N/A <
function-
arg-
property-
data type="choice" value="False"/>
2788N/A <
function-
arg-
def name="timerDuration" 2788N/A The duration that the process is allowed to run
2788N/A </
function-
arg-
description>
3847N/A <
function-
arg-
def name="inputFile" type="optional" default="'None'">
3847N/A input file containing the command input
3847N/A </
function-
arg-
description>
3847N/A <
function-
arg-
property name="type" value="file"/>
3287N/A <
function-
arg-
def name="outputFile" type="optional" default="'None'">
3287N/A Output file containing the command output
3287N/A </
function-
arg-
description>
3287N/A <
function-
arg-
property name="type" value="file"/>
3194N/A <
function-
arg-
def name="expectedRC" type="optional" default="0">
3194N/A Expected return code value. Default value is 0.
3194N/A Wildcard 'noCheck' to not check the RC
2949N/A </
function-
arg-
description>
3951N/A <
function-
arg-
def name="knownIssue" type="optional" default="None">
3951N/A Known issue. Corresponds to an issue number.
3951N/A </
function-
arg-
description>
3315N/A <
function-
arg-
def name="logStderr" type="optional" default="True">
3315N/A If true, stderr for the command is redirect to stdout.
3315N/A </
function-
arg-
description>
3315N/A <
function-
arg-
property name="type" value="enum">
3315N/A <
function-
arg-
property-
description>
3315N/A This argument can only have boolean values
3315N/A </
function-
arg-
property-
description>
3315N/A <
function-
arg-
property-
data type="choice" value="True"/>
3315N/A <
function-
arg-
property-
data type="choice" value="False"/>
3949N/A if is_windows_platform(location):
2788N/A '%s: Running command:\n %s %s\nlocation: %s\nenv: %s\nworkdir: %s' % (_id,command,arguments,location,env,path)
3315N/A <!-- If 'logStderr' is True then redirect sdterr to sdtout --> 3315N/A <
if expr="logStderr == True">
3315N/A <
location>location</
location>
3600N/A <
stdout if="outputFile != 'None'" mode="'replace'">'%s' % outputFile</
stdout>
3847N/A <
elseif expr="inputFile != 'None'">
3847N/A <
location>location</
location>
3847N/A <
stdin>'%s' % inputFile</
stdin>
3847N/A <
location>location</
location>
3847N/A <
stdout if="outputFile != 'None'" mode="'replace'">'%s' % outputFile</
stdout>
3322N/A <!-- The problem here is that STAXResult can either be a 3322N/A string, list or a map object --> 3194N/A <
if expr="expectedRC != 'noCheck'">
3194N/A <
call function="'checktestRC'">
2788N/A if var.__class__==[].__class__:
2788N/A if var.__class__==''.__class__:
2788N/A return 'could not evaluate the following component: %s' % var
2913N/A <
function-
arg-
def name="location" 2913N/A default="STAF_REMOTE_HOSTNAME">
3269N/A </
function-
arg-
description>
3269N/A <
function-
arg-
property name="type" value="hostname"/>
2913N/A <
function-
arg-
def name="dsPath" 2913N/A % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
2788N/A Pathname to installation root
2788N/A </
function-
arg-
description>
2788N/A <
function-
arg-
property name="type" value="pathname"/>
2788N/A 'Kill server running on %s at %s' % (location, dsPath)
2913N/A <
call function="'runSTAFCommand'">
2913N/A { 'name' : 'Read server pid file',
3621N/A if is_windows_platform(location):
2788N/A <
call function="'runCommand'">
2788N/A { 'name' : 'Kill DS server',
2788N/A <
return>STAXResult</
return>
2858N/A <
function name="runSTAFCommand" >
2858N/A A general wrapper to run a STAF command without having to write a
2858N/A <
function-
arg-
def name="location" type="optional" default="STAXServiceMachine">
2858N/A Which machine should the command be executed on
2858N/A </
function-
arg-
description>
2858N/A <
function-
arg-
def name="name" type="required">
2858N/A The name to give the process
2858N/A </
function-
arg-
description>
2858N/A <
function-
arg-
def name="service" type="required">
2858N/A </
function-
arg-
description>
2858N/A <
function-
arg-
def name="request" type="required">
2858N/A </
function-
arg-
description>
2858N/A <
function-
arg-
def name="arguments" type="optional" default="''">
2858N/A the arguments for the service request
2858N/A </
function-
arg-
description>
2858N/A '%s: Running STAF command:\n %s %s %s\nlocation: %s\n' % (_id,service,request,arguments,location)
2858N/A <
block name="'%s:Wrapper for %s' % (_id,name)">
2858N/A <
stafcmd name="'STAF Command: %s' % name">
2858N/A <
location>'%s' % location</
location>
2858N/A '%s %s' % (request,arguments)
2858N/A '%s: STAF Command returned:\n%s' % (_id,STAFResult)
3269N/A This function search for a given string in a given file.
3269N/A BEWARE! of potential performance degradation when grepping big files due
3269N/A to the use of getFile, which loads the whole file content into a variable.
3269N/A <
function-
arg-
def name="location" 3269N/A default="STAF_REMOTE_HOSTNAME">
3269N/A </
function-
arg-
description>
3269N/A <
function-
arg-
property name="type" value="hostname"/>
3269N/A <
function-
arg-
def name="filename" type="required">
3269N/A </
function-
arg-
description>
3269N/A <
function-
arg-
property name="type" value="pathname"/>
3269N/A <
function-
arg-
def name="testString" type="required">
3269N/A </
function-
arg-
description>
3269N/A <
function-
arg-
property name="type" value="string"/>
3269N/A <
function-
arg-
def name="expectedRC" type="optional" default="0">
3269N/A Expected return code value.
3269N/A 0 for successful grep, 1 for unsuccessful grep. Default value is 0.
3269N/A Wildcard 'noCheck' to not check the RC
3269N/A </
function-
arg-
description>
3269N/A 'Search for string \"%s\" in file %s on host %s' % \
3269N/A (testString, filename, location)
3269N/A <
call function="'getFile'">
3269N/A # getFile returns: STAXResult = [cmdRC, cmdResult]
3269N/A filecontent = STAXResult[1]
3269N/A if (expectedRC == 'noCheck'):
3269N/A # don't care about expected result
3269N/A # expect testString to be present in filecontent
3269N/A # expect testString not to be present in filecontent
3269N/A <
call function="'searchStringForSubstring'">
3269N/A 'returnString' : filecontent,
3269N/A 'expectedResult' : myExpectedResult
3269N/A <
return>STAXResult</
return>
3287N/A <
function name="compareFile">
3287N/A This function compares two files.
3287N/A Print the differences if the comparison failed.
3287N/A <
function-
arg-
def name="location" 3287N/A default="STAXServiceMachine">
3287N/A </
function-
arg-
description>
3287N/A <
function-
arg-
property name="type" value="hostname"/>
3287N/A <
function-
arg-
def name="remotehost" 3287N/A default="STAF_REMOTE_HOSTNAME">
3287N/A </
function-
arg-
description>
3287N/A <
function-
arg-
property name="type" value="hostname"/>
3287N/A <
function-
arg-
def name="dsPath" 4153N/A default="'%s/%s' % (DIRECTORY_INSTANCE_BIN,OPENDSNAME)">
3287N/A Pathname to installation root
3287N/A </
function-
arg-
description>
3287N/A <
function-
arg-
property name="type" value="hostname"/>
3287N/A <
function-
arg-
def name="outputFile" type="required">
3287N/A file containing output from the command
3287N/A </
function-
arg-
description>
3287N/A <
function-
arg-
property name="type" value="file"/>
3287N/A <
function-
arg-
def name="outputPath" type="optional">
3287N/A </
function-
arg-
description>
3287N/A <
function-
arg-
property name="type" value="filepath"/>
3287N/A <
function-
arg-
def name="refFile" type="optional">
3287N/A reference file containing expected output
3287N/A </
function-
arg-
description>
3287N/A <
function-
arg-
property name="type" value="file"/>
3287N/A <
function-
arg-
def name="refPath" type="optional">
3287N/A reference path containing refFile
3287N/A </
function-
arg-
description>
3287N/A <
function-
arg-
property name="type" value="filepath"/>
3287N/A <
function-
arg-
def name="diffFile" type="optional">
3287N/A file containing diff output
3287N/A </
function-
arg-
description>
3287N/A <
function-
arg-
property name="type" value="file"/>
3287N/A <
function-
arg-
def name="diffPath" type="optional">
3287N/A </
function-
arg-
description>
3287N/A <
function-
arg-
property name="type" value="filepath"/>
3951N/A <
function-
arg-
def name="knownIssue" type="optional" default="None">
3951N/A Known issue. Corresponds to an issue number.
3951N/A </
function-
arg-
description>
3951N/A <
function-
arg-
property name="type" value="string" />
3287N/A ThisGroupName = CurrentTestPath['group']
3287N/A ThisGroupName = 'unknown-group'
3287N/A FormattedTestcase = format_testcase()
3287N/A outputPath = '%s/..' % (dsPath)
3287N/A <!-- Check if 'diffPath' is already created --> 3287N/A <
call function="'GetEntry'">
3287N/A <!-- If 'diffPath' is not already created then create it --> 3287N/A 'Create folder %s' % diffPath
3287N/A <
call function="'createFolder'">
3287N/A 'Copy file %s/%s (on %s) to %s/%s (on %s)' % \
3287N/A (outputPath, outputFile, cfremotehost, diffPath, outputFile, cflocation)
3287N/A <
call function="'copyFile'">
3287N/A 'location' : cfremotehost ,
3287N/A 'srcfile' : '%s/%s' % (outputPath, outputFile) ,
3287N/A 'destfile' : '%s/%s' % (diffPath, outputFile) ,
3287N/A 'Copy file %s/%s (on %s) to %s/%s (on %s)' % \
3287N/A (refPath, refFile, cflocation, diffPath, refFile, cflocation)
3287N/A <
call function="'copyFile'">
3287N/A 'srcfile' : '%s/%s' % (refPath, refFile) ,
3287N/A 'destfile' : '%s/%s' % (diffPath, refFile) ,
3287N/A <!-- If the copy of 'outputFile' and 'refFile' succeed 3287N/A then compare these files --> 3287N/A <
if expr="outputRC == 0 and refRC == 0">
3287N/A 'Compare file %s/%s to %s/%s on %s' % \
3287N/A (diffPath, outputFile, diffPath, refFile, cflocation)
3287N/A CompareFile = compare_file('%s/%s' % (diffPath, outputFile),
3287N/A '%s/%s' % (diffPath, refFile),
3287N/A '%s/%s' % (diffPath, diffFile))
3287N/A <
tcstatus result="'pass'"/>
3287N/A 'SUCCESS : No differences were found between %s and %s' % \
3951N/A <
if expr="knownIssue == None">
3951N/A <
tcstatus result="'fail'"/>
3951N/A <
call function="'setKnownIssue'">
3287N/A 'ERROR : Differences were found between %s and %s\n%s' % \
3287N/A (outputFile, refFile, diff)
3287N/A 'ERROR : Diff file is here: %s/%s' % (diffPath, diffFile)
3287N/A <
tcstatus result="'fail'"/>
3287N/A 'ERROR : Error during file comparision'
3600N/A <
function name="compileJava" scope="local">
3600N/A This function compile java files.
3600N/A <
function-
arg-
def name="location" 3600N/A default="STAXServiceMachine">
3600N/A </
function-
arg-
description>
3600N/A <
function-
arg-
property name="type" value="hostname"/>
3600N/A <
function-
arg-
def name="foldername" type="required">
3600N/A Path containing java files to compile
3600N/A </
function-
arg-
description>
3600N/A <
function-
arg-
property name="type" value="filepath"/>
3600N/A <
function-
arg-
def name="classpath" type="optional">
3600N/A </
function-
arg-
description>
3600N/A <
function-
arg-
property name="type" value="string"/>
3600N/A <
function-
arg-
def name="expectedRC" type="optional" default="0">
3600N/A Expected return code value.
3600N/A 0 for successful grep, 1 for unsuccessful grep. Default value is 0.
3600N/A Wildcard 'noCheck' to not check the RC
3600N/A </
function-
arg-
description>
3643N/A if is_windows_platform(location):
3643N/A cp = 'CLASSPATH=%s%s.' % (classpath, separator)
3600N/A if location == STAXServiceMachine:
3600N/A env = ['JAVA_HOME=%s' % JAVA_HOME, '%s' % cp]
3600N/A <
call function="'listFolderByExtension'" >
3600N/A 'foldername' : foldername ,
3600N/A <
if expr="cmdResult != 'Folder does not exist.'">
3600N/A <
call function="'runCommand'" >
3600N/A 'name' : 'Compile Java files' ,
3600N/A 'arguments' : '-target 1.5 %s' % list ,
3600N/A <
tcstatus result="'fail'"></
tcstatus>
3549N/A <
function name="getFreePort" scope="local">
3549N/A Returns the first free TCP port greater or equal to given number
3600N/A <
function-
arg-
def name="host" 3600N/A default="STAXServiceMachine">
3549N/A Which machine to look for the free port
3549N/A </
function-
arg-
description>
3549N/A <
function-
arg-
def name="port" type="required">
3549N/A The minimal port number to be returned
3549N/A </
function-
arg-
description>
3549N/A # returns first free port in [port; port+5]
3549N/A # if no free port in this interval, return -1
3613N/A <
function name="checkFileExists" scope="local">
3613N/A Set testcase result to FAIL if file (as param) does not exist
3949N/A <
function-
arg-
def name="location" 3949N/A default="STAXServiceMachine">
3949N/A </
function-
arg-
description>
3949N/A <
function-
arg-
property name="type" value="hostname"/>
3613N/A <
function-
arg-
def name="file" type="required">
3613N/A The file to check existence
3613N/A </
function-
arg-
description>
3949N/A <
call function="'GetEntry'">
3949N/A 'location' : STAF_REMOTE_HOSTNAME ,
3949N/A <
tcstatus result="'fail'"/>
3949N/A <
message log="1" level="'Error'">
3949N/A 'ERROR : File %s does not exist' % file
3613N/A <
function name="checkFileNotExists" scope="local">
3613N/A Set testcase result to FAIL if file (as param) exists
3949N/A <
function-
arg-
def name="location" 3949N/A default="STAXServiceMachine">
3949N/A </
function-
arg-
description>
3949N/A <
function-
arg-
property name="type" value="hostname"/>
3613N/A <
function-
arg-
def name="file" type="required">
3613N/A </
function-
arg-
description>
3949N/A <
call function="'GetEntry'">
3949N/A 'location' : STAF_REMOTE_HOSTNAME ,
3949N/A <
tcstatus result="'fail'"/>
3949N/A <
message log="1" level="'Error'">
3949N/A 'ERROR : File %s does not exist' % file