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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f694bcd2c3ec7d5bcca26215be7cc051041b7b8e1222d11f565eaf9c1e808aa4 |
|
MD5 | 2440434132bb0b0e3be97aa709d98ab5 |
|
BLAKE2b-256 | 8aa86def6a9687c7235dca37bcd23deeae41d336ad0ff28a34d543efc2b5ed3b |
Close
Hashes for coveo_testing_extras-2.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f78d7e0c7d4b473e8702fa7964488a5400b4abc0f15890632fb7b17f420ab8b |
|
MD5 | 620fd3e4e91854107be52923ae5b791c |
|
BLAKE2b-256 | 8301c1ccdae5ce9620cd0a61225e0e13db332ed467690a5c14cb1f0df1f4ab4d |