Dependency-hungry testing helpers
Project description
coveo-testing-extras
Contains extra testing tools without dependency restrictions.
temporary resource implementation: Docker Container
The docker container temporary resource can be used to prepare short-lived containers.
- Supports building from a dockerfile
- Supports pulling images
- Can signal on AWS ECR logout
- Dynamic port mapping retrieval
- Saves log output before removing the container
Automatic AWS ECR login example
Here's how you can enhance TemporaryDockerContainerResource
with automatic ECR login:
from base64 import b64decode
import boto3
from coveo_testing_extras.temporary_resource.docker_container import (
TemporaryDockerContainerResource,
ECRLogoutException,
get_docker_client
)
class WithECR(TemporaryDockerContainerResource):
def obtain_image(self) -> None:
try:
super().obtain_image()
except ECRLogoutException:
self._do_ecr_login()
super().obtain_image()
def _do_ecr_login(self) -> None:
""" Performs an ecr login through awscli. """
assert self.ecr_region
ecr = boto3.client('ecr')
account_id, *_ = self.image_name.split('.')
assert account_id.isdigit()
authorization_data = ecr.get_authorization_token(registryIds=[account_id])['authorizationData'][0]
username, password = b64decode(authorization_data['authorizationToken']).decode().split(':')
with get_docker_client() as client:
login = client.login(username=username, password=password, registry=authorization_data['proxyEndpoint'])
assert login['Status'] == 'Login Succeeded'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for coveo_testing_extras-2.1.10.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9267c9c8eaf6415059a10128493166dbfcaa4874c6be52af3395df15c40d5ff9 |
|
MD5 | 47dbbf453d5dd89bce83fd5959cf9472 |
|
BLAKE2b-256 | bd897493196d3f73d25975862e150c15cf6bfda662405c08222838089f1e714f |
Close
Hashes for coveo_testing_extras-2.1.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8a2c99fd8dbeae32f61cce566b6c3f77faa42f68dfdfd06036f13b9c1264d7f |
|
MD5 | 62c9b56640cacbd6650b145bdf736cf4 |
|
BLAKE2b-256 | 5b8678eee77fd70effa20be177926f1e0f620d45b68c0b39d540a833a1eee5d6 |