Skip to content

fix: Replace a test container whose database does not become reachable, and remove every container that failed to start. - #4

Merged
goloroden merged 2 commits into
mainfrom
fix-replace-unreachable-container
Oct 7, 2026
Merged

goloroden merged 2 commits into
mainfrom
fix-replace-unreachable-container

Conversation

@goloroden

Copy link
Copy Markdown
Member

A local make qa failed in verifiesTheHashOfAnEventWhoseDataTheServerEscapes, because its container did not start:

Timed out waiting for URL to be accessible (http://localhost:63085/api/v1/ping should return HTTP 200)

Docker Desktop sometimes does not make the port it maps a container to reachable from the host. The container keeps running, but the database in it can never be reached. start() then failed after 10 seconds, and left the container behind. The Go SDK fixed the same in #188.

What changes:

  • start() replaces such a container with a new one, up to three times.
  • If the third container fails, too, start() throws an IllegalStateException that says so, with the last failure as its cause.
  • Every other failure, e.g. an image that does not exist, or a database that exits right away, is thrown at once, as it is.
  • Either way, the container that failed to start is removed, so that it is not left behind.
  • Whether a failure is worth another attempt depends on whether the container still runs, which is what Go checks, too.
  • The public API is unchanged. Tests can replace how a container is started through a package-private field, as Go does with startContainer.

Tests:

  • New: replacing a container twice and then starting, giving up after three attempts, and throwing another failure at once. Each test also checks that no failed container is left in Docker.
  • Two mutations are caught: one attempt instead of three, and not removing a failed container.
  • make qa is green, and coverage stays at 100 %.

This will conflict with #2, which documents Container, in a few lines around the constructor and start(). Whichever merges second, I rebase.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Hc2MPSLu7HDHTm8HiBsrDz

…e, and remove every container that failed to start.

Docker Desktop sometimes does not make the port it maps a container to
reachable from the host. The container keeps running, but the database
in it can never be reached, so start() failed after waiting 10 seconds,
and left the container behind. This made tests fail now and then.

start() now replaces such a container with a new one, up to three
times, and then gives up with an exception that says why. Every other
failure, e.g. an image that does not exist, is thrown at once, as it is.
Either way, the container that failed to start is removed. This is what
the Go SDK does since its #188.

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:14
@goloroden goloroden self-assigned this Oct 7, 2026
Keeps both the starter field and the documented constructor from #2, and
describes in the Javadoc of start() that it replaces a container whose
database does not become reachable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hc2MPSLu7HDHTm8HiBsrDz
@goloroden
goloroden merged commit e88fca2 into main Oct 7, 2026
2 checks passed
@goloroden
goloroden deleted the fix-replace-unreachable-container branch October 7, 2026 17:25
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