Skip to content

Deflake real-backend forwarding tests - #5963

Merged
JAORMX merged 1 commit into
mainfrom
deflake-forwarding-realbackend-5962
Jul 24, 2026
Merged

Deflake real-backend forwarding tests#5963
JAORMX merged 1 commit into
mainfrom
deflake-forwarding-realbackend-5962

Conversation

@JAORMX

@JAORMX JAORMX commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Why: TestForwarding_*_RealBackend (pkg/vmcp/server/forwarding_realbackend_integration_test.go) intermittently time out on CI waiting for a forwarded, server-initiated notification (#5962). waitNotification used a hardcoded time.After deadline (5s originally, 15s after #5941) inside the per-test context — a two-deadline design where a timer shorter than the context flaked under the full-suite parallel -race load (the async backend → vMCP → downstream relay can take several seconds), while a longer timer would have masked a genuine hang. The 15s bump proved insufficient (TestForwarding_Logging_RealBackend timed out at 15.09s).

What:

  • waitNotification now selects on the caller's ctx.Done() instead of its own timer (and reports ctx.Err() on timeout) — a single source of truth for the deadline.
  • Every real-backend forwarding test shares one generous const forwardingRealBackendTimeout = 60 * time.Second, replacing the per-test 20s/30s literals. 60s is well under the 10m go test global timeout, so a real hang still fails fast with a clear error rather than blocking the whole suite.
  • notifCh is left buffered at 8; each test emits and reads a single notification, so drop-on-full is not a realistic flake source.

Closes #5962.

Type of change

  • Bug fix

Test plan

  • go test -race -count=5 -run TestForwarding_ ./pkg/vmcp/server/ — passes 5×.
  • task lint 0 issues; task build succeeds.

Does this introduce a user-facing change?

No. Test-only change.

Special notes for reviewers

  • Reviewed for concurrency/test-adequacy: waitNotification's t.Fatalf runs on the test goroutine (called directly, not in a spawned goroutine), and each defer cancel() only fires on function return, so tying to the caller ctx is sound.
  • Minor, deliberate: the two negative-path tests (withHandlers=false) that assert require.NotErrorIs(err, context.DeadlineExceeded) now use 60s instead of 20s. They fail near-instantly in practice, so the widened window is a negligible loss of timing sensitivity, kept for the single-const simplicity.
  • Follow-up to Deflake vMCP forwarding notification wait #5941, which raised only the Progress variant's deadline to 15s.

Generated with Claude Code

TestForwarding_*_RealBackend intermittently timed out on CI waiting for a
forwarded, server-initiated notification. waitNotification used a hardcoded
time.After deadline (5s originally, 15s after #5941) that sat inside the
per-test context: a timer shorter than the context flaked under the
full-suite parallel -race load (the async backend -> vMCP -> downstream
relay can take many seconds), while a longer one would mask a genuine hang.

Collapse the two deadlines into one: waitNotification now selects on the
caller's ctx.Done() instead of its own timer, and every real-backend
forwarding test shares a single, generous forwardingRealBackendTimeout
(60s) — well under the 10m go-test global timeout, so a real hang still
fails fast with a clear ctx error. notifCh stays buffered at 8; each test
emits and reads a single notification, so drop-on-full is not a factor.

Verified with `go test -race -count=5 -run TestForwarding_ ./pkg/vmcp/server/`.

Closes #5962.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the size/XS Extra small PR: < 100 lines changed label Jul 24, 2026
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.84%. Comparing base (97a9dfa) to head (c51fbd5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5963      +/-   ##
==========================================
- Coverage   71.84%   71.84%   -0.01%     
==========================================
  Files         708      708              
  Lines       72811    72811              
==========================================
- Hits        52311    52310       -1     
- Misses      16765    16767       +2     
+ Partials     3735     3734       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JAORMX
JAORMX merged commit bd855dd into main Jul 24, 2026
51 of 52 checks passed
@JAORMX
JAORMX deleted the deflake-forwarding-realbackend-5962 branch July 24, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky: TestForwarding_*_RealBackend time out waiting for forwarded notifications under CI load

3 participants