Skip to content

plugins.aea-test-autonomy.aea_test_autonomy.docker.base

This module contains testing utilities.

DockerImage Objects

class DockerImage(ABC)

A class to wrap interaction with a Docker image.

__init__

def __init__(client: docker.DockerClient)

Initialize.

check_skip

def check_skip() -> None

Check whether the test should be skipped.

By default, nothing happens.

image

@property
@abstractmethod
def image() -> str

Return the image name.

stop_if_already_running

def stop_if_already_running() -> None

Stop the running images with the same tag, if any.

create

@abstractmethod
def create() -> Container

Instantiate the image in a container.

create_many

@abstractmethod
def create_many(nb_containers: int) -> List[Container]

Instantiate the image in many containers, parametrized.

wait

@abstractmethod
def wait(max_attempts: int = 15, sleep_rate: float = 1.0) -> bool

Wait until the image is running.

Arguments:

  • max_attempts: max number of attempts.
  • sleep_rate: the amount of time to sleep between different requests.

Returns:

True if the wait was successful, False otherwise.

launch_image

def launch_image(image: DockerImage,
                 timeout: float = 2.0,
                 max_attempts: int = 10) -> Generator[DockerImage, None, None]

Launch a single container.

Arguments:

  • image: an instance of Docker image.
  • timeout: timeout to launch
  • max_attempts: max launch attempts

Returns:

image

launch_many_containers

def launch_many_containers(
        image: DockerImage,
        nb_containers: int,
        timeout: float = 2.0,
        max_attempts: int = 10) -> Generator[DockerImage, None, None]

Launch many containers from an image.

Arguments:

  • image: an instance of Docker image.
  • nb_containers: the number of containers to launch from the image.
  • timeout: timeout to launch
  • max_attempts: max launch attempts

Returns:

image

DockerBaseTest Objects

class DockerBaseTest(ABC)

Base pytest class for setting up Docker images.

setup_class

@classmethod
def setup_class(cls) -> None

Setup up the test class.

teardown_class

@classmethod
def teardown_class(cls) -> None

Tear down the test.

setup_class_kwargs

@classmethod
@abstractmethod
def setup_class_kwargs(cls) -> Dict[str, Any]

Get kwargs for _setup_class call.