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 launchmax_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 launchmax_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.