– abstract base classes

Those classes are actually implemented in the plainbox.impl package. This module is here so that the essential API concepts are in a single spot and are easier to understand (by not being mixed with additional source code).


This module has API stability guarantees. We are not going to break or introduce backwards incompatible interfaces here without following our API deprecation policy. All existing features will be retained for at least three releases. All deprecated symbols will warn when they will cease to be available.


Bases: object

A pluggable build system definition

PlainBox uses build systems to assist provider authors in building additional executables from source code. To facilitate support for a specific language or toolkit a build system may detect it and offer proper commands without the test developer having to copy/paste those commands from provider to provider.

PlainBox discovers providers from the plainbox.buildsystem entry point. Each entry point there must be a class implementing this interface.

get_build_command(src_dir: str, build_dir: str) → str[source]

Get shell command to build the sources.

  • src_dir – absolute path of the source directory
  • build_dir – absolute path of the build directory

shell command to execute

With the given source and build directory, come up with a piece of shell that knows how to build stuff so that it ends up in the build directory.


The command will be executed in build_dir.

probe(src_dir: str) → int[source]

Look at the source directory and determine how applicable this build system is.

Parameters:src_dir – absolute path of the directory with source code
Returns:the suitability value, 0 if the build system doesn’t support sources of the particular kind, all values greater than zero indicate some level of suitability. The largest return value wins.

The return value is a number. Values closer to zero mean that the build system is not suitable, values closer to one mean the build system is more suitable. Value of 0 mean that the build system is totally unsuitable and will not be applied, even if no other choices are available.

The idea is that multiple build systems may recognize a source directory but since the system is extensible, other people may come up with more suitable build system that spots additional files and returns a score better than the average.


Bases: object

Interface for job execution controller clases.

Execution controllers encapsulate knowledge on how to run command associated with a particular job. Some executors might run the command directly, others might delegate the task to a helper program or perform some special-cased customization to the execution environment.

execute_job(job, job_state, config, session_dir, extcmd_popen)[source]

Execute the specified job using the specified subprocess-like object

  • job – The JobDefinition to execute
  • job_state – The JobState associated to the job to execute.
  • config – A PlainBoxConfig instance which can be used to load missing environment definitions that apply to all jobs. It is used to provide values for missing environment variables that are required by the job (as expressed by the environ key in the job definition file).
  • session_dir – Base directory of the session this job will execute in. This directory is used to co-locate some data that is unique to this execution as well as data that is shared by all executions.
  • extcmd_popen – A subprocess.Popen like object

The return code of the command, as returned by


Compute how applicable this controller is for the specified job.

Returns:A numeric score, or None if the controller cannot run this job. The higher the value, the more applicable this controller is.

Get a warm-up function that should be called before running this job.

Returns:A callable (without arguments) or None, depending on needs of a particular job.

The warm-up function is an optional advisory interface to improve the testing experience for the user. A job may not require any warm-up. In such case the return value is None. Note that even if this function is not called the testing process should perform the same way (correctly) but the user may be prompted for additional steps mid-way.


Bases: object

Job definition that contains a mixture of meta-data and executable information that can be consumed by the job runner to produce results.


The shell command to execute to perform the job.

The return code, standard output and standard error streams are automatically recorded and processed, depending on the plugin type.

This value can be None


Comma-delimited dependency expression

This field can be used to express job dependencies. If a job depends on another job it can only start if the other job had ran and succeeded.

This is the original data as provided when constructed. Use get_direct_dependencies() to obtain the parsed equivalent.

This value can be None


Human-readable description of the job.

This field is typically used to include execution and verification steps for manual and human-assisted tests.

This value can be None


Unique job identifier

The identifier is unique within the provider a job belongs to


Name of the job


Name of the job interpreter.

Various interpreters are provided by the job runner.


The provider this job definition belongs to


Technically this still can be None (a provider-less job may exist) but it can only happen in testing. This mode is discouraged and will be eventually forbidden. All job definition units must belong to a provider.


Human readable purpose of the test.


List of expressions that need to be true for this job to be available

This value can be None


Shell that is used to interpret the command

Defaults to ‘bash’ for checkbox compatibility.


Human readable instruction what actions should user perform while performing test


Short (one line) description of the job


Human readable instruction how to verify outcome of a test


Bases: object

An opaque qualifier for a job definition.

This is an abstraction for matching jobs definitions to names, patterns and other means of selecting jobs.

There are two ways to use a qualifier object. The naive, direct, old API can simply check if a qualifier designates a particular job (if it selects it and marks for subsequent execution). This API works fine for certain tasks but it was found that it is insufficient to implement so-called test plan ordering, where the order of jobs in a test plan is preserved when selecting that test plan for execution. This spawned the second, lower-level API, that gives portable visibility into composite qualifiers and distinct select, deselect vote so that full range of current expressiveness can be preserved.

 (0) vote indicating that a job should not be included for selection. It overwrites any other votes.
 (1) vote indicating that a job should be included for selection. It is overridden by VOTE_EXCLUDE.
 (2) vote indicating that a job should neither be included nor excluded for selection. This is a neutral value overridden by all other votes.

Check if this qualifier designates the specified

Returns True:if the qualifier designates the specified job
Returns False:otherwise

Return a list of primitives that constitute this qualifier.

Returns:A list of IJobQualifier objects that each is the smallest, indivisible entity.

When each vote cast by those qualifiers is applied sequentially to a given job then the result is the same as the return value of the designates() method. The resulting list has more structure and this structure may matter to job ordering when a list of jobs is matched against a list of qualifiers. The resulting sets are identical but ordering of results is more accurately reflected by iterating over the fine structure of each qualifier.


Get one of the VOTE_IGNORE, VOTE_INCLUDE, VOTE_EXCLUDE votes that this qualifier associated with the specified job.

Parameters:job – A IJobDefinition instance that is to be visited
Returns:one of the VOTE_xxx constants

property indicating that a qualifier is not divisible by calling get_primitive_qualifiers().

If a qualifier is not primitive it can be replaced with a list of qualifiers it produces by the call to the aforementioned method.


Origin of this qualifier

Raises:NonPrimitiveQualifierOrigin – If the is_primitive() property is True and this qualifier has no well-defined origin of itself.

This property can be used to trace the origin of a qualifier back to its definition point. Note that it may not always be available when it doesn’t make sense to say that a composite object came from any one particular place.


Bases: object

Class for representing results from a single job

OUTCOME_NOT_IMPLEMENTED = 'not-implemented'
OUTCOME_NOT_SUPPORTED = 'not-supported'

The comment that was added by the user, if any


Compute and return the sequence of IOLogRecord objects.

Returns:A sequence of tuples (delay, stream-name, data) where delay is the delay since the previous message seconds (typically a fractional number), stream name is either ‘stdout’ or ‘stderr’ and data is the bytes object that was obtained from that stream.

A sequence of tuples (delay, stream-name, data) where delay is the delay since the previous message seconds (typically a fractional number), stream name is either ‘stdout’ or ‘stderr’ and data is the bytes object that was obtained from that stream.


flag that indicates if the result is hollow

Hollow results may have been created but hold no data at all. Hollow results are also tentatively deprecated, once we have some time to re-factor SessionState and specifically the job_state_map code we will remove the need to have hollow results.

Hollow results are not saved, beginning with plainbox.impl.session.suspend.SessionSuspendHelper4.


Outcome of the test.

The result of either automatic or manual verification. Depending on the plugin (test type). Available values are defined as class properties above.


Command return code.

This is the return code of the process started to execute the command from the job definition. It can also encode the signal that the process was killed with, if any.


Bases: object

Something that can run a job definition and produce results.

You can run many jobs with one runner, each time you’ll get additional result object. Typically you will need to connect the runner to a user interface but headless mode is also possible.


Determine if authentication warm-up may be needed.

Parameters:job_lits – A list of jobs that may be executed
Returns:A list of methods to call to complete the warm-up step.

Authentication warm-up is related to the plainbox-secure-launcher-1 program that can be ‘warmed-up’ to perhaps cache the security credentials. This is usually done early in the testing process so that we can prompt for passwords before doing anything that takes an extended amount of time.

run_job(job, config=None, ui=None)[source]

Run the specified job.

Calling this method may block for arbitrary amount of time. User interfaces should ensure that it runs in a separate thread.

The return value is a JobResult object that contains all the data that was captured during the execution of the job. Some jobs may not return a JobResult value.


Bases: object

User interface (textual) related to running a single job

about_to_execute_program(args, kwargs)[source]

Method called just prior to execute an external program.

  • args – Same as for
  • kwargs – Same as for
about_to_start_running(job, job_state)[source]

Method called as the runner has decided to run the job and is getting ready to start.

considering_job(job, job_state)[source]

Method called as the runner is considering the specified job can run or not.

finished(job, job_state, job_result)[source]

Method called at the end of the process, regardless if the job was actually started or not


Method called just after running an external program

Parameters:returncode – The return code of the external program
finished_running(job, job_state, job_result)[source]

Method called immediately after the runner finishes to run the job

got_program_output(stream_name, line)[source]

Method called on every line of output from an external program

  • stream_name – either ‘stdin’ or ‘stdout’
  • line – the full text of the intercepted line
job_cannot_start(job, job_state, job_result)[source]

Method called when a job cannot be started


Method called when job that is about to run has ‘noreturn’ flag (plainbox will suspend operation after running that job).


Method called prior to user interactions that might require familiarity of the job description. Gets called only if purpose/steps/verification fields are missing.


Method called after starting a job


Method called prior to user interactions that might require familiarity with interaction steps


Method called before user selects outcome of a job

pick_action_cmd(action_list, prompt=None)[source]

Present a list of actions and let the user pick one

Parameters:action_list – A list of 3-tuples (accel, label, cmd)
Prompt:An optional prompt string
Returns:cmd of the selected action or None
started_running(job, job_state)[source]

Method called immediately before the runner starts to run the job


Method called only for user-interact and user-interact-verify jobs that should instruct the user to read the description (that needs to be displayed somehow) and confirm before the test is actually started. The user should be one of the few choices listed below:

save and quit
run the job
skip and continue
Returns:The action selected by the user.


Provider for the current type of tests

Also known as the ‘checkbox-like’ provider.


Return the required value of CHECKBOX_SHARE environment variable.


This variable is only required by one script. It would be nice to remove this later on.


absolute path of the base directory with other directories.

May be None


directory where all the executables needed by this provider reside


absolute path of the data directory


description of this provider


List of all the executables


Return additional entry for PYTHONPATH, if needed.

This entry is required for CheckBox scripts to import the correct CheckBox python libraries.


The result may be None


the name of the gettext domain associated with this provider

This value may be empty, in such case provider data cannot be localized for the user environment.


A mapping from unit identifier to list of units with that identifier.


Typically the list will be one element long but invalid providers may break that guarantee. Code defensively if you can.


List of loaded job definition units.


Return an absolute path of the jobs directory


absolute path of the directory with locale data

The value is applicable as argument bindtextdomain()


name of this provider

This name should be dbus-friendly. It should not be localizable.


namespace component of the provider name

This property defines the namespace in which all provider jobs are defined in. Jobs within one namespace do not need to be fully qualified by prefixing their partial identifier with provider namespace (so all stays ‘as-is’). Jobs that need to interact with other provider namespaces need to use the fully qualified job identifier instead.

The identifier is defined as the part of the provider name, up to the colon. This effectively gives organizations flat namespace within one year-domain pair and allows to create private namespaces by using sub-domains.


A mapping from filename path to a list of units stored in that file.


For .pxu files this will enumerate all units stored there. For other things it will typically be just the FileUnit.


list of problems encountered by the loading process


flag indicating that this provider was loaded from the secure portion of PROVIDERPATH and thus can be used with the plainbox-trusted-launcher-1.


List of loaded units.


absolute path of the units directory

May be None


version of this provider


Bases: object

Provider for the current type of tests.

This class provides the APIs required by the internal implementation that are not considered normal public APIs. The only consumer of the those methods and properties are internal to plainbox.


Return the required value of CHECKBOX_SHARE environment variable.


This variable is only required by one script. It would be nice to remove this later on.


absolute path of the base directory with other directories.

May be None


directory where all the executables needed by this provider reside


absolute path of the data directory


Return additional entry for PYTHONPATH, if needed.

This entry is required for CheckBox scripts to import the correct CheckBox python libraries.


The result may be None


Return an absolute path of the jobs directory


flag indicating that this provider was loaded from the secure portion of PROVIDERPATH and thus can be used with the plainbox-trusted-launcher-1.


absolute path of the units directory

May be None


Bases: object

Interface for session state controller classes.

Session state controller classes cooperate with SessionState and DependencySolver classes and implement knowledge unique to particular job semantics. Before execution the controller can influence job runnability (by setting inhibitors). After execution the controller can observe the result and influence session state


Get the set of direct dependencies of a particular job.

Parameters:job – A IJobDefinition instance that is to be visited
Returns:set of pairs (dep_type, job_name)

Returns a set of pairs (dep_type, job_name) that describe all dependencies of the specified job. The first element in the pair, dep_type, is either DEP_TYPE_DIRECT, DEP_TYPE_ORDERING or DEP_TYPE_RESOURCE. The second element is the name of the job.

get_inhibitor_list(session_state, job)[source]

Get a list of readiness inhibitors that inhibit a particular job.

  • session_state – A SessionState instance that is used to interrogate the state of the session where it matters for a particular job. Currently this is used to access resources and job results.
  • job – A JobDefinition instance

List of JobReadinessInhibitor

observe_result(session_state, job, result)[source]

Notice the specified test result and update readiness state.

  • session_state – A SessionState object
  • job – A JobDefinition object
  • result – A IJobResult object

This function updates the internal result collection with the data from the specified test result. Results can safely override older results. Results also change the ready map (jobs that can run) because of dependency relations.

class, exporter_unit=None)[source]

Bases: object

Interface for classes that export session state to a byte stream.

Exporters write out the state of the session after all jobs have finished running, in a user-selected format. The intent is not to preserve everything that the session may hold but instead to present it to the user in the best format possible.

Each exporter can support a set of options that can alter the way it operates. Options can either be set boolean-like, or they can be assigned a value (a string). If an option contains a “=”, the part of the string on the right of the equal sign will be assigned as the option’s value; otherwise they operate in a boolean fashion.

It’s best to keep the list of exporter options under control to keep the user interface from becoming annoying.

dump(data, stream)[source]

Dump data to stream.

This method operates on data that was returned by get_session_data_subset(). It may not really process bytes or simple collections. Instead, for efficiency, anything is required.

As in get_session_data_subset() it’s essential to safely save arbitrarily large data sets (or actually, only where it matters the most, like in io_log).

Data is a text stream suitable for writing.

dump_from_session_manager(session_manager, stream)[source]

Dump session information pulled from session manager to stream.

This method takes session manager instance, extracts session information from it, and dumps it to a stream.


Compute a subset of session data.

The subset of the data that should be saved may depend on a particular saver class and options selected by the user.

Must return a collection that can be handled by dump(). Special care must be taken when processing io_log (and in the future, attachments) as those can be arbitrarily large.


Return the list of supported options

class, option_string)[source]

Bases: object

Interface for transports that send test data somewhere.

They handle just the transmission portion of data sending; exporters are expected to produce data in the proper format (e.g. json, tar.xz).

Each transport can have specific parameters that are required for the other end to properly process received information (like system identification, authorization data and so on), and that don’t semantically belong in the test data as produced by the exporter. Additionally each transport needs to be told where to send test data. This is transport-dependent; things like a HTTP endpoint, IP address, port are good examples.

send(data, config=None, session_state=None)[source]

Send data somewhere.

  • data – a stream-like object of data to send (read only)
  • config – a PlainBoxConfig object (optional)
  • session_state – the session for which this transport is associated with the data being sent (optional)
  • ValueError – if any of the arguments are somehow invalid
  • TransportError – if any transport-specific problem arises

a dictionary with additional items, see notes below


The return value is especially vague specifically to allow various transports to express whatever they may need to express for a particular vertical use case yet still to allow most of the code to just work with all transports.

It is expected that certain keys in the returned dictionary will gain special semantics that can be further standardized. As of this writing there are no standard keys.


Bases: object

An abstract source of text.

Concrete instances of this class are used by plainbox.impl.rfc822.Origin to keep track of where each entry of a RFC822-like document came from.


Compute a new text source of the same kind with any filesystem references translated to be relative from the specified base directory.

Parameters:base_dir – A base directory name
Returns:A new text source

Bases: object

Base class that allows job runner to interact with the user interface.


Get the outcome of the manual verification, as according to the user May raise NotImplementedError if the user interface cannot provide this answer.

comments powered by Disqus