Extension (plugin) APIs

Extension APIs that may be of interest to plugin writers.

Submodules

avocado.plugins.config module

class avocado.plugins.config.Config

Bases: avocado.core.plugin_interfaces.CLICmd

Implements the avocado ‘config’ subcommand

configure(parser)
description = 'Shows avocado config keys'
name = 'config'
run(args)

avocado.plugins.diff module

Job Diff

class avocado.plugins.diff.Diff

Bases: avocado.core.plugin_interfaces.CLICmd

Implements the avocado ‘diff’ subcommand

configure(parser)

Add the subparser for the diff action.

Parameters:parser – Main test runner parser.
description = 'Shows the difference between 2 jobs.'
name = 'diff'
run(args)

avocado.plugins.distro module

avocado.plugins.distro.DISTRO_PKG_INFO_LOADERS = {'deb': <class 'avocado.plugins.distro.DistroPkgInfoLoaderDeb'>, 'rpm': <class 'avocado.plugins.distro.DistroPkgInfoLoaderRpm'>}

the type of distro that will determine what loader will be used

class avocado.plugins.distro.Distro

Bases: avocado.core.plugin_interfaces.CLICmd

Implements the avocado ‘distro’ subcommand

configure(parser)
description = 'Shows detected Linux distribution'
get_output_file_name(args)

Adapt the output file name based on given args

It’s not uncommon for some distros to not have a release number, so adapt the output file name to that

name = 'distro'
run(args)
class avocado.plugins.distro.DistroDef(name, version, release, arch)

Bases: avocado.utils.distro.LinuxDistro

More complete information on a given Linux Distribution

Can and should include all the software packages that ship with the distro, so that an analysis can be made on whether a given package that may be responsible for a regression is part of the official set or an external package.

software_packages = None

All the software packages that ship with this Linux distro

software_packages_type = None

A simple text that denotes the software type that makes this distro

to_dict()

Returns the representation as a dictionary

to_json()

Returns the representation of the distro as JSON

class avocado.plugins.distro.DistroPkgInfoLoader(path)

Bases: object

Loads information from the distro installation tree into a DistroDef

It will go through all package files and inspect them with specific package utilities, collecting the necessary information.

get_package_info(path)

Returns information about a given software package

Should be implemented by classes inheriting from DistroDefinitionLoader.

Parameters:path (str) – path to the software package file
Returns:tuple with name, version, release, checksum and arch
Return type:tuple
get_packages_info()

This method will go through each file, checking if it’s a valid software package file by calling is_software_package() and calling load_package_info() if it’s so.

is_software_package(path)

Determines if the given file at path is a software package

This check will be used to determine if load_package_info() will be called for file at path. This method should be implemented by classes inheriting from DistroPkgInfoLoader and could be as simple as checking for a file suffix.

Parameters:path (str) – path to the software package file
Returns:either True if the file is a valid software package or False otherwise
Return type:bool
class avocado.plugins.distro.DistroPkgInfoLoaderDeb(path)

Bases: avocado.plugins.distro.DistroPkgInfoLoader

Loads package information for DEB files

get_package_info(path)
is_software_package(path)
class avocado.plugins.distro.DistroPkgInfoLoaderRpm(path)

Bases: avocado.plugins.distro.DistroPkgInfoLoader

Loads package information for RPM files

get_package_info(path)
is_software_package(path)

Systems needs to be able to run the rpm binary in order to fetch information on package files. If the rpm binary is not available on this system, we simply ignore the rpm files found

class avocado.plugins.distro.SoftwarePackage(name, version, release, checksum, arch)

Bases: object

Definition of relevant information on a software package

to_dict()

Returns the representation as a dictionary

to_json()

Returns the representation of the distro as JSON

avocado.plugins.distro.load_distro(path)

Loads the distro from an external file

Parameters:path (str) – the location for the input file
Returns:a dict with the distro definition data
Return type:dict
avocado.plugins.distro.load_from_tree(name, version, release, arch, package_type, path)

Loads a DistroDef from an installable tree

Parameters:
  • name (str) – a short name that precisely distinguishes this Linux Distribution among all others.
  • version (str) – the major version of the distribution. Usually this is a single number that denotes a large development cycle and support file.
  • release (str) – the release or minor version of the distribution. Usually this is also a single number, that is often omitted or starts with a 0 when the major version is initially release. It’s often associated with a shorter development cycle that contains incremental a collection of improvements and fixes.
  • arch (str) – the main target for this Linux Distribution. It’s common for some architectures to ship with packages for previous and still compatible architectures, such as it’s the case with Intel/AMD 64 bit architecture that support 32 bit code. In cases like this, this should be set to the 64 bit architecture name.
  • package_type (str) – one of the available package info loader types
  • path (str) – top level directory of the distro installation tree files
avocado.plugins.distro.save_distro(linux_distro, path)

Saves the linux_distro to an external file format

Parameters:
Returns:

None

avocado.plugins.docker module

Run the job inside a docker container.

class avocado.plugins.docker.Docker

Bases: avocado.core.plugin_interfaces.CLI

Run the job inside a docker container

configure(parser)
description = 'Run tests inside docker container'
name = 'docker'
run(args)
class avocado.plugins.docker.DockerRemoter(dkrcmd, image, options, name=None)

Bases: object

Remoter object similar to avocado.core.remoter which implements subset of the commands on docker container.

Executes docker container and attaches it.

Parameters:
  • dkrcmd – The base docker binary (or command)
  • image – docker image to be used in this instance
cleanup()

Stop the container and remove it

close()

Safely postprocess the container

Note:It won’t remove the container, you need to do it manually
get_cid()

Return this remoter’s container ID

makedir(remote_path)

Create a directory on the container

Warning:No other process must be running on foreground
Parameters:remote_path – the remote path to create.
receive_files(local_path, remote_path)

Receive files from the container

run(command, ignore_status=False, quiet=None, timeout=60)

Run command inside the container

send_files(local_path, remote_path)

Send files to the container

class avocado.plugins.docker.DockerTestRunner(job, test_result)

Bases: avocado.core.remote.runner.RemoteTestRunner

Test runner which runs the job inside a docker container

remote_test_dir = '/avocado_remote_test_dir'
setup()
tear_down()

avocado.plugins.envkeep module

class avocado.plugins.envkeep.EnvKeep

Bases: avocado.core.plugin_interfaces.CLI

Keep environment variables on remote executions

configure(parser)
description = 'Keep variables in remote environment'
name = 'envkeep'
run(args)

avocado.plugins.exec_path module

Libexec PATHs modifier

class avocado.plugins.exec_path.ExecPath

Bases: avocado.core.plugin_interfaces.CLICmd

Implements the avocado ‘exec-path’ subcommand

description = 'Returns path to avocado bash libraries and exits.'
name = 'exec-path'
run(args)

Print libexec path and finish

Parameters:args – Command line args received from the run subparser.

avocado.plugins.gdb module

Run tests with GDB goodies enabled.

class avocado.plugins.gdb.GDB

Bases: avocado.core.plugin_interfaces.CLI

Run tests with GDB goodies enabled

configure(parser)
description = "GDB options for the 'run' subcommand"
name = 'gdb'
run(args)

avocado.plugins.jobscripts module

class avocado.plugins.jobscripts.JobScripts

Bases: avocado.core.plugin_interfaces.JobPre, avocado.core.plugin_interfaces.JobPost

description = 'Runs scripts before/after the job is run'
name = 'jobscripts'
post(job)
pre(job)

avocado.plugins.journal module

Journal Plugin

class avocado.plugins.journal.Journal

Bases: avocado.core.plugin_interfaces.CLI

Test journal

configure(parser)
description = "Journal options for the 'run' subcommand"
name = 'journal'
run(args)
class avocado.plugins.journal.ResultJournal(job=None)

Bases: avocado.core.result.Result

Test Result Journal class.

This class keeps a log of the test updates: started running, finished, etc. This information can be forwarded live to an avocado server and provide feedback to users from a central place.

Creates an instance of ResultJournal.

Parameters:job – an instance of avocado.core.job.Job.
end_test(state)
end_tests()
lazy_init_journal(state)
start_test(state)

avocado.plugins.jsonresult module

JSON output module.

class avocado.plugins.jsonresult.JSONCLI

Bases: avocado.core.plugin_interfaces.CLI

JSON output

configure(parser)
description = "JSON output options for 'run' command"
name = 'json'
run(args)
class avocado.plugins.jsonresult.JSONResult

Bases: avocado.core.plugin_interfaces.Result

description = 'JSON result support'
name = 'json'
render(result, job)

avocado.plugins.list module

class avocado.plugins.list.List

Bases: avocado.core.plugin_interfaces.CLICmd

Implements the avocado ‘list’ subcommand

configure(parser)

Add the subparser for the list action.

Parameters:parser – Main test runner parser.
description = 'List available tests'
name = 'list'
run(args)
class avocado.plugins.list.TestLister(args)

Bases: object

Lists available test modules

list()

avocado.plugins.multiplex module

class avocado.plugins.multiplex.Multiplex(*args, **kwargs)

Bases: avocado.core.plugin_interfaces.CLICmd

Implements the avocado ‘multiplex’ subcommand

configure(parser)
description = 'Tool to analyze and visualize test variants and params'
name = 'multiplex'
run(args)

avocado.plugins.plugins module

Plugins information plugin

class avocado.plugins.plugins.Plugins

Bases: avocado.core.plugin_interfaces.CLICmd

Plugins information

configure(parser)
description = 'Displays plugin information'
name = 'plugins'
run(args)

avocado.plugins.remote module

Run tests on a remote machine.

class avocado.plugins.remote.Remote

Bases: avocado.core.plugin_interfaces.CLI

Run tests on a remote machine

configure(parser)
description = "Remote machine options for 'run' subcommand"
name = 'remote'
run(args)

avocado.plugins.replay module

class avocado.plugins.replay.Replay

Bases: avocado.core.plugin_interfaces.CLI

Replay a job

configure(parser)
description = "Replay options for 'run' subcommand"
load_config(resultsdir)
name = 'replay'
run(args)
avocado.plugins.replay.ignore_call(*args, **kwargs)

Accepts anything and does nothing

avocado.plugins.run module

Base Test Runner Plugins.

class avocado.plugins.run.Run

Bases: avocado.core.plugin_interfaces.CLICmd

Implements the avocado ‘run’ subcommand

configure(parser)

Add the subparser for the run action.

Parameters:parser – Main test runner parser.
description = 'Runs one or more tests (native test, test alias, binaryor script)'
name = 'run'
run(args)

Run test modules or simple tests.

Parameters:args – Command line args received from the run subparser.

avocado.plugins.sysinfo module

System information plugin

class avocado.plugins.sysinfo.SysInfo

Bases: avocado.core.plugin_interfaces.CLICmd

Collect system information

configure(parser)

Add the subparser for the run action.

Parameters:parser – Main test runner parser.
description = 'Collect system information'
name = 'sysinfo'
run(args)

avocado.plugins.tap module

TAP output module.

class avocado.plugins.tap.TAP

Bases: avocado.core.plugin_interfaces.CLI

TAP Test Anything Protocol output avocado plugin

configure(parser)
description = 'TAP - Test Anything Protocol results'
name = 'TAP'
run(args)
class avocado.plugins.tap.TAPResult(job, force_output_file=None)

Bases: avocado.core.result.Result

TAP output class

end_test(state)

Log the test status and details

end_tests()
start_tests()

Log the test plan

avocado.plugins.vm module

Run tests on Virtual Machine.

class avocado.plugins.vm.VM

Bases: avocado.core.plugin_interfaces.CLI

Run tests on a Virtual Machine

configure(parser)
description = "Virtual Machine options for 'run' subcommand"
name = 'vm'
run(args)

avocado.plugins.wrapper module

class avocado.plugins.wrapper.Wrapper

Bases: avocado.core.plugin_interfaces.CLI

Implements the ‘–wrapper’ flag for the ‘run’ subcommand

configure(parser)
description = "Implements the '--wrapper' flag for the 'run' subcommand"
name = 'wrapper'
run(args)

avocado.plugins.xunit module

xUnit module.

class avocado.plugins.xunit.XUnitCLI

Bases: avocado.core.plugin_interfaces.CLI

xUnit output

configure(parser)
description = 'xUnit output options'
name = 'xunit'
run(args)
class avocado.plugins.xunit.XUnitResult

Bases: avocado.core.plugin_interfaces.Result

PRINTABLE = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~\n\r '
UNKNOWN = '<unknown>'
description = 'XUnit result support'
name = 'xunit'
render(result, job)

avocado.plugins.yaml_to_mux module

Multiplexer plugin to parse yaml files to params

class avocado.plugins.yaml_to_mux.ListOfNodeObjects

Bases: list

Used to mark list as list of objects from whose node is going to be created

class avocado.plugins.yaml_to_mux.Value

Bases: tuple

Used to mark values to simplify checking for node vs. value

class avocado.plugins.yaml_to_mux.YamlToMux

Bases: avocado.core.plugin_interfaces.CLI

Registers callback to inject params from yaml file to the

configure(parser)

Configures “run” and “multiplex” subparsers

description = "YamlToMux options for the 'run' subcommand"
name = 'yaml_to_mux'
run(args)
avocado.plugins.yaml_to_mux.create_from_yaml(paths, debug=False)

Create tree structure from yaml-like file :param fileobj: File object to be processed :raise SyntaxError: When yaml-file is corrupted :return: Root of the created tree structure

Module contents