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.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b5deb39cdb1b8133c9db5bc7d954d3aa9213e4ccee6447ef62c2674fc64c894 |
|
MD5 | 62604ef9a351441ce885a2f498197b9d |
|
BLAKE2b-256 | 0a1f99c7ab3fe5ee389911b90f04efc67f0bce734da44efe53f3d3f1c913bbcf |
Close
Hashes for coveo_testing_extras-2.1.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0ae9859fd5c020aad842a5502e04bc036f399d5fea509ad2cf3667a95521bb8 |
|
MD5 | cb4c83a99ae865aee5886146effd455e |
|
BLAKE2b-256 | a8e771a296c0527f0a2d1c4110fb5cd4f541f342944bb652c82adc6de4a0b376 |