test: reduce fixed waits in slow suites#2003
Conversation
📝 WalkthroughWalkthroughThis pull request replaces time-based synchronization (fixed sleep durations) with a deterministic hold-file mechanism across multiple test files in the internal/cmd and internal/service packages. Tests now create temporary files to coordinate timing instead of relying on static delays, enabling more reliable and controlled test execution. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 the current code and only fix it if needed.
Inline comments:
In `@internal/service/worker/worker_test.go`:
- Around line 587-589: The subtest can hang because w.Stop is called with
context.Background() and the test then blocks on <-done without timeout; change
this to create a context with timeout (e.g., context.WithTimeout) and pass that
to w.Stop, and replace the plain receive on done with a testify assertion that
the stop completed before the timeout (use require.Eventually or require.NoError
with a select/timer) so the test fails fast on regressions; update references to
Stop, cancel, and done in this subtest accordingly.
🪄 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: e551d33e-2e6d-4e74-ab44-23f46e23550b
📒 Files selected for processing (9)
internal/cmd/cleanup_test.gointernal/cmd/restart_test.gointernal/cmd/status_test.gointernal/cmd/stop_test.gointernal/cmd/test_helpers_test.gointernal/service/frontend/api/v1/dagruns_test.gointernal/service/frontend/api/v1/proc_liveness_test.gointernal/service/frontend/api/v1/singleton_test.gointernal/service/worker/worker_test.go
Summary
Local timing
internal/cmd: 27.5s before, 15.3s after on this machine.internal/service/worker: 14.1s before, 11.3s after on this machine.internal/service/frontend/api/v1: 35.2s before, 23.9s after on this machine.internal/intg/distr -run TestParallel_MixedLocalAndDistributed: 1.5s after replacing fixed sleeps.Testing
go test -count=1 ./internal/cmdgo test -json -count=1 ./internal/service/worker > /tmp/worker-mainbranch.jsonlgo test -json -count=1 ./internal/service/frontend/api/v1 > /tmp/api-v1-mainbranch.jsonlgo test -count=1 ./internal/service/workergo test -count=1 ./internal/intg/distr -run TestParallel_MixedLocalAndDistributedSummary by CodeRabbit