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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2109bbca39bb1a1ea7b4b765125b3d9a3fbc3d0076272cb725063d352d991968 |
|
MD5 | 5a9ef09d268c1bf4dc772c6942b65ad3 |
|
BLAKE2b-256 | 37e2c0a8ec4906b50799c893d975943e2e1ca2999a8771e9752b634a47ff489d |
Close
Hashes for coveo_testing_extras-2.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa28ab23e94c62f4df92140b1f8849283e624574758b49d64d20384641f15a4f |
|
MD5 | 771e2d20bf5b44df454d27227811c532 |
|
BLAKE2b-256 | c1d0a2c02999bbe1a16ccec0e7369e429e196af810182a1b82c624191581dfa0 |