Skip to content

Conversation

@JAORMX
Copy link
Collaborator

@JAORMX JAORMX commented Oct 31, 2025

Summary

Fixes intermittent test failures in pkg/vmcp/server/health_test.go that were occurring in CI due to port conflicts.

Problem

The health endpoint tests were flaky because all parallel test instances tried to bind to the default port 4483, causing "address already in use" errors when running with -parallel flag.

Solution

  1. Added Ready() channel to vMCP server (pkg/vmcp/server/server.go):

    • Added ready chan struct{} field to signal when server is ready to accept connections
    • Exposed via Ready() <-chan struct{} method
    • Channel is closed after listener is created in Start()
  2. Used existing networking.FindAvailable() utility (pkg/vmcp/server/health_test.go):

    • Each test now gets a unique random port (range 10000-65535)
    • Eliminates port conflicts between parallel tests
  3. Improved test synchronization:

    • Tests wait for srv.Ready() channel instead of arbitrary sleeps
    • Added error channel to catch and report startup failures early
    • Better error messages including actual server address

Test Plan

Verified with stress testing:

go test -v ./pkg/vmcp/server -run TestHealthEndpoint -count=20 -parallel=4

All 60 tests (20 iterations × 3 subtests) passed reliably in ~0.26s.

🤖 Generated with Claude Code

The health endpoint tests were failing intermittently in CI due to port
conflicts when running parallel tests. All test instances tried to bind
to the default port 4483, causing "address already in use" errors.

Changes:
- Add Ready() channel to vMCP server to signal when listener is created
- Use networking.FindAvailable() to assign unique random ports to tests
- Improve test synchronization by waiting on Ready() channel
- Add error channel to catch and report startup failures

The tests now run reliably with 20 parallel iterations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.43%. Comparing base (4ef4a16) to head (bf81090).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2415   +/-   ##
=======================================
  Coverage   54.43%   54.43%           
=======================================
  Files         265      265           
  Lines       25590    25599    +9     
=======================================
+ Hits        13931    13936    +5     
- Misses      10338    10340    +2     
- Partials     1321     1323    +2     

☔ View full report in Codecov by Sentry.
📢 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 enabled auto-merge (squash) October 31, 2025 12:29
@JAORMX JAORMX merged commit 40b7277 into main Oct 31, 2025
28 checks passed
@JAORMX JAORMX deleted the fix-vmcp-health-test-flakiness branch October 31, 2025 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants