e2e: parallelize WaitForExporters to reduce test runtime#895
Conversation
WaitForExporters was running sequentially despite its comment saying 'in parallel'. For 3 exporters, each call stacked: 2s outer sleep + 3x(2s inner sleep + kubectl wait + polling) = ~8s+ minimum. Now uses sync.WaitGroup to run all WaitForExporter calls concurrently. Each WaitForExporter already has its own exporterPostDelay sleep, so the duplicate outer sleep is removed. GinkgoRecover() ensures assertion panics from goroutines are properly caught by the test framework. With 3 exporters in parallel, each call drops from ~8s to ~4s minimum. Called 13+ times across the core e2e tests, this saves ~50-80s total.
📝 WalkthroughWalkthrough
ChangesExporter readiness
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" 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 `@e2e/test/utils.go`:
- Around line 593-604: Update WaitForExporters to track failures from each
concurrent WaitForExporter call, using an atomic failure indicator alongside
GinkgoRecover. After wg.Wait() completes, abort the main goroutine when any
exporter failed so downstream commands do not run; preserve the current
concurrent waiting behavior for successful exporters.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
Motivation
WaitForExporterswas running sequentially despite its comment saying "in parallel." For the typical call with 3 exporters, each invocation stacked delays:exporterPostDelaysleepkubectl wait+Eventuallypolling)This function is called 13+ times in
e2e_test.goalone, plus additional calls in the compat test files. The sequential waiting adds up to a significant portion of the total e2e test runtime.Change
Parallelize the
WaitForExportercalls insideWaitForExportersusingsync.WaitGroup:WaitForExportercall already has its ownexporterPostDelay(2s) sleep, so the duplicate outer sleep is removedGinkgoRecover()ensures assertion panics fromMustRunCmd/Eventuallyinside goroutines are properly caught by the Ginkgo test frameworkBefore (sequential, ~8s minimum for 3 exporters)
After (parallel, ~4s minimum for 3 exporters)
Expected savings
With 3 exporters per call and 13+ call sites in the core tests: estimated 50-80s reduction in total e2e runtime.
What doesn't change
WaitForExporter(singular) — unchanged, keeps its own delay + kubectl wait + pollingWaitForExporterOffline— unchangedsyncwas already imported,GinkgoRecovercomes from the Ginkgo v2 dot-import