Repository navigation
Description
Summary
The real-backend forwarding integration tests in pkg/vmcp/server/forwarding_realbackend_integration_test.go intermittently fail on CI with a timeout waiting for a forwarded, server-initiated notification. They pass reliably (in milliseconds) locally, but under the full-suite parallel -race + -coverpkg=./... load on the shared CI runner the round trip occasionally exceeds the test's fixed wait deadline.
Symptom
forwarding_realbackend_integration_test.go:326: timed out waiting for notifications/message notification
(analogous failures for notifications/progress, etc.)
Affected tests
All use the shared downstreamClient.waitNotification helper, which relies on a hardcoded time.After(...) deadline:
TestForwarding_Progress_RealBackend— waits fornotifications/progressTestForwarding_Logging_RealBackend— waits fornotifications/message- (same helper is used by the
Elicitation/Samplingvariants)
Root cause
waitNotification (forwarding_realbackend_integration_test.go:206) blocks on a fixed deadline for an async, server-initiated notification relayed backend → vMCP → downstream client. Under CI's parallel -race load that relay can take several seconds; when it exceeds the deadline the test fails.
- Deflake vMCP forwarding notification wait #5941 already raised this deadline from 5s → 15s to fix the
Progressvariant. - That was insufficient:
TestForwarding_Logging_RealBackendtimed out at 15.09s (right at the 15s deadline) on the CI run for Add opt-in strict MCP-Protocol-Version validation #5957.
A likely contributing factor (noted in #5941): notifCh is filled by a non-blocking send that drops on a full buffer, so a slow consumer can miss a notification entirely rather than merely wait longer.
Impact
Intermittent red on the required Tests / Test Go Code check, which blocks unrelated PRs and forces re-runs.
Suggested fixes (pick one / combine)
- Wait until the caller's context deadline instead of a separate hardcoded
time.After: the callers already use a 20scontext.WithTimeout, sowaitNotificationshould select onctx.Done()rather than an independent (shorter) timer — one source of truth, and it fails cleanly when the context actually expires. - Raise both the per-test context and the wait deadline generously (e.g. 60s) — real-backend integration tests are inherently slower under
-race. - Make the notification capture robust: give
notifChenough buffer (or drain it in a goroutine) so a transient slow consumer cannot drop a notification via the non-blocking send.
References
- Prior partial fix: Deflake vMCP forwarding notification wait #5941 (5s → 15s for the Progress variant)
- Observed again on the CI for Add opt-in strict MCP-Protocol-Version validation #5957
Generated with Claude Code
Activity
Deflake real-backend forwarding tests (stacklok#5963)
fix(operator): allow multiple keys of one Secret in spec.secrets (#6690)