This function checks a return code against an expected return code return code received from command the output of the result the expected return code 'RC=%s, Result=Ok' % (returncode) 'RC=%s, Result=%s' % (returncode,result) 'RC=%s, Expected %s, Result=%s' % (returncode,expected,result) RC This function checks the return code against an expected return code for a testcase return code received from command the output of the result the expected return code Issue id. Corresponds to an issue number. 'SUCCESS: RC=%s, Expected %s, Result=%s' % (returncode,expected,result) 'SUCCESS: RC=%s, Expected %s' % (returncode,expected) { 'issueId' : issue } 'ERROR : RC=%s, Expected %s, Result=%s' % (returncode,expected,result) This function set the known issue flag and maintains list of known issues Issue ID { 'location' : STAF_REMOTE_HOSTNAME, 'type' : 'shared', 'variable' : 'issuesList' } 'ERROR: HIT **** Known Issue (%s) ****' % issueId 'KnownIssue: %s' % issuesList { 'location' : STAF_REMOTE_HOSTNAME, 'type' : 'shared', 'variable' : 'issuesList=%s' % issuesList } This function set the status of the tests: PASS 'Set test status to PASS' This function set the status of the tests: FAIL 'Set test status to FAIL' This function search for a string in the retrun string of a testcase Return 0 if the string is found, 1 otherwise the substring expected from the command the return string received from command the type of the search: substring, exact-case-insensitive or exact-case-sensitive Known issue. Corresponds to an issue number. Expected return code value. Default value is 0. Wildcard 'noCheck' to not check the RC 'ERROR : Invalid returnString type (%s), requires org.python.core.PyString.' \ % returnString.__class__ [myRC, myReason] 'Search type: %s Found substring, %s, in the return string' \ % (searchType, expectedString) 'Search type: %s Did not find substring, %s, in the return \ string, %s' % (searchType, expectedString, returnString) 'SUCCESS: searchString successful' 'ERROR: searchString fail' { 'issueId' : knownIssue } [myRC, myReason] This function checks the return string against an expected return substring for a testcase the substring expected from the command the return string received from command Known issue. Corresponds to an issue number. 'ERROR : Invalid returnString type (%s), requires org.python.core.PyString.' % returnString.__class__ 'SUCCESS : Found substring, %s, in the return string' % (expectedString) { 'issueId' : issue } 'ERROR : Did not find substring, %s, in the return string, %s' % (expectedString, returnString) This function checks the return string against an expected return substring that should not be present for a testcase the substring being tested from the command the return string received from command Known issue. Corresponds to an issue number. 'Did Not Find substring, %s, in the return string' % (testString) { 'issueId' : issue } 'Found substring, %s, in the return string, %s' % (testString, returnString) This function simply searches a string for a substring the substring being tested from the command the return string received from command the expected result, 0 for false (not present), 1 for true (present), 2 for old behavior 'Did Not Find substring, %s, in the return string' % (testString) 'Found substring, %s, in the return string' % (testString) returnCode 'SUCCESS : Did Not Find substring, %s, in the return string' % (testString) 'ERROR : Did Not Find substring, %s, in the return string' % (testString) 'SUCCESS : Found substring, %s, in the return string' % (testString) 'ERROR : Found substring, %s, in the return string' % (testString) returnCode Checks that the ldap server is running Location of target host Pathname to installation root Number of iterations Number of seconds to wait between iterations Directory server hostname or IP address Directory server port number Bind DN Bind password { 'location' : mylocation, 'dsPath' : mypath, 'dsInstanceHost' : myhost , 'dsInstancePort' : myport , 'dsInstanceDn' : mydn , 'dsInstancePswd' : mypswd , 'dsScope' : 'base' , 'dsBaseDN' : 'cn=config' , 'dsFilter' : 'objectclass=*' , 'attributes' : 'dn', 'expectedRC' : 'noCheck' } 'LOOP %s => RC=%s' % (myLoop, ldapRC) { 'sleepForMilliSeconds' : noOfMilliSeconds } { 'returncode' : ldapRC , 'result' : 'Check is alive' } Checks that the ldap server is stopped Location of target host Pathname to installation root Number of iterations Number of seconds to wait between iterations 'Check if %s/logs/server.pid still exists on host %s' \ % (dsPath,location) { 'location' : location, 'entry' : '%s/logs/server.pid' % dsPath, 'attribute' : 'TYPE' } 'LOOP %s => RC %s' % (loop,checkRC) 'Sleep for %sms' % noOfMilliSeconds { 'sleepForMilliSeconds' : noOfMilliSeconds } 'Server is not stopped after %sms \ (%s/logs/server.pid still exists on %s)' \ % (noOfLoops*noOfMilliSeconds,dsPath,location) Sleep for number of milliseconds Number of milliseconds to sleep STAXServiceMachine 'delay' 'delay %i' % sleepForMilliSeconds { 'returncode' : RC , 'result' : STAFResult } Get OS related variables Name of host on which to retrieve variables '%s' % hostname 'var' 'get system var STAF/Config/OS/Name' 'OS Name= %s' % STAFResult STAFResult Pretty prints a banner at the start of a test. 'testcase: %s' % STAXCurrentTestcase '****************************************************' '*** STARTING TEST CASE %s.' % STAXCurrentTestcase '***' Pretty prints a banner at the end of a test. '***' '*** ENDING TEST CASE %s.' % STAXCurrentTestcase '****************************************************' 'testcase: %s' % STAXCurrentTestcase Performs all the preoperations for a test case { 'location' : STAF_REMOTE_HOSTNAME, 'type' : 'shared', 'variable' : 'issuesList=[]' } Performs all the post operations for a test suite 'A signal (%s) was raised during this test case' % SignalRaised { 'location' : STAF_REMOTE_HOSTNAME, 'type' : 'shared', 'variable' : 'issuesList' } '## Test Verdict: %s ##' % _status { 'location' : STAXServiceMachine, 'logname' : 'STAX_Job_%s_User' % STAXJobID, 'startfrom' : testcaseStartTime, 'endat' : testcaseEndTime } Performs all the pre operations for a test suite '#### %s/%s suite preamble ####' % (ThisGroupName,ThisSuiteName) Performs all the post operations for a test suite '#### %s/%s suite postamble ####' % (ThisGroupName,ThisSuiteName) { 'starttime' : TestSuiteStartTime, 'endtime' : TestSuiteEndTime, 'logFile' : TestLogFile } Performs all the pre operations for a test group '##### %s group preamble #####' % ThisGroupName Performs all the post operations for a test group '##### %s group postamble #####' % ThisGroupName { 'name' : 'Generate coverage xml report for test group %s' % CurrentTestPath['group'], 'command' : 'java', 'arguments' : ' -Xms64M -Xmx1G -cp %s emma report -r html -in %s,%s -Dreport.html.out.file=%s -sp %s' % (emmaJar, coverageEm, coverageFiles, coverageHtml, srcArgs), 'path' : TMPDIR } Queries the staf logs for the test case and write to file as text timestamp to start logging from timestamp to start logging to name of file to write the logs { 'location' : STAXServiceMachine, 'logname' : 'STAX_Job_%s_User' % STAXJobID, 'startfrom' : starttime, 'endat' : endtime } { 'queryresult' : STAFResult, 'output' : xmlFile } { 'input' : xmlFile, 'stylesheet' : xslFile, 'output' : htmlFile } Process staf log query results and write them to a file result of the staf log query name of the XML file to where results are written 'Creating XML log file %s' % logFile { 'location' : STAXServiceMachine, 'foldername' : NewLogDir } { 'returncode' : '1' , 'result' : output, 'expected' : '0' } _message Process XML file and transform that to an HTML log file name of the XML file to where results are obtained name of the HTML file to where results are written name of the XSL stylesheet used to transform results 'Inputting XML file %s' % xmlFile 'Transform XSL file %s' % xslFile 'Creating HTML file %s' % htmlFile '%s' % _message check the number of matching sub-string in a string the sub-string to check the main string where the search is done comparison using case sensitive, or not value is : True/False number of expected sub-string that must be in the main string Issue id. Corresponds to an issue number. '%s' % myMessage { 'issueId' : issue } '%s' % myMessage myRC,myMessage Name of the function to run Arguments to be passed on to the called function. This can be a map or a list of arguments, whatever the called function expects will be carried on here. . for a map, pass the arguments like this: { 'argumentA' : 'argumentAvalue' , 'argumentB' : 1 , ... } . for a list, pass the arguments like this: [ 'argumentAvalue, 1, ... ] The expected return code of the function to run. This is then passed onto the checkRC function. It is also used to throw an exception if the argument functionException is provided and set the test case status if the argument functionSetsTCStatus is provided The exception to throw if the return code differs from the expected RC. The exception is appended to STAXException. An optional message to display before running the function Whether the function to run sets the testcase status or not. If this is set, the test case status is set according to whether or not the function meets the expected return code. True or False should be used for this argument. If this argument is provided, a testcase will be created with this argument's value for name and set to fail only upon failure If this argument is provided, a signal will be raised upon unsuccesful execution of the function to run If this argument is provided then functionCallBack will be called after the execution of function name. This allows to specify arguments for the call back function '%s' % functionMessage 'runFunction: %s: called with parameters [%s]' % (functionName,functionArguments) functionArguments [_functionRC,_functionResult] A general wrapper to run a command without having to write a dedicated function for it the command to run the path where the command is to be run from the path where the command is to be found the environment variables to set. The default set here should just work for OpenDS commands Which machine should the command be executed on The name to give the process (only matters in the STAX Monitor really) A boolean (use True or False here, case matters) to enable disable stripping the output of a command TODO: consider allowing passing a function name to enable custom output manipulation (overkill?) This argument can only have boolean values The duration that the process is allowed to run input file containing the command input Output file containing the command output Expected return code value. Default value is 0. Wildcard 'noCheck' to not check the RC Known issue. Corresponds to an issue number. If true, stderr for the command is redirect to stdout. This argument can only have boolean values '%s: Running command:\n %s %s\nlocation: %s\nenv: %s\nworkdir: %s' % (_id,command,arguments,location,env,path) location command arguments path env '%s' % outputFile location command arguments path env '%s' % inputFile location command arguments path env '%s' % outputFile { 'returncode' : cmdRC, 'result' : cmdResult, 'expected' : expectedRC, 'issue' : knownIssue } 'ERROR: COMMAND HANGING, not completed after %s' % timerDuration { 'issueId' : knownIssue } cmdResult Kill the ldap server Location of target host Pathname to installation root 'Kill server running on %s at %s' % (location, dsPath) { 'name' : 'Read server pid file', 'location' : location, 'service' : 'FS', 'request' : 'GET FILE', 'arguments' : _args } { 'name' : 'Kill DS server', 'location' : location, 'command' : _cmd, 'arguments' : _args } 'skip the killing of process when running with coverage to avoid data corruption' STAXResult A general wrapper to run a STAF command without having to write a dedicated function for it Which machine should the command be executed on The name to give the process the command to run the command to run the arguments for the service request '%s: Running STAF command:\n %s %s %s\nlocation: %s\n' % (_id,service,request,arguments,location) '%s' % location service '%s %s' % (request,arguments) '%s: STAF Command returned:\n%s' % (_id,STAFResult) STAFResult This function search for a given string in a given file. BEWARE! of potential performance degradation when grepping big files due to the use of getFile, which loads the whole file content into a variable. Location of target host File path String searched Expected return code value. 0 for successful grep, 1 for unsuccessful grep. Default value is 0. Wildcard 'noCheck' to not check the RC 'Search for string \"%s\" in file %s on host %s' % \ (testString, filename, location) { 'location' : location, 'filename' : filename } { 'testString' : testString, 'returnString' : filecontent, 'expectedResult' : myExpectedResult } STAXResult This function compares two files. Print the differences if the comparison failed. Location of target host The name of remote host Pathname to installation root file containing output from the command path containing outputFile reference file containing expected output reference path containing refFile file containing diff output file containing diffFile Known issue. Corresponds to an issue number. { 'location' : cflocation, 'entry' : diffPath, 'attribute' : 'TYPE' } 'Create folder %s' % diffPath { 'location' : cflocation , 'foldername' : diffPath } 'Copy file %s/%s (on %s) to %s/%s (on %s)' % \ (outputPath, outputFile, cfremotehost, diffPath, outputFile, cflocation) { 'location' : cfremotehost , 'srcfile' : '%s/%s' % (outputPath, outputFile) , 'destfile' : '%s/%s' % (diffPath, outputFile) , 'remotehost' : cflocation } 'Copy file %s/%s (on %s) to %s/%s (on %s)' % \ (refPath, refFile, cflocation, diffPath, refFile, cflocation) { 'location' : cflocation , 'srcfile' : '%s/%s' % (refPath, refFile) , 'destfile' : '%s/%s' % (diffPath, refFile) , 'remotehost' : cflocation } 'Compare file %s/%s to %s/%s on %s' % \ (diffPath, outputFile, diffPath, refFile, cflocation) 'SUCCESS : No differences were found between %s and %s' % \ (outputFile, refFile) { 'issueId' : knownIssue } 'ERROR : Differences were found between %s and %s\n%s' % \ (outputFile, refFile, diff) 'ERROR : Diff file is here: %s/%s' % (diffPath, diffFile) 'ERROR : Error during file comparision' This function compile java files. Location of remote host Path containing java files to compile Path where to place generated class files Additional classpath Expected return code value. Default value is 0. Wildcard 'noCheck' to not check the RC { 'location' : location , 'foldername' : foldername , 'extension' : 'java' } { 'name' : 'Compile Java files' , 'command' : cmd , 'arguments' : '-target 1.5 %s %s' % (cmdOptions,list) , 'location' : location , 'path' : foldername , 'envCmd' : env , 'expectedRC' : expectedRC } STAXResult This function create a jar file. Location of remote host Name of the jar file to create Path where to find generated class files Execution path Path to the manifest file Expected return code value. Default value is 0. Wildcard 'noCheck' to not check the RC { 'location' : location , 'entry' : '%s/%s' % (pathfolder,entrypoint) , 'attribute' : 'TYPE' } { 'name' : 'Create Jar file' , 'command' : cmd , 'arguments' : '%s %s %s' % (cmdOptions,jarname,entrypoint) , 'location' : location , 'path' : pathfolder , 'expectedRC' : expectedRC } STAXResult Returns the first free TCP port greater or equal to given number Which machine to look for the free port The minimal port number to be returned port Set testcase result to FAIL if file (as param) does not exist Location of target host The file to check existence { 'location' : STAF_REMOTE_HOSTNAME , 'entry' : file , 'attribute' : 'TYPE' } 'ERROR : File %s does not exist' % file Set testcase result to FAIL if file (as param) exists Location of target host The file to check absence { 'location' : STAF_REMOTE_HOSTNAME , 'entry' : file , 'attribute' : 'TYPE' } 'ERROR : File %s does not exist' % file This function execute the ldclt tools. Location of target host Directory server hostname or IP address Directory server port number Bind DN Bind password The baseDN for the LDAP operation The ldclt options File containing output from the command Path containing outputFile Expected return code value. Default value is 0 Wildcard 'noCheck' to not check the RC Known issue. Corresponds to an issue number. { 'name' : 'LDCLT Script' , 'command' : STAFCmd , 'arguments' : STAFCmdParams , 'location' : location , 'path' : LDCLT_DIR , 'envCmd' : env , 'outputFile' : '%s/%s' % (outputPath, outputFile) , 'expectedRC' : expectedRC , 'logStderr' : True , 'knownIssue' : knownIssue } STAXResult This function makes a ldclt template file Template file name Template file location Extra line to add to the mkae-ldif template 'creation of a ldclt template failed (Code=%s,Reason=%s).' % (STAXCode,STAXReason) { 'returncode' : STAXCode , 'result' : STAXReason } { 'location' : STAXServiceMachine, 'srcfile' : tmpTemplateFile, 'destfile' : templateFile, 'remotehost' : templateLocation } { 'returncode' : RC , 'result' : STAXResult } [RC, STAXResult] This function parses an ldif entry and returns a dictionary, e.g.: {'dn':['o=example'],'objectclass':['top','organization'],'o':['example']} Ldif entry to parse (single string). parsedEntry This function parses several ldif entries and returns a list of dictionaries such as those produced by parseLdifEntry Ldif entries to parse (single string). { 'ldifEntry' : entryToParse } parsedEntryList This function parses an ldif change and returns a list, e.g.: [ ['replace','l','London'], ['add','description','This is a test'] ] Ldif change to parse (single string). parsedChange This function checks the content of an external changelog entry Location of target host Pathname to installation root External changelog entry (as an output of parseLdifEntry) DN of the target entry for the change Change type (e.g. add, delete, modify) Change time Changenumber (only for changelog draft-compatible mode) Replication CSN Target entry uuid Replica Identifier NewRDN DeleteOldRDN NewSuperior Changes. If changetype == add, changes should be a map, e.g.: {'dn':['o=example'],'objectclass':['top','organization'],'o':['example']} If changetype == modify, changes should be a list, e.g.: [ ['replace','l','London'], ['add','description','This is a test'] ] Map containing the attributes configured as include-attributes along with their values, e.g.: { 'description':['desc1', desc2'], 'telephonenumber':['11-22-33']} List of the attributes in includeAttrs expected NOT TO BE FOUND in the changelog entry. Known issue. Corresponds to an issue number. 'checkChangelogEntry: Checking changelog entry %s against expected \ values' % ecl_DN 'checkChangelogEntry: Checking targetDN' { 'returnString' : ecl_targetDN, 'expectedString' : targetDN, 'searchType' : 'exact-case-insensitive', 'knownIssue' : myKnownIssue } 'checkChangelogEntry: Checking changeType' { 'returnString' : ecl_changeType, 'expectedString' : changeType, 'searchType' : 'exact-case-insensitive', 'knownIssue' : myKnownIssue } 'checkChangelogEntry: Checking changeTime' { 'returnString' : ecl_changeTime, 'expectedString' : changeTime, 'searchType' : 'exact-case-insensitive', 'knownIssue' : myKnownIssue } 'checkChangelogEntry: Checking changeNumber' { 'returnString' : ecl_changeNumber, 'expectedString' : changeNumber, 'searchType' : 'exact-case-sensitive', 'knownIssue' : myKnownIssue } 'checkChangelogEntry: Checking replicationCSN' { 'returnString' : ecl_replicationCSN, 'expectedString' : replicationCSN, 'searchType' : 'exact-case-insensitive', 'knownIssue' : myKnownIssue } 'No replicationCSN could be found in the changelog entry' { 'issueId' : myKnownIssue } 'checkChangelogEntry: Checking replicaIdentifier' { 'returnString' : ecl_replicaIdentifier, 'expectedString' : replicaIdentifier, 'searchType' : 'exact-case-sensitive', 'knownIssue' : myKnownIssue } 'No replicaIdentifier could be found in the changelog entry' { 'issueId' : myKnownIssue } 'checkChangelogEntry: Checking targetEntryUUID' { 'returnString' : ecl_targetEntryUUID, 'expectedString' : targetEntryUUID, 'searchType' : 'exact-case-insensitive', 'knownIssue' : myKnownIssue } 'No targetEntryUUID could be found in the changelog entry' { 'issueId' : myKnownIssue } 'checkChangelogEntry: Checking newRDN' { 'returnString' : ecl_newRDN, 'expectedString' : newRDN, 'searchType' : 'exact-case-insensitive', 'knownIssue' : myKnownIssue } 'No newRDN could be found in the changelog entry' { 'issueId' : myKnownIssue } 'checkChangelogEntry: Checking deleteOldRDN' { 'returnString' : ecl_deleteOldRDN, 'expectedString' : deleteOldRDN, 'searchType' : 'exact-case-sensitive', 'knownIssue' : myKnownIssue } 'No deleteOldRDN could be found in the changelog entry' { 'issueId' : myKnownIssue } 'checkChangelogEntry: Checking newSuperior' { 'returnString' : ecl_newSuperior, 'expectedString' : newSuperior, 'searchType' : 'exact-case-insensitive', 'knownIssue' : myKnownIssue } 'No newSuperior could be found in the changelog entry' { 'issueId' : myKnownIssue } 'checkChangelogEntry: Decode external changelog entry changes' { 'location' : myLocation, 'dsPath' : myPath, 'subcommand' : 'decode', 'encodedData' : ecl_changes } 'checkChangelogEntry: Decoded changes:\n%s' % decodedChanges 'checkChangelogEntry: Checking changes' { 'ldifEntry' : decodedChanges } 'Parsed changelog entry changes: \n%s' % ecl_changesMap 'checkChangelogEntry: Checking changes: %s' % attr 'Found expected values in changes: %s' % valueList 'Expected values %s could not be found in %s' \ % (valueList, ecl_valueList) { 'issueId' : myKnownIssue } 'No %s could be found in the changes' % attr { 'issueId' : myKnownIssue } { 'ldifChange' : decodedChanges } 'Parsed changelog entry changes: \n%s' % ecl_changesList 'checkChangelogEntry: Checking changes: %s' % mod 'Found expected change:\n %s: %s\n %s: %s\n' \ % (mod_type, mod_attr, mod_attr, mod_val) 'Expected change %s could not be found in %s'\ % (mod, ecl_changesList) { 'issueId' : myKnownIssue } 'No changes could be found in the changelog entry' { 'issueId' : myKnownIssue } 'checkChangelogEntry: Checking include-attribute: %s' % attr 'Found values %s for %s while NONE expected.' \ % (valueList, targetAttr) { 'issueId' : myKnownIssue } 'Found expected values for include attribute in %s: \ %s' % (targetAttr, valueList) 'Expected values %s could not be found in %s: %s' \ % (valueList, targetAttr, ecl_valueList) { 'issueId' : myKnownIssue } 'No %s could be found in the changelog entry, AS EXPECTED' \ % targetAttr 'No %s could be found in the changelog entry' % targetAttr { 'issueId' : myKnownIssue } This function performs a psearch request Location of target host Target directory server hostname or IP address Directory server port number Directory server dn Bind password Specify the base DN for which to perform the verification Specify the number of threads to use Specify the output file path Specify the opeation type Optional do not perform any display in terminal Optional output file in ldif format Expected return code value. Default value is 0 Wildcard 'noCheck' to not check the RC '%s %s' % (STAFCmd, STAFCmdParams) { 'name' : 'PSearch' , 'command' : '%s/bin/java' % JAVA_HOME , 'arguments' : '%s %s' % (STAFCmd, STAFCmdParams) , 'location' : location , 'path' : '%s/ldapjdk' % remote.java , 'envCmd' : env , 'expectedRC' : expectedRC } STAXResult