SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
test(e2e): fix teardown crashes (network endpoint race + eager keeper lookup) (#12204)
Ashwin Bhatkal564d479aae46
diff --git a/tests/fixtures/clickhouse.py b/tests/fixtures/clickhouse.pyindex ba334ae628..172a32e53f 100644--- a/tests/fixtures/clickhouse.py+++ b/tests/fixtures/clickhouse.py@@ -203,9 +203,9 @@ def create_clickhouse( # pylint: disable=too-many-arguments,too-many-positionalpytestconfig: pytest.Config,cache_key: str = "clickhouse",) -> types.TestContainerClickhouse:- coordinator = next(iter(keeper.container_configs.values()))-def create() -> types.TestContainerClickhouse:+ # Lazy: the keeper fixture is empty under --teardown (never created).+ coordinator = next(iter(keeper.container_configs.values()))clickhouse_version = request.config.getoption("--clickhouse-version")container = ClickHouseContainer(@@ -381,9 +381,10 @@ def create_clickhouse_cluster( # pylint: disable=too-many-arguments,too-many-pomigration goes through. Per-node containers are exposed via `nodes` sotests can assert shard-local state."""- coordinator = next(iter(keeper.container_configs.values()))def create() -> types.TestContainerClickhouse:+ # Lazy: the keeper fixture is empty under --teardown (never created).+ coordinator = next(iter(keeper.container_configs.values()))clickhouse_version = request.config.getoption("--clickhouse-version")# Unique aliases per creation: docker allows duplicate network aliasesdiff --git a/tests/fixtures/network.py b/tests/fixtures/network.pyindex ddcdb6442e..6d7f08f241 100644--- a/tests/fixtures/network.py+++ b/tests/fixtures/network.py@@ -1,3 +1,5 @@+import time+import dockerimport docker.errorsimport pytest@@ -23,12 +25,37 @@ def network(request: pytest.FixtureRequest, pytestconfig: pytest.Config) -> typedef delete(nw: types.Network):client = docker.from_env()try:- client.networks.get(network_id=nw.id).remove()+ network = client.networks.get(network_id=nw.id)except docker.errors.NotFound:logger.info("Skipping removal of Network, Network(%s) not found. Maybe it was manually removed?",{"name": nw.name, "id": nw.id},)+ return++ # Docker detaches endpoints asynchronously, so the network can briefly+ # report "has active endpoints" after its containers are gone. Retry,+ # force-disconnecting any stragglers.+ last_err: docker.errors.APIError | None = None+ for _ in range(10):+ try:+ network.remove()+ return+ except docker.errors.NotFound:+ return+ except docker.errors.APIError as err:+ if "has active endpoints" not in str(err):+ raise+ last_err = err+ network.reload()+ for container_id in network.attrs.get("Containers") or {}:+ try:+ network.disconnect(container_id, force=True)+ except docker.errors.APIError:+ pass+ time.sleep(1)++ raise last_errdef restore(existing: dict) -> types.Network:client = docker.from_env()