Skip to content

Conversation

@amirejaz
Copy link
Contributor

Summary

This PR adds comprehensive test coverage for remote MCP server health check failure scenarios, ensuring that the health check callback mechanism works correctly when remote servers become unavailable.

Changes

  • Added 8 new test cases covering various remote MCP server failure scenarios:
    • TestTransparentProxy_RemoteServerFailure_5xxStatus - Tests 5xx status codes trigger callback
    • TestTransparentProxy_RemoteServerFailure_ConnectionRefused - Tests connection failures
    • TestTransparentProxy_RemoteServerFailure_Timeout - Tests timeout scenarios
    • TestTransparentProxy_RemoteServerFailure_BecomesUnavailable - Tests server becoming unavailable after being healthy
    • TestTransparentProxy_RemoteServerFailure_Different5xxCodes - Table-driven test for various 5xx codes (500, 502, 503, 504)
    • TestTransparentProxy_RemoteServerHealthy_4xxCodes - Verifies 4xx codes are considered healthy
    • TestTransparentProxy_HealthCheckNotRunBeforeInitialization - Ensures health checks skip until initialization
    • TestTransparentProxy_HealthCheckFailureWithNilCallback - Tests graceful handling with nil callback

Technical Improvements

  • Fixed race conditions by converting IsServerInitialized from int32 to atomic.Bool for thread-safe access
  • Added private serverInitialized() getter method for better encapsulation
  • All tests run in parallel and pass with race detector enabled

Testing

  • All tests pass with -race flag enabled
  • Tests use httptest.NewServer to simulate different failure scenarios
  • Proper synchronization with sync.Mutex for callback tracking

Related

Addresses test coverage gap identified in PR #3077 for remote MCP server health check failure handling.

@github-actions github-actions bot added the size/M Medium PR: 300-599 lines changed label Dec 17, 2025
@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

❌ Patch coverage is 89.65517% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.25%. Comparing base (4b3fd00) to head (44ca6c2).

Files with missing lines Patch % Lines
...g/transport/proxy/transparent/transparent_proxy.go 89.65% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3084      +/-   ##
==========================================
+ Coverage   57.14%   57.25%   +0.11%     
==========================================
  Files         341      341              
  Lines       34053    34075      +22     
==========================================
+ Hits        19459    19510      +51     
+ Misses      12985    12953      -32     
- Partials     1609     1612       +3     

☔ 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.

Copy link
Contributor

@jhrozek jhrozek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good test coverage for the health check failure scenarios!

@github-actions github-actions bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Dec 18, 2025
@amirejaz amirejaz requested a review from jhrozek December 18, 2025 13:30
@github-actions github-actions bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants