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
File details
Details for the file coveo_testing_extras-2.1.12.tar.gz
.
File metadata
- Download URL: coveo_testing_extras-2.1.12.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.9.19 Linux/5.15.0-1064-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b0bb61828162ad1287573d673695c395f2a0124966b61ae9ee6e9ead9e0b329 |
|
MD5 | 27d3d71baf80b38559e5d3a5432dea68 |
|
BLAKE2b-256 | 4879c5b02be2f30ab8ecac922d7dc24855a4f6dd386fb236c357059140e85b61 |
File details
Details for the file coveo_testing_extras-2.1.12-py3-none-any.whl
.
File metadata
- Download URL: coveo_testing_extras-2.1.12-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.9.19 Linux/5.15.0-1064-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9442af18b1e0a16d9e242328583ef2a712700bf51acd8b25893644c8d335b28 |
|
MD5 | 18508853f23987a7a0dd2d89b7a3a16b |
|
BLAKE2b-256 | 88b3812575d5b05a8709374f12591e0c2bf1a99eb6e711cba3a4f85bfeffebdc |