Skip to content

Stabilize testcontainers provider tests on slow (ARM) CI runners - #68963

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:harden-mongo-testcontainer-arm-ci
Jun 26, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
potiuk:harden-mongo-testcontainer-arm-ci

Conversation

@potiuk

@potiuk potiuk commented Jun 25, 2026

Copy link
Copy Markdown
Member

Problem

The mongo provider tests boot a real mongo:8.0 container via testcontainers (since #53773 dropped mongomock). The whole bring-up — image pull, container start, readiness ping — happens in the setup phase of the first test that uses the session fixture, and must fit inside the per-test pytest --setup-timeout (60s).

On the GitHub-hosted ARM canary (ubuntu-22.04-arm), where the Docker image cache is cold and registry/disk throughput is lower, the mongo:8.0 pull alone (~17–19s observed) eats much of that 60s budget, so setup times out → cascade of ERROR at setup of TestMongoHook.* (Failed: Timeout >60.0s). AMD doesn't hit it because it runs on every PR with warm caches; ARM only runs on the cron canary. (Same run, Py3.11 mongo passed while Py3.10 timed out — a timing/infra signature, not a code defect, and not emulation: ARM runners are native arm64 with a native mongo:8.0 image, no QEMU.)

Changes

A. Pre-pull testcontainers images out of the timed path. Before a parallel provider run, pull the images on the shared host daemon — but only in CI, and only when the owning provider's tests are actually selected (e.g. skip when the run is Providers[mysql,...] without mongo, or excludes it). Locally it's a no-op; testcontainers pulls on demand as before. Keyed by provider in TESTCONTAINERS_IMAGES_BY_PROVIDER so it scales to future testcontainers-based providers.

B. Higher floor for setup/teardown timeouts. Container-backed fixtures do their work in setup/teardown, so floor those at 180s (max(test_timeout, 180)) while keeping execution-timeout at the per-test value so genuinely hung tests are still caught quickly. Belt-and-suspenders for cold-cache or other slow bring-ups.

Both are scoped so normal per-test hang-detection and local behavior are unchanged.

Tests: added coverage for the timeout floor and for the CI/provider-scoped pre-pull (selected / excluded / non-providers / outside-CI). mypy-dev + ruff clean.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8)

Generated-by: Claude Code (Opus 4.8) following the guidelines

The mongo provider tests boot a real mongo:8.0 container via testcontainers
in the setup phase of the first test that uses the session fixture. That
bring-up -- image pull, container start, readiness ping -- has to fit inside
the per-test pytest setup-timeout (60s). On the GitHub-hosted ARM canary,
where the image cache is cold and registry/disk throughput is lower, the
pull alone can eat most of that budget, so setup times out and cascades into
"ERROR at setup" across every TestMongoHook test. AMD does not hit this
because it runs on every PR with warm caches; ARM only runs on the cron
canary.

Two complementary changes:

- Pre-pull the testcontainers images (mongo:8.0 + ryuk) on the shared host
  daemon before the timed run, but only in CI and only when the owning
  provider's tests are actually in the selection -- so the slow cold-cache
  pull happens outside the per-test setup timeout. Locally it stays a no-op.

- Give pytest setup/teardown timeouts a higher floor (180s) for container-
  backed fixtures, while keeping execution-timeout at the per-test value so
  genuinely hung tests are still caught quickly.
@potiuk
potiuk merged commit 9b0fe28 into apache:main Jun 26, 2026
145 checks passed
@potiuk
potiuk deleted the harden-mongo-testcontainer-arm-ci branch June 26, 2026 18:50
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-3-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-3-test PR Link

github-actions Bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Jun 26, 2026
…runners (apache#68963)

The mongo provider tests boot a real mongo:8.0 container via testcontainers
in the setup phase of the first test that uses the session fixture. That
bring-up -- image pull, container start, readiness ping -- has to fit inside
the per-test pytest setup-timeout (60s). On the GitHub-hosted ARM canary,
where the image cache is cold and registry/disk throughput is lower, the
pull alone can eat most of that budget, so setup times out and cascades into
"ERROR at setup" across every TestMongoHook test. AMD does not hit this
because it runs on every PR with warm caches; ARM only runs on the cron
canary.

Two complementary changes:

- Pre-pull the testcontainers images (mongo:8.0 + ryuk) on the shared host
  daemon before the timed run, but only in CI and only when the owning
  provider's tests are actually in the selection -- so the slow cold-cache
  pull happens outside the per-test setup timeout. Locally it stays a no-op.

- Give pytest setup/teardown timeouts a higher floor (180s) for container-
  backed fixtures, while keeping execution-timeout at the per-test value so
  genuinely hung tests are still caught quickly.
(cherry picked from commit 9b0fe28)

Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
aws-airflow-bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Jun 26, 2026
…runners (apache#68963)

The mongo provider tests boot a real mongo:8.0 container via testcontainers
in the setup phase of the first test that uses the session fixture. That
bring-up -- image pull, container start, readiness ping -- has to fit inside
the per-test pytest setup-timeout (60s). On the GitHub-hosted ARM canary,
where the image cache is cold and registry/disk throughput is lower, the
pull alone can eat most of that budget, so setup times out and cascades into
"ERROR at setup" across every TestMongoHook test. AMD does not hit this
because it runs on every PR with warm caches; ARM only runs on the cron
canary.

Two complementary changes:

- Pre-pull the testcontainers images (mongo:8.0 + ryuk) on the shared host
  daemon before the timed run, but only in CI and only when the owning
  provider's tests are actually in the selection -- so the slow cold-cache
  pull happens outside the per-test setup timeout. Locally it stays a no-op.

- Give pytest setup/teardown timeouts a higher floor (180s) for container-
  backed fixtures, while keeping execution-timeout at the per-test value so
  genuinely hung tests are still caught quickly.
(cherry picked from commit 9b0fe28)

Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
potiuk added a commit that referenced this pull request Jun 26, 2026
…runners (#68963) (#69054)

The mongo provider tests boot a real mongo:8.0 container via testcontainers
in the setup phase of the first test that uses the session fixture. That
bring-up -- image pull, container start, readiness ping -- has to fit inside
the per-test pytest setup-timeout (60s). On the GitHub-hosted ARM canary,
where the image cache is cold and registry/disk throughput is lower, the
pull alone can eat most of that budget, so setup times out and cascades into
"ERROR at setup" across every TestMongoHook test. AMD does not hit this
because it runs on every PR with warm caches; ARM only runs on the cron
canary.

Two complementary changes:

- Pre-pull the testcontainers images (mongo:8.0 + ryuk) on the shared host
  daemon before the timed run, but only in CI and only when the owning
  provider's tests are actually in the selection -- so the slow cold-cache
  pull happens outside the per-test setup timeout. Locally it stays a no-op.

- Give pytest setup/teardown timeouts a higher floor (180s) for container-
  backed fixtures, while keeping execution-timeout at the per-test value so
  genuinely hung tests are still caught quickly.
(cherry picked from commit 9b0fe28)

Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
karenbraganz pushed a commit to karenbraganz/airflow that referenced this pull request Jun 30, 2026
…che#68963)

The mongo provider tests boot a real mongo:8.0 container via testcontainers
in the setup phase of the first test that uses the session fixture. That
bring-up -- image pull, container start, readiness ping -- has to fit inside
the per-test pytest setup-timeout (60s). On the GitHub-hosted ARM canary,
where the image cache is cold and registry/disk throughput is lower, the
pull alone can eat most of that budget, so setup times out and cascades into
"ERROR at setup" across every TestMongoHook test. AMD does not hit this
because it runs on every PR with warm caches; ARM only runs on the cron
canary.

Two complementary changes:

- Pre-pull the testcontainers images (mongo:8.0 + ryuk) on the shared host
  daemon before the timed run, but only in CI and only when the owning
  provider's tests are actually in the selection -- so the slow cold-cache
  pull happens outside the per-test setup timeout. Locally it stays a no-op.

- Give pytest setup/teardown timeouts a higher floor (180s) for container-
  backed fixtures, while keeping execution-timeout at the per-test value so
  genuinely hung tests are still caught quickly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants