avocado.core.spawners package¶
Submodules¶
avocado.core.spawners.common module¶
-
class
avocado.core.spawners.common.
SpawnMethod
¶ Bases:
enum.Enum
The method employed to spawn a runnable or task.
-
ANY
= <object object>¶ Spawns with any method available, that is, it doesn’t declare or require a specific spawn method
-
PYTHON_CLASS
= <object object>¶ Spawns by running executing Python code, that is, having access to a runnable or task instance, it calls its run() method.
-
STANDALONE_EXECUTABLE
= <object object>¶ Spawns by running a command, that is having either a path to an executable or a list of arguments, it calls a function that will execute that command (such as with os.system())
-
-
class
avocado.core.spawners.common.
SpawnerMixin
(config=None, job=None)¶ Bases:
object
Common utilities for Spawner implementations.
-
METHODS
= []¶
-
static
bytes_from_file
(filename)¶ Read bytes from a files in binary mode.
This is a helpful method to read local files bytes efficiently.
If the spawner that you are implementing needs access to local file, feel free to use this method.
-
static
stream_output
(job_id, task_id)¶ Returns output files streams in binary mode from a task.
This method will find for output files generated by a task and will return a generator with tuples, each one containing a filename and bytes.
You need to provide in your spawner a stream_output() method if this one is not suitable for your spawner. i.e: if the spawner is trying to access a remote output file.
-
task_output_dir
(runtime_task)¶
-
avocado.core.spawners.exceptions module¶
avocado.core.spawners.mock module¶
-
class
avocado.core.spawners.mock.
MockRandomAliveSpawner
¶ Bases:
avocado.core.spawners.mock.MockSpawner
A mocking spawner that simulates randomness about tasks being alive.
-
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.
-
-
class
avocado.core.spawners.mock.
MockSpawner
¶ Bases:
avocado.core.plugin_interfaces.Spawner
A mocking spawner that performs no real operation.
Tasks asked to be spawned by this spawner will initially reported to be alive, and on the next check, will report not being alive.
-
METHODS
= [<SpawnMethod.PYTHON_CLASS: <object object>>, <SpawnMethod.STANDALONE_EXECUTABLE: <object object>>]¶
-
static
check_task_requirements
(runtime_task)¶ Checks if the requirements described within a task are available.
Parameters: runtime_task ( avocado.core.task.runtime.RuntimeTask
) – wrapper for a Task with additional runtime information.
-
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 requirementReturns: 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.
-
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
-
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.
-
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.
-
static
update_requirement_cache
(runtime_task, result)¶ Updates the information about requirement in cache based on result.
Parameters: - runtime_task (
avocado.core.task.runtime.RuntimeTask
) – runtime task with requirement - result (avocado.core.teststatus.STATUSES) – result of runtime_task
- runtime_task (
-
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.
-