Skip to content

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

Open
mdelapenya wants to merge 55 commits into
mateenali66:feat/issue-2765-generated-mocks-waitfrom
mdelapenya:fix/pr-3603-review-suggestions-v2
Open

chore(wait): apply review suggestions to exit_test and health_test#1
mdelapenya wants to merge 55 commits into
mateenali66:feat/issue-2765-generated-mocks-waitfrom
mdelapenya:fix/pr-3603-review-suggestions-v2

Conversation

@mdelapenya

Copy link
Copy Markdown

Review feedback from the testcontainers maintainers on PR testcontainers#3603.

Changes

  • wait/exit_test.go and wait/health_test.go migrated from package wait to package wait_test
  • Hand-written mock structs removed; replaced with mockStrategyTarget (already generated and checked in)
  • Typed EXPECT() chains used throughout — consistent with file_test.go and log_test.go
  • anyContext matcher reused for context arguments (not bare mock.Anything)
  • Import paths updated to github.com/moby/moby/api/types/container
  • Typed container.State* constants used instead of raw string literals
  • newStateTarget(t, state) helper extracted in health_test.go, mirroring newRunningTarget pattern
  • TestWaitForHealthWithNil: goroutine+mutex pattern replaced with a RunAndReturn time-based closure

Test results

All 7 tests pass on current main:

--- PASS: TestWaitForExit (0.00s)
--- PASS: TestWaitForHealthTimesOutForUnhealthy (0.20s)
--- PASS: TestWaitForHealthSucceeds (0.00s)
--- PASS: TestWaitForHealthWithNil (0.20s)
--- PASS: TestWaitForHealthFailsDueToOOMKilledContainer (0.00s)
--- PASS: TestWaitForHealthFailsDueToExitedContainer (0.00s)
--- PASS: TestWaitForHealthFailsDueToUnexpectedContainerStatus (0.00s)
ok  github.com/testcontainers/testcontainers-go/wait  0.413s

dependabot Bot and others added 30 commits March 30, 2026 22:53
Bumps [pygments](https://github.com/pygments/pygments) from 2.19.2 to 2.20.0.
- [Release notes](https://github.com/pygments/pygments/releases)
- [Changelog](https://github.com/pygments/pygments/blob/master/CHANGES)
- [Commits](pygments/pygments@2.19.2...2.20.0)

---
updated-dependencies:
- dependency-name: pygments
  dependency-version: 2.20.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…-pass approach (testcontainers#3620)

* fix(usage-metrics):  replace the per-version inline retry with a multi-pass approach

Try all versions in a first pass, collect failures, wait for the rate limit window to reset,
then retry only the failed versions. Repeat until all succeed or a max number of passes is hit.
This avoids cascading failures where retries for one version burn rate budget for the next.

* chore(usage-data): manually trigger the workflow contributes to an existing PR

* fix: deduplicate versions and only retry retryable errors

* fix: preserve collected metrics when checking out existing branch
…3622)

* fix(usage-metrics): reduce rate-limit cascades

* fix: lint
* chore(metrics): update usage metrics (2026-04-01)

* chore(metrics): update usage metrics (2026-04-01)

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…ntainers#3625)

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6.0.0 to 7.0.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@b7c566a...bbbca2d)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…estcontainers#3632)

Bumps [github.com/go-jose/go-jose/v4](https://github.com/go-jose/go-jose) from 4.1.3 to 4.1.4.
- [Release notes](https://github.com/go-jose/go-jose/releases)
- [Commits](go-jose/go-jose@v4.1.3...v4.1.4)

---
updated-dependencies:
- dependency-name: github.com/go-jose/go-jose/v4
  dependency-version: 4.1.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---------

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Co-authored-by: Alex Ausch <alex.ausch@going.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: mdelapenya <mdelapenya@gmail.com>
…ers#3601)

Check the tag against recentVersionTags before stripping hyphen
suffixes, so that tags containing hyphens like community-archive
are correctly recognized as up-to-date versions.

Fixes testcontainers#3592

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…testcontainers#3627)

* chore(deps): bump github.com/shirou/gopsutil/v4 from 4.26.2 to 4.26.3

Bumps [github.com/shirou/gopsutil/v4](https://github.com/shirou/gopsutil) from 4.26.2 to 4.26.3.
- [Release notes](https://github.com/shirou/gopsutil/releases)
- [Commits](shirou/gopsutil@v4.26.2...v4.26.3)

---
updated-dependencies:
- dependency-name: github.com/shirou/gopsutil/v4
  dependency-version: 4.26.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(deps): propagate go mod tidy for gopsutil v4.26.3

Run go mod tidy across all submodules to propagate the gopsutil v4
version bump from the root module.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: rust <mdelapenya@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…estcontainers#3628)

Bumps [github.com/moby/patternmatcher](https://github.com/moby/patternmatcher) from 0.6.0 to 0.6.1.
- [Release notes](https://github.com/moby/patternmatcher/releases)
- [Commits](moby/patternmatcher@v0.6.0...v0.6.1)

---
updated-dependencies:
- dependency-name: github.com/moby/patternmatcher
  dependency-version: 0.6.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mayor <mdelapenya@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ers#3629)

* chore(deps): bump golang.org/x/sys from 0.41.0 to 0.42.0

Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.41.0 to 0.42.0.
- [Commits](golang/sys@v0.41.0...v0.42.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.42.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: propagate golang.org/x/sys v0.42.0 to all modules

Ran make tidy-all after merging main to propagate the x/sys bump
to all sub-module go.mod/go.sum files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mayor <mdelapenya@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add .beads/, .claude/, and .runtime/ to .gitignore to prevent
agent workspace files from being accidentally committed.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…s#3634)

Update to tagged versions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…com/docker/compose v5.1.2 (testcontainers#3646)

* chore(deps): bump github.com/klauspost/compress v1.18.5

- v1.18.3 contains a fix for CVE-2025-61728
- v1.18.5 fixes a crash in zstd

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

* chore(deps): bump github.com/docker/compose v5.1.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

---------

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
go1.25.9 (released 2026-04-07) includes security fixes to the go command,
the compiler, and the archive/tar, crypto/tls, crypto/x509, html/template,
and os packages, as well as bug fixes to the go command, the compiler, and
the runtime. See the Go 1.25.9 milestone on our issue tracker for details.

- https://github.com/golang/go/issues?q=milestone%3AGo1.25.9+label%3ACherryPickApproved
- full diff: golang/go@go1.25.8...go1.25.9

go1.26.2 (released 2026-04-07) includes security fixes to the go command,
the compiler, and the archive/tar, crypto/tls, crypto/x509, html/template,
and os packages, as well as bug fixes to the go command, the go fix command,
the compiler, the linker, the runtime, and the net, net/http, and net/url
packages. See the Go 1.26.2 milestone on our issue tracker for details;

- https://github.com/golang/go/issues?q=milestone%3AGo1.26.2+label%3ACherryPickApproved
- full diff: golang/go@go1.26.1...go1.26.2

From the security announce:

We have just released Go versions 1.26.2 and 1.25.9, minor point releases.

These releases include 10 security fixes following the security policy:

- os: Root.Chmod can follow symlinks out of the root on Linux

  On Linux, if the target of Root.Chmod is replaced with a symlink while
  the chmod operation is in progress, Chmod could operate on the target
  of the symlink, even when the target lies outside the root.

  The Linux fchmodat syscall silently ignores the AT_SYMLINK_NOFOLLOW flag,
  which Root.Chmod uses to avoid symlink traversal. Root.Chmod checks its
  target before acting and returns an error if the target is a symlink
  lying outside the root, so the impact is limited to cases where the
  target is replaced with a symlink between the check and operation.

  On Linux, Root.Chmod now uses the fchmodat2 syscall when available, and
  an workaround using /proc/self/fd otherwise.

  Thanks to Uuganbayar Lkhamsuren for reporting this issue.

  This is CVE-2026-32282 and Go issue https://go.dev/issue/78293.

- html/template: JS template literal context incorrectly tracked

  Context was not properly tracked across template branches for JS template
  literals, leading to possibly incorrect escaping of content when branches were
  used.

  Additionally template actions within JS template literals did not properly
  track
  the brace depth, leading to incorrect escaping being applied.

  These issues could cause actions within JS template literals to be incorrectly
  or improperly escaped, leading to XSS vulnerabilities.

  This only affects templates that use template actions within JS template
  literals.

  This is CVE-2026-32289 and Go issue https://go.dev/issue/78331.

- crypto/x509: excluded DNS constraints not properly applied to wildcard domains

  When verifying a certificate chain containing excluded DNS constraints, these
  constraints are not correctly applied to wildcard DNS SANs which use a
  different
  case than the constraint.

  For example, if a certificate contains the DNS name "*.example.com" and the
  excluded DNS name "EXAMPLE.COM", the constraint will not be applied.

  This only affects validation of otherwise trusted certificate chains, issued
  by
  a root CA in the VerifyOptions.Roots CertPool, or in the system certificate
  pool.

  This issue only affects Go 1.26.

  Thank you to Riyas from Saintgits College of Engineering, k1rnt, @1seal for
  reporting this issue.

  This is CVE-2026-33810 and Go issue https://go.dev/issue/78332.

- cmd/compile: no-op interface conversion bypasses overlap checking

  Previously, the compiler failed to unwrap pointers contained within
  a no-op interface conversion leading to an incorrect determination
  of a non-overlapping move.

  To prevent unsafe move operations, the compiler will now unwrap all
  such conversions before considering a move non-overlapping.

  Thank you to Jakub Ciolek - https://ciolek.dev/ for reporting this issue.

  This is CVE-2026-27144 and Go issue https://go.dev/issue/78371.

- cmd/compile: possible memory corruption after bound check elimination

  Previously, slices and arrays accessed using induction variables
  were sometimes incorrectly proved in-bound. If the induction variable
  used for indexing were to overflow or underflow, it could allow access
  to memory beyond the scope of the original slice or array.

  To prevent this behavior, the compiler ensures that any mutated induction
  variable that overflows/underflows with respect to its loop condition
  is not used for bound check elimination.

  Thank you to Jakub Ciolek - https://ciolek.dev/ for reporting this issue.

  This is CVE-2026-27143 and Go issue https://go.dev/issue/78333.

- archive/tar: unbounded allocation when parsing old format GNU sparse map

  tar.Reader could allocate an unbounded amount of memory when reading
  a maliciously-crafted archive containing a large number of sparse
  regions encoded in the "old GNU sparse map" format.

  We now limit both the number of old GNU sparse map extension blocks,
  and the total number of sparse file entries, regardless of encoding.

  Thanks to Colin Walters (wal...@verbum.org) who initially reported this issue.
  Thanks also to Uuganbayar Lkhamsuren (https://github.com/uug4na) and Jakub
  Ciolek
  who additionally reported this issue.

  This is CVE-2026-32288 and Go issue https://go.dev/issue/78301.

- crypto/tls: multiple key update handshake messages can cause connection to
  deadlock

  If one side of the TLS connection sends multiple key update messages
  post-handshake in a single record, the connection can deadlock, causing
  uncontrolled consumption of resources. This can lead to a denial of service.

  This only affects TLS 1.3.

  Thank you to Jakub Ciolek - https://ciolek.dev/ for reporting this issue.

  This is CVE-2026-32283 and Go issue https://go.dev/issue/78334.

- cmd/go: trust layer bypass when using cgo and SWIG

  A well-crafted SWIG source file could take advantage
  of a file-naming convention used inside the trust
  boundary of the cgo compiler. Doing so could result
  in arbitrary code execution during build time.

  SWIG files are disallowed from using this convention.

  Thank you to Juho Forsén of Mattermost for reporting this issue.

  This is CVE-2026-27140 and Go issue https://go.dev/issue/78335.

- crypto/x509: unexpected work during chain building

  During chain building, the amount of work that is done is not correctly
  limited
  when a large number of intermediate certificates are passed in
  VerifyOptions.Intermediates, which can lead to a denial of service. This
  affects
  both direct users of crypto/x509 and users of crypto/tls.

  Thank you to Jakub Ciolek - https://ciolek.dev/ for reporting this issue.

  This is CVE-2026-32280 and Go issue https://go.dev/issue/78282.

- crypto/x509: inefficient policy validation

  Validating certificate chains which use policies is unexpectedly inefficient
  when certificates in the chain contain a very large number of policy mappings,
  possibly causing denial of service.

  This only affects validation of otherwise trusted certificate chains, issued
  by
  a root CA in the VerifyOptions.Roots CertPool, or in the system certificate
  pool.

  Thank you to Jakub Ciolek - https://ciolek.dev/ for reporting this issue.

  This is CVE-2026-32281 and Go issue https://go.dev/issue/78281.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…stcontainers#3644)

Bumps [go.opentelemetry.io/otel/sdk](https://github.com/open-telemetry/opentelemetry-go) from 1.41.0 to 1.43.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](open-telemetry/opentelemetry-go@v1.41.0...v1.43.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/sdk
  dependency-version: 1.43.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…tlptracehttp (testcontainers#3643)

Bumps [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp](https://github.com/open-telemetry/opentelemetry-go) from 1.41.0 to 1.43.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](open-telemetry/opentelemetry-go@v1.41.0...v1.43.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp
  dependency-version: 1.43.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ners#3638)

Bumps [github.com/aws/aws-sdk-go-v2/service/s3](https://github.com/aws/aws-sdk-go-v2) from 1.51.2 to 1.97.3.
- [Release notes](https://github.com/aws/aws-sdk-go-v2/releases)
- [Commits](aws/aws-sdk-go-v2@service/s3/v1.51.2...service/s3/v1.97.3)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go-v2/service/s3
  dependency-version: 1.97.3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…estcontainers#3626)

Bumps [mkdocs-include-markdown-plugin](https://github.com/mondeja/mkdocs-include-markdown-plugin) from 7.2.1 to 7.2.2.
- [Release notes](https://github.com/mondeja/mkdocs-include-markdown-plugin/releases)
- [Commits](mondeja/mkdocs-include-markdown-plugin@v7.2.1...v7.2.2)

---
updated-dependencies:
- dependency-name: mkdocs-include-markdown-plugin
  dependency-version: 7.2.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…tlptracehttp (testcontainers#3645)

Bumps [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp](https://github.com/open-telemetry/opentelemetry-go) from 1.41.0 to 1.43.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](open-telemetry/opentelemetry-go@v1.41.0...v1.43.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp
  dependency-version: 1.43.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…otlpmetrichttp (testcontainers#3641)

Bumps [go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp](https://github.com/open-telemetry/opentelemetry-go) from 1.38.0 to 1.43.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](open-telemetry/opentelemetry-go@v1.38.0...v1.43.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp
  dependency-version: 1.43.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…otlpmetrichttp (testcontainers#3639)

Bumps [go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp](https://github.com/open-telemetry/opentelemetry-go) from 1.28.0 to 1.43.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](open-telemetry/opentelemetry-go@v1.28.0...v1.43.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp
  dependency-version: 1.43.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
dependabot Bot and others added 25 commits April 17, 2026 07:24
…ontainers#3652)

Bumps [github.com/jackc/pgx/v5](https://github.com/jackc/pgx) from 5.5.4 to 5.9.0.
- [Changelog](https://github.com/jackc/pgx/blob/master/CHANGELOG.md)
- [Commits](jackc/pgx@v5.5.4...v5.9.0)

---
updated-dependencies:
- dependency-name: github.com/jackc/pgx/v5
  dependency-version: 5.9.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…stcontainers#3656)

Bumps [github.com/jackc/pgx/v5](https://github.com/jackc/pgx) from 5.5.4 to 5.9.2.
- [Changelog](https://github.com/jackc/pgx/blob/master/CHANGELOG.md)
- [Commits](jackc/pgx@v5.5.4...v5.9.2)

---
updated-dependencies:
- dependency-name: github.com/jackc/pgx/v5
  dependency-version: 5.9.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ontainers#3657)

Bumps [github.com/jackc/pgx/v5](https://github.com/jackc/pgx) from 5.9.0 to 5.9.2.
- [Changelog](https://github.com/jackc/pgx/blob/master/CHANGELOG.md)
- [Commits](jackc/pgx@v5.9.0...v5.9.2)

---
updated-dependencies:
- dependency-name: github.com/jackc/pgx/v5
  dependency-version: 5.9.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…estcontainers#3658)

Bumps [github.com/Azure/go-ntlmssp](https://github.com/Azure/go-ntlmssp) from 0.0.0-20221128193559-754e69321358 to 0.1.1.
- [Release notes](https://github.com/Azure/go-ntlmssp/releases)
- [Commits](https://github.com/Azure/go-ntlmssp/commits/v0.1.1)

---
updated-dependencies:
- dependency-name: github.com/Azure/go-ntlmssp
  dependency-version: 0.1.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…rs#3660)

* fix: wait for log production goroutine to drain on stop

stopLogProduction() was cancelling the context and returning
immediately, creating a race where in-flight log data could be
dropped when Terminate() fired during active log streaming.
Confirmed data loss of up to 77% of lines in reproduction tests.

Add a logProductionDone channel (closed by the goroutine on exit)
and wait for it in stopLogProduction() before returning. For
containers that have already exited, the goroutine finishes
naturally once stdcopy.StdCopy reaches EOF, so all buffered logs
are delivered. A 5-second bounded timeout handles the case where
the container is still actively streaming (e.g. Stop() called on
a running container), after which we force-cancel and wait for
the goroutine to acknowledge.

Adds TestContainerLogDrainOnTerminate to demonstrate the fix:
it runs 5 parallel sub-tests, each starting an alpine container
that emits 1000 log lines and exits, then calls Terminate() and
asserts all 1000 lines were received.

Fixes testcontainers#2887

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: bound post-cancel wait in stopLogProduction

The post-cancel <-logProductionDone receive was unbounded. While
context cancellation normally unblocks stdcopy.StdCopy promptly
(the timeoutCtx derived from logProductionCtx is cancelled too),
a stuck kernel socket read or Docker daemon transport failure
could cause the goroutine to hang indefinitely, blocking
Stop/Terminate forever.

Add a select with time.After(minLogProductionTimeout) on the
post-cancel wait, matching the existing pre-cancel timeout.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: address CodeRabbit review feedback

- Replace raw 5*time.Second literal in stopLogProduction pre-cancel
  wait with minLogProductionTimeout for consistency; both drain
  timeouts now share the same named constant.
- Remove redundant 'run := run' loop-variable shadow (unnecessary
  since Go 1.22 integer range captures loop vars by value).
- Add CleanupContainer(t, ctr) after Run() succeeds so containers
  are always reclaimed even if a subsequent assertion panics.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: log warning when post-cancel goroutine drain times out

If stdcopy.StdCopy fails to unblock within minLogProductionTimeout
after context cancellation (stuck kernel socket / daemon hang),
stopLogProduction now logs a warning via c.logger.Printf so leaked
goroutines are diagnosable rather than silently ignored.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
…ntainers#3661)

* fix(compose): close docker clients to prevent goroutine leaks

Close dockerCli.Client() and dockerClient in Down() to release
net/http persistConn.readLoop/writeLoop goroutines that were leaking
on every Up+Down cycle.

Store the *command.DockerCli instance in the DockerCompose struct so
its HTTP transport connections can be closed during teardown.
Previously the dockerCli was created in NewDockerComposeWith() but
never retained, so its HTTP client connections could not be released.

Adds TestDockerComposeGoroutineLeak to demonstrate the fix: it
snapshots goroutines before an Up+Down cycle and asserts that no
net/http persistConn goroutines remain afterward.

Fixes testcontainers#2008

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(compose): address code review feedback on goroutine leak fix

- Extract Close() method on DockerCompose for explicit resource cleanup,
  removing the close defer from Down() to keep teardown and resource
  release concerns separate. Down() is no longer single-use.
- Add go.uber.org/goleak as a direct dependency and replace the hand-rolled
  goroutineSnapshot/goroutineLeaks helpers with goleak.VerifyNone, which
  handles the buffer-growth loop, exponential retry and cleaner reporting.
- Use goleak.IgnoreCurrent() (snapshotted after NewDockerCompose) plus
  IgnoreTopFunction for Reaper goroutines to scope the leak check to
  goroutines introduced by the Up+Down lifecycle only.
- Call compose.Close() in t.Cleanup, after Down(), to release HTTP transport
  connections from both dockerCli.Client() and dockerClient.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(compose): address second round of code review feedback

- Make Close() idempotent by nil-ing dockerCli and dockerClient after
  closing them, so double-close is a no-op.
- Add TODO(testcontainers#2008) comment on the IgnoreTopFunction filter explaining that
  it pins on an internal closure name that may change if Reaper is
  refactored, and should be removed when the Reaper leak is fixed.
- Register compose.Down in a t.Cleanup (LIFO after Close) so teardown
  runs even if the test panics after Up succeeds.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
* chore(metrics): update usage metrics (2026-05-05)

* chore(metrics): update usage metrics (2026-05-05)

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* fix(dind): close temp file handle before removal

On some OS (such as Windows), keeping a file descriptor open prevents you from deleting the file.

* fix(k3s): close temp file handle before removal

On some OS (such as Windows), keeping a file descriptor open prevents you from deleting the file.
…estcontainers#3673)

Bumps [github.com/apache/thrift](https://github.com/apache/thrift) from 0.21.0 to 0.23.0.
- [Release notes](https://github.com/apache/thrift/releases)
- [Changelog](https://github.com/apache/thrift/blob/master/CHANGES.md)
- [Commits](apache/thrift@v0.21.0...v0.23.0)

---
updated-dependencies:
- dependency-name: github.com/apache/thrift
  dependency-version: 0.23.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…estcontainers#3665)

Bumps [mkdocs-include-markdown-plugin](https://github.com/mondeja/mkdocs-include-markdown-plugin) from 7.2.1 to 7.2.2.
- [Release notes](https://github.com/mondeja/mkdocs-include-markdown-plugin/releases)
- [Commits](mondeja/mkdocs-include-markdown-plugin@v7.2.1...v7.2.2)

---
updated-dependencies:
- dependency-name: mkdocs-include-markdown-plugin
  dependency-version: 7.2.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…tcontainers#3664)

Bumps [docker/setup-docker-action](https://github.com/docker/setup-docker-action) from 4.5.0 to 5.1.0.
- [Release notes](https://github.com/docker/setup-docker-action/releases)
- [Commits](docker/setup-docker-action@efe9e38...b2189fb)

---
updated-dependencies:
- dependency-name: docker/setup-docker-action
  dependency-version: 5.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…se (testcontainers#3674)

Bumps [github.com/in-toto/in-toto-golang](https://github.com/in-toto/in-toto-golang) from 0.10.0 to 0.11.0.
- [Release notes](https://github.com/in-toto/in-toto-golang/releases)
- [Changelog](https://github.com/in-toto/in-toto-golang/blob/master/CHANGELOG.md)
- [Commits](in-toto/in-toto-golang@v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: github.com/in-toto/in-toto-golang
  dependency-version: 0.11.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---------
Co-authored-by: tks-subtree-bot <tks-subtree-bot@users.noreply.github.com>
Co-authored-by: Manuel de la Peña <social.mdelapenya@gmail.com>
Co-authored-by: mdelapenya <mdelapenya@gmail.com>
…ers#3686)

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.75.0 to 1.81.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.75.0...v1.81.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-version: 1.81.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ainers#3690)

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.79.3 to 1.81.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.79.3...v1.81.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-version: 1.81.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ainers#3689)

* chore(deps): bump golang.org/x/crypto from 0.48.0 to 0.50.0

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.48.0 to 0.50.0.
- [Commits](golang/crypto@v0.48.0...v0.50.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.50.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: run mod tidy

* chore: bump crypto to v0.51.0

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…tcontainers#3676)

* chore(deps): bump github.com/moby/moby/api from 1.54.1 to 1.54.2

Bumps [github.com/moby/moby/api](https://github.com/moby/moby) from 1.54.1 to 1.54.2.
- [Release notes](https://github.com/moby/moby/releases)
- [Commits](moby/moby@api/v1.54.1...api/v1.54.2)

---
updated-dependencies:
- dependency-name: github.com/moby/moby/api
  dependency-version: 1.54.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: run mod tidy

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mdelapenya <mdelapenya@gmail.com>
…testcontainers#3667)

* chore(deps): bump github.com/shirou/gopsutil/v4 from 4.26.3 to 4.26.4

Bumps [github.com/shirou/gopsutil/v4](https://github.com/shirou/gopsutil) from 4.26.3 to 4.26.4.
- [Release notes](https://github.com/shirou/gopsutil/releases)
- [Commits](shirou/gopsutil@v4.26.3...v4.26.4)

---
updated-dependencies:
- dependency-name: github.com/shirou/gopsutil/v4
  dependency-version: 4.26.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: run mod tidy

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mdelapenya <mdelapenya@gmail.com>
Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.6.3 to 2.7.0.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](urllib3/urllib3@2.6.3...2.7.0)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-version: 2.7.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: mdelapenya <mdelapenya@gmail.com>
…ontainers#3721)

The toomanyrequests debug block was printing the full Docker config
(including auth tokens) to stdout. Remove it as the TODO comment
already indicated.

Fixes testcontainers#3720

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

8 participants