Skip to content

Add comprehensive test coverage for remote MCP server health check failures#3084

Merged
amirejaz merged 12 commits intomainfrom
remote-mcp-server-health-check-failure
Jan 14, 2026
Merged

Add comprehensive test coverage for remote MCP server health check failures#3084
amirejaz merged 12 commits intomainfrom
remote-mcp-server-health-check-failure

Conversation

@amirejaz
Copy link
Copy Markdown
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
Copy Markdown

codecov Bot commented Dec 17, 2025

Codecov Report

❌ Patch coverage is 75.53191% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.78%. Comparing base (92b08b7) to head (896b161).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...g/transport/proxy/transparent/transparent_proxy.go 77.52% 12 Missing and 8 partials ⚠️
pkg/transport/proxy/transparent/pinger.go 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3084      +/-   ##
==========================================
+ Coverage   63.66%   63.78%   +0.11%     
==========================================
  Files         362      362              
  Lines       35521    35263     -258     
==========================================
- Hits        22613    22491     -122     
+ Misses      11089    10954     -135     
+ Partials     1819     1818       -1     

☔ 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
Copy Markdown
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!

Comment thread pkg/transport/proxy/transparent/transparent_test.go Outdated
@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
eleftherias
eleftherias previously approved these changes Dec 22, 2025
@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
@github-actions github-actions Bot added size/L Large PR: 600-999 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jan 13, 2026
@amirejaz amirejaz merged commit 327e9dd into main Jan 14, 2026
33 checks passed
@amirejaz amirejaz deleted the remote-mcp-server-health-check-failure branch January 14, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Large PR: 600-999 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants