Base class for target implementations.
A Target is an entity that can run tests. QMTest can spread the
workload from multiple tests across multiple targets. In
addition, a single target can run more that one test at once.
Target is an abstract class.
You can extend QMTest by providing your own target class
implementation.
To create your own test class, you must create a Python class
derived (directly or indirectly) from Target . The documentation
for each method of Target indicates whether you must override it
in your test class implementation. Some methods may be
overridden, but do not need to be. You might want to override
such a method to provide a more efficient implementation, but
QMTest will work fine if you just use the default version.
Methods
|
|
|
|
GetDatabase
|
GetDatabase ( self )
Return the Database containing the tests this target will run.
- returns
- The
Database containing the tests this target will
run.
Derived classes must not override this method.
|
|
GetGroup
|
GetGroup ( self )
Return the group of which the target is a member.
Derived classes must not override this method.
|
|
GetName
|
GetName ( self )
Return the name of the target.
Derived classes must not override this method.
|
|
IsIdle
|
IsIdle ( self )
Return true if the target is idle.
- returns
- True if the target is idle. If the target is idle,
additional tasks may be assigned to it.
Derived classes must override this method.
|
|
IsInGroup
|
IsInGroup ( self, group_pattern )
Returns true if this Target is in a particular group.
-
group_pattern
- A string giving a regular expression.
- returns
- Returns true if the
group_pattern denotes a
regular expression that matches the group for this Target ,
false otherwise.
|
|
RunTest
|
RunTest (
self,
descriptor,
context,
)
Run the test given by test_id .
-
descriptor
- The
TestDescriptor for the test.
-
context
- The
Context in which to run the test.
Derived classes may override this method.
|
|
Start
|
Start (
self,
response_queue,
engine=None,
)
Start the target.
-
response_queue
- The
Queue in which the results of test
executions are placed.
-
engine
- The
ExecutionEngine that is starting the target,
or None if this target is being started without an
ExecutionEngine .
Derived classes may override this method, but the overriding
method must call this method at some point during its
execution.
|
|
Stop
|
Stop ( self )
Stop the target.
Clean up all resources that have been set up on this target
and take whatever other actions are required to stop the
target.
Derived classes may override this method.
|
|
_BeginResourceSetUp
|
_BeginResourceSetUp ( self, resource_name )
Begin setting up the indicated resource.
-
resource_name
- A string naming a resource.
- returns
- If at attempt to set up the resource has already
been made, returns a tuple
(resource, outcome, properties) .
The resource is the Resource object itself, but may be
None if the resource could not be set up. The outcome
indicates the outcome that resulted when the resource was set
up. The properties are a map from strings to strings
indicating properties added by this resource.
If the resource has not been set up, but _BeginResourceSetUp
has already been called for the resource, then the contents of
the tuple will all be None .
If this is the first time _BeginResourceSetUp has been called
for this resource, then None is returned, but the resource
is marked as in the process of being set up. It is the
caller's responsibility to finish setting it up by calling
_FinishResourceSetUp .
|
|
_CleanUpResource
|
_CleanUpResource (
self,
name,
resource,
)
Clean up the resource .
-
resource
- The
Resource that should be cleaned up.
-
name
- The name of the reosurce itself.
|
|
_FinishResourceSetUp
|
_FinishResourceSetUp (
self,
resource,
result,
properties,
)
Finish setting up a resource.
-
resource
- The
Resource itself.
-
result
- The
Result associated with setting up the
resource.
-
properties
- A dictionary of additional context properties
that should be provided to tests that depend on this resource.
- returns
- A tuple of the same form as is returned by
_BeginResourceSetUp when the resource has already been set
up.
|
|
_GetTemporaryDirectory
|
_GetTemporaryDirectory ( self )
Return the path to a temporary directory.
- returns
- The path to a temporary directory to pass along to
tests and resources via the
TMPDIR_CONTEXT_PROPERTY .
|
|
_RecordResult
|
_RecordResult ( self, result )
Record the result .
-
result
- A
Result of a test or resource execution.
Derived classes may override this method, but the overriding
method must call this method at some point during its
execution.
|
|
_SetUpResource
|
_SetUpResource (
self,
resource_name,
context,
)
Set up the resource given by resource_id .
-
resource_name
- The name of the resource to be set up.
-
context
- The
Context in which to run the resource.
- returns
- A map from strings to strings indicating additional
properties added by this resource.
|
|
__SetUpResources
|
__SetUpResources (
self,
descriptor,
context,
)
Set up all the resources associated with descriptor .
-
descriptor
- The
TestDescriptor or ResourceDescriptor
indicating the test or resource that is about to be run.
-
context
- The
Context in which the resources will be
executed.
- returns
- A tuple of the same form as is returned by
_BeginResourceSetUp when the resource has already been set
up.
Exceptions
|
|
self.__ResourceSetUpException, resource
|
|
|
__init__
|
__init__ (
self,
database,
properties,
)
Construct a Target .
-
database
- The
Database containing the tests that will be
run.
-
properties
- A dictionary mapping strings (property names)
to values.
|
|