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.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd95dfaace75d84d806ab43d60d27dbac1a1f1b4e5e97c2f2fced4c56eefcf7c |
|
MD5 | 1d003ac2c11080b397b15803d75c59bf |
|
BLAKE2b-256 | 33d5bcffccc1be2dd7300e5c51c6e3bf2516c9fc12fb1784a30238c9361c882e |
Close
Hashes for coveo_testing_extras-2.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36210ef8aa631b787dfa5bb7d4480bf983ab5fbe9f1703365a99f7ed3ce75468 |
|
MD5 | 64a98d5a8daa1dd14f29398ec3845fbd |
|
BLAKE2b-256 | bafddab2472e83e8831804466abc2573453e6fdbcde3477a1626e64005d37ba5 |