Package pysys :: Module baserunner :: Class BaseRunner
[hide private]
[frames] | no frames]

Class BaseRunner

source code

process.user.ProcessUser --+
                           |
                          BaseRunner

The base class for executing a set of PySys testcases.

BaseRunner is the parent class for running a set of PySys system testcases. The runner is instantiated with a list of pysys.xml.descriptor.XMLDescriptorContainer objects detailing the set of testcases to be run. The runner iterates through the descriptor list and for each entry imports the pysys.basetest.BaseTest subclass for the testcase, creates an instance of the test class and then calls the setup, execute, validate and cleanup methods of the test class instance. The runner is responsible for ensuring the output subdirectory of each testcase is purged prior to test execution to remove stale output from a previous run, detects any core files produced during execution of a testcase from processes started via the pysys.process module, and performs audit trail logging of the test results on completion of running a set of testcases.

The base runner contains the hook functions setup, testComplete, cycleComplete and cleanup to allow a subclass to perform custom operations prior to the execution of a set of testcases, between the execution of each testcase in a set, between each cycle of execution of a set of testcases, and on completion of all testcases respectively. Subclasses are typically used should some global conditions need to be setup prior to the set of testcasess being run (i.e. load data into a shared database, start an external process etc), and subsequently cleaned up after test execution.

Instance Methods [hide private]
 
__init__(self, record, purge, cycle, mode, threads, outsubdir, descriptors, xargs)
Create an instance of the BaseRunner class.
source code
 
setKeywordArgs(self, xargs)
Set the xargs as data attributes of the class.
source code
 
setup(self)
Setup method which may optionally be overridden to perform custom setup operations prior to execution of a set of testcases.
source code
 
testComplete(self, testObj, dir)
Test complete method which performs completion actions after execution of a testcase.
source code
 
cycleComplete(self)
Cycle complete method which may optionally be overridden to perform custom operations between the repeated execution of a set of testcases.
source code
 
cleanup(self)
Cleanup method which may optionally be overridden to perform custom cleanup operations after execution of all testcases.
source code
 
start(self, printSummary=True)
Start the execution of a set of testcases, returning a dictionary of the testcase outcomes.
source code
 
printSummary(self)
Print the output summary at the completion of a test run.
source code
 
containerCallback(self, thread, container)
Callback method on completion of running a test.
source code
 
containerExceptionCallback(self, thread, exc_info)
Callback method for unhandled exceptions thrown when running a test.
source code
 
handleKbrdInt(self, prompt=True)
Handle a keyboard exception caught during running of a set of testcases.
source code

Inherited from process.user.ProcessUser: __del__, __getattr__, getInstanceCount, signalProcess, startProcess, stopProcess, waitForFile, waitForSignal, waitForSocket, waitProcess, writeProcess

Instance Variables [hide private]
logging.Logger log
Reference to the logger instance of this class
string mode
The user defined modes to run the tests within
string outsubdir
The directory name for the output subdirectory
Project project
Reference to the project details as set on the module load of the launching executable

Inherited from process.user.ProcessUser: input, output

Method Details [hide private]

__init__(self, record, purge, cycle, mode, threads, outsubdir, descriptors, xargs)
(Constructor)

source code 

Create an instance of the BaseRunner class.

Parameters:
  • record - Indicates if the test results should be recorded
  • purge - Indicates if the output subdirectory should be purged on PASSED result
  • cycle - The number of times to execute the set of requested testcases
  • mode - The user defined mode to run the testcases in
  • threads - The number of worker threads to execute the requested testcases
  • outsubdir - The name of the output subdirectory
  • descriptors - List of XML descriptor containers detailing the set of testcases to be run
  • xargs - The dictionary of additional arguments to be set as data attributes to the class
Overrides: process.user.ProcessUser.__init__

setKeywordArgs(self, xargs)

source code 

Set the xargs as data attributes of the class.

Values in the xargs dictionary are set as data attributes using the builtin setattr() method. Thus an xargs dictionary of the form {'foo': 'bar'} will result in a data attribute of the form self.foo with value bar.

Parameters:
  • xargs - A dictionary of the user defined extra arguments

testComplete(self, testObj, dir)

source code 

Test complete method which performs completion actions after execution of a testcase.

The testComplete method performs purging of the output subdirectory of a testcase on completion of the test execution. Purging involves removing all files with a zero file length in order to only include files with content of interest. Should self.purge be set, the purging will remove all files (excluding the run.log) on a PASSED outcome of the testcase in order to reduce the on-disk memory footprint when running a large number of tests. Should a custom testComplete for a subclass be required, the BaseRunner testComplete method should first be called.

Parameters:
  • testObj - Reference to the pysys.basetest.BaseTest instance of the test just completed
  • dir - The directory to perform the purge on

start(self, printSummary=True)

source code 

Start the execution of a set of testcases, returning a dictionary of the testcase outcomes.

The start method is the main method for executing the set of requested testcases. The set of testcases are executed a number of times determined by the self.cycle attribute. When executing a testcase all output from the execution is saved in the testcase output subdirectory; should self.cycle be set to more than 1, the output subdirectory is further split into cycle[n] directories to sandbox the output from each iteration.

Parameters:
  • printSummary - Indicates if the test results should be reported on test completion

containerCallback(self, thread, container)

source code 

Callback method on completion of running a test.

Parameters:
  • container - A reference to the container object that ran the test

    Called on completion of running a testcase, either directly by the BaseRunner class (or a sub-class thereof), or from the ThreadPool when running with more than one worker thread. The method is responsible for calling of the testComplete() method of the runner, recording of the test result to the result writers, and for deletion of the test container object.

containerExceptionCallback(self, thread, exc_info)

source code 

Callback method for unhandled exceptions thrown when running a test.

Parameters:
  • exc_info - The tuple of values as created from sys.exc_info()