Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coveo_testing_extras-3.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

coveo_testing_extras-3.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file coveo_testing_extras-3.0.tar.gz.

File metadata

  • Download URL: coveo_testing_extras-3.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.22 Linux/6.8.0-1027-azure

File hashes

Hashes for coveo_testing_extras-3.0.tar.gz
Algorithm Hash digest
SHA256 3fade182a96f567d90d0364b0ddec7365360df2ace7e0453f6d12ba5dce566df
MD5 123a856b78ebdfbb2b8655f67deffe70
BLAKE2b-256 c45786101fc59dc3f70dbaa7de1e994633dc252bc64711c95c5d74c6285e3d5d

See more details on using hashes here.

File details

Details for the file coveo_testing_extras-3.0-py3-none-any.whl.

File metadata

  • Download URL: coveo_testing_extras-3.0-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.22 Linux/6.8.0-1027-azure

File hashes

Hashes for coveo_testing_extras-3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3994855cdf7e1d4e4e9ccc9e2f01ea07cff00999abbe59c93f7146fe3dae47bb
MD5 20f8188ff63b223360508ad49e0fb660
BLAKE2b-256 2ff71b6cc65075990f8ca67a87b8298fb17a91ba9f90ebc5170ed2564ad94198

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page