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.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ae45118a5d84e57b94fbe01fb976e671ec96c99d324b9ece83b5de49dcdfa60 |
|
MD5 | 5979cb55966e573fa902b898b8e8bc90 |
|
BLAKE2b-256 | 7983860fdb5304ad866aa93858056424f655c2520c16481c52ce9235a45bf742 |
Close
Hashes for coveo_testing_extras-1.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69b352e7e72070eb5713e0b8b2bb2b3a74fe14c12cebced3a3f04031e0c84e9a |
|
MD5 | 58c8d8bc52b61fc5bd714a01bd9f9b6b |
|
BLAKE2b-256 | 096a0b95f5587fae9c75f36f64ab60f4a006e2658cc823b77e89cfeb4717be31 |