Skip to content

feat(wait): backport ForAny and wait cleanups from testcontainers-go - #171

Merged
mdelapenya merged 8 commits into
mainfrom
feat/wait-backport-tcgo
Oct 23, 2026
Merged

mdelapenya merged 8 commits into
mainfrom
feat/wait-backport-tcgo

Conversation

@mdelapenya

@mdelapenya mdelapenya commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

🤖 Automated implementer agent — this comment was posted by the implementer bot from AI Factory, not by a human developer

Backports the missing wait/ changes from testcontainers-go into container/wait, preserving original authorship (each commit keeps its upstream author and date, a Backported-from: trailer with the upstream SHA, and "Backport notes" listing the adaptations). Added with git format-patch -1 <sha> -- wait/ | git am -3 --directory=container.

Refs #147 (already closed; this delivers wait.ForAny).

Commits

# Upstream Author Notes
1 testcontainers/testcontainers-go#3208 Tiago Peczenyj slices.Delete in walk.go; keeps go-sdk's ErrVisitStop
2 testcontainers/testcontainers-go#3568 (partial) Manuel de la Peña drops obsolete // +build line in errors.go
3 testcontainers/testcontainers-go#3719 Jean Barkhuysen wait.ForAny / AnyMultiStrategy. Adapted: ErrVisitStop, &NopStrategyTarget{}, WithTimeout, typed network.Port, import path. The synctest test stays in any_test.go with no //go:build go1.25 tag (go-sdk is on Go 1.27). Upstream issue: testcontainers/testcontainers-go#3717
4 testcontainers/testcontainers-go#3603 Mateen Anjum exit/health tests moved to the generated mockery mocks; adapted import path and WithTimeout; dropped stray Logger() hunk
5 docs (go-sdk authored) — documents wait.ForAny in container/README.md
6 go-sdk only (no Backported-from:) — fix(wait): support non-pointer Strategy implementations in ForAny — review follow-up for a reflect.IsNil panic in the upstream code
7 go-sdk only (no Backported-from:) — fix(wait): support non-pointer Strategy implementations in ForAll — same fix for MultiStrategy
8 go-sdk only (no Backported-from:) — tidy ForAny select, add a Walk test for AnyMultiStrategy, fix ExampleForAny timeouts

Commits 1–4 are the upstream-authored backports; 5–8 are go-sdk-authored.

Not included

Merge method — maintainer's choice

Authorship is preserved only with "Rebase and merge". .github/settings.yml currently has allow_rebase_merge: false (I did not modify it). A squash merge would attribute everything to the PR author; in that case add these trailers to the squash message:

Co-authored-by: Jean Barkhuysen <jean.barkhuysen@gmail.com>
Co-authored-by: Tiago Peczenyj <tpeczenyj@weborama.com>
Co-authored-by: Mateen Anjum <mateenali66@gmail.com>

Verification

After every commit: go build ./..., go vet ./wait/, go test ./wait/ (Go 1.27.3) and golangci-lint v2.15.0 on container/wait — all clean.

peczenyj and others added 5 commits October 23, 2026 10:29
…iners/testcontainers-go#3208)

Apply gopls modernize tool with fix and format code.

Backport note: only the container/wait part (walk.go: slices.Delete) is ported;
the conflict is resolved to keep go-sdk's ErrVisitStop.

Backported-from: testcontainers/testcontainers-go@42824ba
Partial backport of testcontainers/testcontainers-go#3568
("chore(compose): update to compose-v5"): only the wait/errors.go change,
removing the legacy "// +build !windows" line (the //go:build line remains).

Backported-from: testcontainers/testcontainers-go@d2d0d10
…estcontainers/testcontainers-go#3719)

* feat(wait): implement AnyMultiStrategy: ForAny equivalent to ForAll.

Upstream issue: testcontainers/testcontainers-go#3717.

* fix: lint

Signed-off-by: mdelapenya <mdelapenya@gmail.com>

* fix: formatting

Signed-off-by: mdelapenya <mdelapenya@gmail.com>

---------

Backport notes (go-sdk adaptations):
- walk.go: keep go-sdk's ErrVisitStop (the deprecated VisitStop alias was removed)
- tests: use &NopStrategyTarget{} (pointer receivers in go-sdk), WithTimeout
  instead of WithStartupTimeout, typed network.Port in ForListeningPort
- examples: import github.com/docker/go-sdk/container/wait
- TestAnyMultiStrategy_WaitsForAny keeps its testing/synctest.Test usage without a
  //go:build go1.25 constraint: go-sdk is on Go 1.27
- docs/ changes not ported (go-sdk has no docs site)

Signed-off-by: mdelapenya <mdelapenya@gmail.com>
Co-authored-by: mdelapenya <mdelapenya@gmail.com>
Backported-from: testcontainers/testcontainers-go@96ab095
…ry mocks (testcontainers/testcontainers-go#3603)

* chore(wait): apply review suggestions to exit_test and health_test

- Switch to package wait_test
- Replace hand-written mocks with mockStrategyTarget + typed EXPECT() chains
- Use anyContext matcher for context args
- Use moby/moby import paths (not docker/docker)
- Use typed container state constants
- Extract newStateTarget() helper in health_test.go
- Replace goroutine+mutex pattern in TestWaitForHealthWithNil with RunAndReturn closure

Addresses review feedback on PR testcontainers/testcontainers-go#3603.

* test(wait): add t.Helper() to newStateTarget

Satisfies the thelper linter; newStateTarget is a test helper.

Signed-off-by: Mateen Anjum <mateenali66@gmail.com>

---------

Backport notes (go-sdk adaptations): import github.com/docker/go-sdk/container/wait,
use WithTimeout instead of WithExitTimeout/WithStartupTimeout, and drop the
go-sdk-only healthStrategyTarget.Logger() helper along with the hand-written target.

Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
Co-authored-by: Manuel de la Peña <social.mdelapenya@gmail.com>
Backported-from: testcontainers/testcontainers-go@eb511c4
@mdelapenya
mdelapenya requested a review from robmry October 23, 2026 10:38
@mdelapenya
mdelapenya marked this pull request as ready for review October 23, 2026 10:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T10:40:20.810973Z a5b6081 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a5b6081ae7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread container/wait/any.go Outdated
reflect.Value.IsNil panics for non-nil-capable kinds such as structs, so
ForAny(valueStrategy{}) crashed in WaitUntilReady and String. Guard the
reflected kind before calling IsNil and add a regression test.

Follow-up to the testcontainers/testcontainers-go#3719 backport; addresses
review feedback on PR #171. The same pattern exists in MultiStrategy (all.go)
and is left unchanged here.
robmry
robmry previously approved these changes Oct 23, 2026

@robmry robmry left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ForAny backport mirrors ForAll's structure, and the walk.go refactor to walkAndMutate looks right.

Verified at 891c1b80 (Go 1.27.3):

  • go test -race -count=3 ./wait/ passes and go vet ./wait/ is clean.
  • A throwaway test that removed the middle ForLog from ForAny(nop, log, nop) through Walk returned no error and left 2 strategies, so the new walk branch works.
  • mockStrategyTarget, anyContext and nilWaitStrategy all exist, and nothing outside wait/ type-switches on *MultiStrategy.

Inline comments cover the ForAll value-type panic, a missing walk test, a no-op for loop, the wall-clock health test and the example's timeouts. None of them blocks the merge.

PR description: the commit table lists 5 commits but the PR has 6. The sixth, fix(wait): support non-pointer Strategy implementations in ForAny, is go-sdk-only and has no Backported-from: trailer. Please add it to the table.

Merge method: .github/settings.yml sets allow_rebase_merge: false, so preserving authorship needs either that setting flipped or a squash with the three Co-authored-by: trailers from the description. That is a maintainer decision.

Reviewed by Claude Code on behalf of @robmry.

Comment thread container/wait/any.go
Comment thread container/wait/any.go Outdated
Comment thread container/wait/walk.go
Comment thread container/wait/health_test.go
Comment thread container/wait/wait_examples_test.go
Reuse isNilStrategy in MultiStrategy so ForAll(valueStrategy{}) no longer
panics in String and WaitUntilReady, matching ForAny. Adds a regression test.

Addresses review feedback on PR #171.
…meouts

- any.go: the select always returns, drop the redundant for loop
- walk_test.go: add a Walk case for AnyMultiStrategy (visit, remove)
- wait_examples_test.go: ExampleForAny no longer shows a 10s timeout that
  would fail the whole ForAny early; note that the shortest timeout bounds it

Addresses review feedback on PR #171.
@mdelapenya
mdelapenya merged commit 7a0da8f into main Oct 23, 2026
11 checks passed
@mdelapenya
mdelapenya deleted the feat/wait-backport-tcgo branch October 23, 2026 13:46
mdelapenya added a commit to testcontainers/testcontainers-go that referenced this pull request Oct 23, 2026
…#4052)

reflect.Value.IsNil panics for non-nil-capable kinds such as structs, so
ForAny(valueStrategy{}) and ForAll(valueStrategy{}) crashed in String and
WaitUntilReady. Add an isNilStrategy helper that only calls IsNil on
nil-capable kinds and use it in AnyMultiStrategy and MultiStrategy.

Also tidy AnyMultiStrategy.WaitUntilReady (the select always returns, so
drop the for loop), cover Walk on ForAny, and fix ExampleForAny timeouts:
a strategy hitting its own timeout fails the whole ForAny, so the shortest
timeout bounds the wait.

Backport of fixes found in docker/go-sdk#171.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
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.

5 participants