Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Container Images
TESTCONTAINERS_RYUK_CONTAINER_IMAGE=testcontainers/ryuk:0.14.0
TEMPORAL__IMAGE=temporalio/temporal:1.10.1
REDIS__IMAGE=redis:8.10.3-alpine
POSTGRES__IMAGE=postgres:18.7-alpine
MYSQL__IMAGE=mysql:8.4.13
STARROCKS__IMAGE=starrocks/allin1-ubuntu:4.1.8
KEYCLOAK__IMAGE=keycloak/keycloak:26.8.2
APM_SERVER__IMAGE=elastic/apm-server:9.5.7
ELASTIC__IMAGE=elastic/elasticsearch:9.5.7
ENVOY__IMAGE=envoyproxy/envoy:v1.40.2
ELASTIC__IMAGE=elastic/elasticsearch:9.5.6
KAFKA__IMAGE=apache/kafka:4.4.0
MINIO__IMAGE=pgsty/minio:RELEASE.2026-08-04T00-00-00Z
VAULT__IMAGE=hashicorp/vault:2.2.2
KEYCLOAK__IMAGE=keycloak/keycloak:26.8.2
MAILPIT__IMAGE=axllent/mailpit:v1.34.0
MINIO__IMAGE=pgsty/minio:RELEASE.2026-08-04T00-00-00Z
MYSQL__IMAGE=mysql:8.4.13
OTEL_COLLECTOR__IMAGE=otel/opentelemetry-collector-contrib:0.165.0
POSTGRES__IMAGE=postgres:18.7-alpine
PUSHGATEWAY__IMAGE=prom/pushgateway:v1.11.5
APM_SERVER__IMAGE=elastic/apm-server:9.5.6
REDIS__IMAGE=redis:8.10.3-alpine
SCYLLADB__IMAGE=scylladb/scylla:2026.3.6
STARROCKS__IMAGE=starrocks/allin1-ubuntu:4.1.8
TEMPORAL__IMAGE=temporalio/temporal:1.10.1
TESTCONTAINERS_RYUK_CONTAINER_IMAGE=testcontainers/ryuk:0.14.0
VAULT__IMAGE=hashicorp/vault:2.2.2

AUTH__SECRET_KEY=test-only-jwt-signing-key-not-a-secret-0123456789
AUTH__TOTP__SECRET_KEY=CHANGE_ME
Expand Down
2 changes: 1 addition & 1 deletion features/elastic_adapter_apm.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: Elasticsearch Operations Testing with Elastic APM
Scenario Outline: Elasticsearch adapter spans reach Elastic APM Server <route>
Given adapter spans are exported to Elastic APM Server <route>
When I index and search a document through the Elasticsearch adapter
Then Elastic APM Server should store a span of type "external" with subtype "http"
Then Elastic APM Server should store a span of type "db" with subtype "elasticsearch"

Examples:
| route |
Expand Down
4 changes: 4 additions & 0 deletions features/shared_telemetry_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
ApmForwardingCollectorTestContainer,
ApmServerTestContainer,
OtelCollectorTestContainer,
pull_image_with_retry,
)


Expand All @@ -48,14 +49,17 @@ def main(argv: list[str]) -> int:
if arguments.collector:
collector = OtelCollectorTestContainer()
started.append(collector)
pull_image_with_retry(collector.image)
collector.start()
endpoints["otel_collector"] = _collector_entry(collector)
if arguments.apm:
apm_server = ApmServerTestContainer()
started.append(apm_server)
pull_image_with_retry(apm_server.image)
apm_server.start()
forwarder = ApmForwardingCollectorTestContainer()
started.append(forwarder)
pull_image_with_retry(forwarder.image)
forwarder.start()
endpoints.update(
elasticsearch_url=apm_server.elasticsearch_url,
Expand Down
38 changes: 38 additions & 0 deletions features/test_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import time
from pathlib import Path

import docker
import httpx2
from opentelemetry.instrumentation.utils import suppress_instrumentation
import requests
Expand Down Expand Up @@ -123,6 +124,39 @@ def _secret_value(value):
}


# Docker Hub answers 429 when many CI jobs pull the same new tag at once, and one rate-limited pull fails the
# whole feature because testcontainers raises it out of ``start()``. Pulls here retry with backoff instead.
DOCKER_PULL_ATTEMPTS = 5
DOCKER_PULL_BASE_DELAY_SECONDS = 5.0


def pull_image_with_retry(image: str) -> None:
"""Make sure ``image`` is in the local image store, retrying transient registry failures.

Args:
image: Image reference with tag, for example ``elastic/elasticsearch:9.5.7``.
"""
client = docker.from_env()
try:
client.images.get(image)
return
except docker.errors.ImageNotFound:
logger.info("Image %s is not present locally, pulling it", image)
for attempt in range(1, DOCKER_PULL_ATTEMPTS + 1):
try:
client.images.pull(image)
return
except docker.errors.APIError as error:
response = error.response
status = response.status_code if response is not None else None
transient = status is None or status == 429 or status >= 500
if attempt == DOCKER_PULL_ATTEMPTS or not transient:
raise
delay = min(DOCKER_PULL_BASE_DELAY_SECONDS * 2 ** (attempt - 1), 60.0)
logger.warning("Pulling %s failed (%s); retrying in %.0fs", image, error, delay)
time.sleep(delay)


def _wait_for_log(container: DockerContainer, pattern: str, timeout: int) -> None:
"""Block until the container logs ``pattern`` (a regex), failing after ``timeout`` seconds.

Expand Down Expand Up @@ -166,6 +200,7 @@ def get_container(cls, name: str, **kwargs):
instance = cls._container_instances[name]
# Start container if not already running (lazy startup)
if name not in cls._started_containers:
pull_image_with_retry(instance.image)
instance.start()
cls._started_containers.add(name)
return instance
Expand All @@ -175,6 +210,7 @@ def get_container(cls, name: str, **kwargs):
instance = container_class(**kwargs)
cls._container_instances[name] = instance
# Start container lazily
pull_image_with_retry(instance.image)
instance.start()
cls._started_containers.add(name)
return instance
Expand All @@ -189,6 +225,7 @@ def start_all(cls):
logger.info(f"Starting {name} container...")
container = container_class()
cls._container_instances[name] = container
pull_image_with_retry(container.image)
container.start()
cls._started_containers.add(name)

Expand Down Expand Up @@ -2134,6 +2171,7 @@ def start(self) -> DockerContainer | None:
return None

self._elasticsearch = _build_elasticsearch_container(BaseConfig.global_config().ELASTIC__IMAGE)
pull_image_with_retry(BaseConfig.global_config().ELASTIC__IMAGE)
self._elasticsearch.start()
elasticsearch_host = self._elasticsearch.get_container_host_ip()
elasticsearch_port = int(self._elasticsearch.get_exposed_port(9200))
Expand Down
2 changes: 1 addition & 1 deletion packages/redis/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version = "0.1.0" # This version is set on publish flow!
requires-python = ">=3.14,<4"
dependencies = [
"archipy==0.1.0", # Pinned to core version on publish flow!
"redis[hiredis]>=8.1.0",
"redis[hiredis]>=8.2.0",
]
license = "Apache-2.0"

Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cache = [
dependency-injection = ["dependency-injector>=4.49.1"]
elasticsearch = ["archipy-elasticsearch==0.1.0"] # Pinned to core version on publish flow!
elasticsearch-async = ["archipy-elasticsearch==0.1.0", "elasticsearch[async]>=9.5.1"] # Pinned to core version on publish flow!
fakeredis = ["fakeredis>=2.40.0"]
fakeredis = ["fakeredis>=2.41.0"]
fastapi = [
"fastapi[all]>=0.165.0",
]
Expand Down Expand Up @@ -125,9 +125,9 @@ dev = [
"pre-commit>=4.7.0",
"ruff>=0.17.6",
"ty>=0.0.108",
"types-grpcio>=1.85.0.20261028",
"types-protobuf>=7.35.1.20260906",
"types-pymysql>=1.2.4.20261116",
"types-grpcio>=1.85.0.20261122",
"types-protobuf>=7.35.1.20261122",
"types-pymysql>=1.2.4.20261122",
"validate-pyproject>=0.27",
]

Expand Down
Loading
Loading