Skip to content

chore: Start the database for the test of an interrupted write outside the timeout of CancellationTest, so that a slow Docker does not break all container tests. - #3

Merged
goloroden merged 2 commits into
mainfrom
fix-container-start-under-timeout
Oct 7, 2026
Merged

goloroden merged 2 commits into
mainfrom
fix-container-start-under-timeout

Conversation

@goloroden

Copy link
Copy Markdown
Member

A local make qa failed with 62 of 149 tests at once. The first one was aWriteOfAnInterruptedThreadWritesNothing, which timed out after 10 seconds. All others failed with:

Previous attempts to find a Docker environment failed. Will not retry.

Why:

  • CancellationTest gives each test 10 seconds, and this test started its container within that time.
  • Docker was slow to answer, apparently because Docker Desktop had just resumed. The timeout then interrupted Testcontainers while it was looking for Docker.
  • Testcontainers never tries that again within the same JVM, so every later test that needed a container failed, too.

What changes:

  • The test moves to WriteEventsTest as writesNothingIfTheThreadIsInterrupted. That class starts the database in @BeforeEach, and the timeout of a class does not cover lifecycle methods. I checked that by cutting the timeout of ObserveEventsTest to one second, below the start time of a container, and its test still passed.
  • A comment in CancellationTest says why its timeout must not cover starting a container.
  • All other tests of CancellationTest use a fake server, and stay as they are.

Tests:

  • With the timeout of CancellationTest cut to 2 seconds, the test failed on main, and all tests pass on this branch.
  • make qa is green, and coverage stays at 100 %.

A second flaky failure came up in the same runs: a container whose database did not become reachable within 10 seconds, as in Go #188. That needs a change to Container, so it gets a PR of its own.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Hc2MPSLu7HDHTm8HiBsrDz

…e the timeout of CancellationTest, so that a slow Docker does not break all container tests.

CancellationTest gives each test 10 seconds, and the test of a write
whose thread is interrupted started its container within that time.
When Docker was slow to answer, e.g. right after Docker Desktop resumed,
the timeout interrupted Testcontainers while it was looking for Docker.
Testcontainers then never tries again, so every later test that needed
a container failed with "Previous attempts to find a Docker environment
failed. Will not retry."

The test now lives in WriteEventsTest, which starts the database in
@beforeeach, and the timeout of a class does not cover that. With the
timeout of CancellationTest cut to 2 seconds, the test failed before,
and all tests pass now. A comment in CancellationTest says why its
timeout must not cover starting a container.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hc2MPSLu7HDHTm8HiBsrDz
@goloroden
goloroden requested a review from a team as a code owner October 7, 2026 16:09
@goloroden goloroden self-assigned this Oct 7, 2026
@goloroden
goloroden merged commit 8a0cbf9 into main Oct 7, 2026
2 checks passed
@goloroden
goloroden deleted the fix-container-start-under-timeout branch October 7, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant