avocado.plugins.spawners package

Submodules

avocado.plugins.spawners.lxc module

class avocado.plugins.spawners.lxc.LXCSpawner(config=None, job=None)

Bases: Spawner, SpawnerMixin

METHODS = [SpawnMethod.STANDALONE_EXECUTABLE]
async static check_task_requirements(runtime_task)

Check the runtime task requirements needed to be able to run

create_task_output_dir(runtime_task)

Creates output directory in the intended location, before the task spawn.

The output directory path will be saved to the task.runnable.config for the usage by runners.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

description = 'LXC (container) based spawner'
is_operational()

Checks whether this spawner is operationally capable to perform.

Result:

whether or not this spawner is operational on this system, that is, whether it has all its requirements set up and should be ready to operate successfully.

Return type:

bool

async static is_requirement_in_cache(runtime_task)

Checks if it’s necessary to run the requirement.

There are occasions when the similar requirement has been run and its results are already saved in cache. In such occasion, it is not necessary to run the task again. For example, this might be useful for tasks which would install the same package to the same environment.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – runtime task with requirement

Returns:

If the results are already in cache.

Return type:

True if task is in cache False if task is not in cache None if task is running in different process and should be in cache soon.

static is_task_alive(runtime_task)

Determines if a task is alive or not.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

reserve_slot(runtime_task)

Reserve a free or custom container slot for the runtime task.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – runtime task to reserve the slot for

Yields:

a free slot to use if such was found

Raises:

RuntimeError if no free slot could be found

This will either use a runtime cache to find a free container slot to run the task in or use a custom container/slot ID to allow for custom schedulers to make their own decisions on which containers to run when.

static run_container_cmd(container, command)
async static run_container_cmd_async(container, command)
async static save_requirement_in_cache(runtime_task)

Saves the information about requirement in cache before the runtime_task is run.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – runtime task with requirement

slots_cache = {}
async spawn_task(runtime_task)

Spawns a task return whether the spawning was successful.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

async terminate_task(runtime_task)

Terminates a task before finish.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

Returns:

whether the task has been fully terminated or not

Return type:

bool

async static update_requirement_cache(runtime_task, result)

Updates the information about requirement in cache based on result.

Parameters:
async wait_task(runtime_task)

Waits for a task to finish.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

exception avocado.plugins.spawners.lxc.LXCSpawnerException

Bases: Exception

Errors more closely related to the spawner functionality

class avocado.plugins.spawners.lxc.LXCSpawnerInit

Bases: Init

description = 'LXC (container) based spawner initialization'
initialize()

Entry point for the plugin to perform its initialization.

class avocado.plugins.spawners.lxc.LXCStreamsFile

Bases: object

fileno()
read()
avocado.plugins.spawners.lxc.with_slot_reservation(fn)

Decorator for slot cache context manager.

Parameters:

fn (function) – function to run with slot reservation

Returns:

same function with the slot now reserved

Return type:

function

The main reason for the decorator is to not have to indent the entire task running function in order to safely release the slot upon any error.

avocado.plugins.spawners.podman module

class avocado.plugins.spawners.podman.PodmanCLI

Bases: CLI

configure(parser)

Configures the command line parser with options specific to this plugin.

description = 'podman spawner command line options for "run"'
name = 'podman'
run(config)

Execute any action the plugin intends.

Example of action may include activating a special features upon finding that the requested command line options were set by the user.

Note: this plugin class is not intended for adding new commands, for that please use CLICmd.

class avocado.plugins.spawners.podman.PodmanSpawner(config=None, job=None)

Bases: DeploymentSpawner, SpawnerMixin

METHODS = [SpawnMethod.STANDALONE_EXECUTABLE]
async static check_task_requirements(runtime_task)

Check the runtime task requirements needed to be able to run

create_task_output_dir(runtime_task)

Creates output directory in the intended location, before the task spawn.

The output directory path will be saved to the task.runnable.config for the usage by runners.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

async deploy_artifacts()

Basic artifacts deployment for the isolated environment.

During this stage test references (i.e: mytest.py), data files (i.e: mytest.py.data/), and any other basic requirement should be deployed to the isolated environment. Please keep in mind that test requirements defined at the requirements resolver level are not part of this deployment and it will be fulfilled by the requirement resolver.

This method should also be executed before spawning the task.

async deploy_avocado(where)

Avocado deployment for the isolated environment.

This method should be executed before spawning the task.

Parameters:

where – handle for where the spawner should deploy avocado. You can use this parameter to pass any valid argument, like a container, vm, or any other isolated environment object or identifier.

description = 'Podman (container) based spawner'
get_eggs_paths(py_major, py_minor)

Return the basic eggs needed to bootstrap Avocado.

This will return a tuple with the current location and where this should be deployed.

is_operational()

Checks whether this spawner is operationally capable to perform.

Result:

whether or not this spawner is operational on this system, that is, whether it has all its requirements set up and should be ready to operate successfully.

Return type:

bool

async is_requirement_in_cache(runtime_task)

Checks if it’s necessary to run the requirement.

There are occasions when the similar requirement has been run and its results are already saved in cache. In such occasion, it is not necessary to run the task again. For example, this might be useful for tasks which would install the same package to the same environment.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – runtime task with requirement

Returns:

If the results are already in cache.

Return type:

True if task is in cache False if task is not in cache None if task is running in different process and should be in cache soon.

is_task_alive(runtime_task)

Determines if a task is alive or not.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

property podman
property podman_version
property python_version
async save_requirement_in_cache(runtime_task)

Saves the information about requirement in cache before the runtime_task is run.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – runtime task with requirement

async spawn_task(runtime_task)

Spawns a task return whether the spawning was successful.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

async terminate_task(runtime_task)

Terminates a task before finish.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

Returns:

whether the task has been fully terminated or not

Return type:

bool

async update_requirement_cache(runtime_task, result)

Updates the information about requirement in cache based on result.

Parameters:
async wait_task(runtime_task)

Waits for a task to finish.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

exception avocado.plugins.spawners.podman.PodmanSpawnerException

Bases: PodmanException

Errors more closely related to the spawner functionality

class avocado.plugins.spawners.podman.PodmanSpawnerInit

Bases: Init

description = 'Podman (container) based spawner initialization'
initialize()

Entry point for the plugin to perform its initialization.

avocado.plugins.spawners.process module

class avocado.plugins.spawners.process.ProcessSpawner(config=None, job=None)

Bases: Spawner, SpawnerMixin

METHODS = [SpawnMethod.STANDALONE_EXECUTABLE]
async static check_task_requirements(runtime_task)

Check the runtime task requirements needed to be able to run

create_task_output_dir(runtime_task)

Creates output directory in the intended location, before the task spawn.

The output directory path will be saved to the task.runnable.config for the usage by runners.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

description = 'Process based spawner'
is_operational()

Checks whether this spawner is operationally capable to perform.

Result:

whether or not this spawner is operational on this system, that is, whether it has all its requirements set up and should be ready to operate successfully.

Return type:

bool

async static is_requirement_in_cache(runtime_task)

Checks if it’s necessary to run the requirement.

There are occasions when the similar requirement has been run and its results are already saved in cache. In such occasion, it is not necessary to run the task again. For example, this might be useful for tasks which would install the same package to the same environment.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – runtime task with requirement

Returns:

If the results are already in cache.

Return type:

True if task is in cache False if task is not in cache None if task is running in different process and should be in cache soon.

static is_task_alive(runtime_task)

Determines if a task is alive or not.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

async static save_requirement_in_cache(runtime_task)

Saves the information about requirement in cache before the runtime_task is run.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – runtime task with requirement

async spawn_task(runtime_task)

Spawns a task return whether the spawning was successful.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

async terminate_task(runtime_task)

Terminates a task before finish.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

Returns:

whether the task has been fully terminated or not

Return type:

bool

async static update_requirement_cache(runtime_task, result)

Updates the information about requirement in cache based on result.

Parameters:
async static wait_task(runtime_task)

Waits for a task to finish.

Parameters:

runtime_task (avocado.core.task.runtime.RuntimeTask) – wrapper for a Task with additional runtime information.

class avocado.plugins.spawners.process.ProcessSpawnerHandle(process)

Bases: object

create_wait_task()
property wait_task

Module contents