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-1.0.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56bdefc0aa00d485b2a098477fc5fcb95868092da5da71d4789101d8d7dc2d96 |
|
MD5 | 968b4ac848f5445d9944ad41953cb05e |
|
BLAKE2b-256 | 9f8bc99a1c602af5edf200d70138ae3d00465a0a082493c40970183c7659f5bf |
Close
Hashes for coveo_testing_extras-1.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c188d7886d17f0feec86f97050b00954db9f68e8ec2ec17a17623380f88776ef |
|
MD5 | 0edd106eef68ab5ab59d110205c7040f |
|
BLAKE2b-256 | 91c1f0a5b34d47b296caf0aad489ebcb334ebb879195e6447ed4d6dd7299e8a7 |