chore: stabilize TestContainerLogWithErrClosed and re-enable it for rootful CI#3817
chore: stabilize TestContainerLogWithErrClosed and re-enable it for rootful CI#3817malikov73 wants to merge 2 commits into
Conversation
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Summary by CodeRabbit
WalkthroughThe log consumer test adds quiet-period polling and exact message-delta assertions, replaces fixed-sleep counting, and detects rootless Docker through the extracted Docker host socket. ChangesLog Consumer Test Stabilization
Estimated code review effort: 3 (Moderate) | ~15–30 minutes Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@logconsumer_test.go`:
- Around line 260-263: Update TestContainerLogWithErrClosed to detect rootless
Docker using the resolved Docker host or socket configuration rather than
checking XDG_RUNTIME_DIR. Skip only when that resolved endpoint indicates a
rootless Docker daemon, and allow the test to run in normal PAM/systemd
sessions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2860feb0-487b-4300-a7ab-e6154c85230b
📒 Files selected for processing (1)
logconsumer_test.go
17799b1 to
451d84d
Compare
What does this PR do?
Stabilizes
TestContainerLogWithErrClosedand re-enables it for rootful CI. The test has been skipped on all of GitHub Actions since #1925 (Nov 2023).It used fixed
time.Sleepcalls to wait for asynchronously streamed log messages and then asserted exact message counts — a race against CI load that made it flaky (#411) and got it skipped.Changes:
waitLogsQuiethelper — the initial baseline count is taken after the log stream has been quiet for 1s (bounded by a 30s deadline), instead of hoping a fixed 1s is enough for nginx startup logs to drain.requireNewMsgshelper — replaces the three sleep-then-assert-exact-count patterns: polls until the expected new messages arrive (up to 1 min), lets the stream settle for 1s so unexpected extra lines still surface, then asserts the exact count. The test stays exactly as strict as before — duplicate or stray messages still fail it. Polling the mutex-guardedMsgs()is used rather than theAccepted-channel handshake because the final assertions are negative ("no extra messages"), which a channel receive can't express without the same settle window.GITHUB_RUN_IDskip is narrowed to rootless Docker only (XDG_RUNTIME_DIR, matching the existing rootless skips indocker_test.go) — chore: skip TestContainerLogWithErrClosed as flaky on rootless docker #1925's stated rationale was rootless flakiness, and privileged dind + iptables is environmentally incompatible there, same category as the existing rootless-Podman skip. The test returns to the rootful matrix, which this PR's own CI run validates.Note: the
// todo: remove this temporary fix (test is flaky)retry loop arounddind.Endpoint()is a separate workaround and is left untouched.Why is it important?
This is the only test covering the log-producer reconnect path (
errClosedhandling), and it has been effectively unprotected in CI for over two years. Found while dogfooding a flaky-test static analyzer I've been building — it flagged all three sleep-then-assert sites in this function.If you'd rather keep #1924 open until rootless is also covered, happy to switch Closes → Relates.
Related issues
How to test this PR
Locally (Docker via OrbStack, macOS, rootful): 11/11 consecutive green runs with
-raceafter the change.