Skip to content

Run google_genai MCP tests in-memory and close pooled connections - #1836

Merged
tconley1428 merged 1 commit into
mainfrom
flake/genai-mcp-inmemory
Sep 10, 2026
Merged

Run google_genai MCP tests in-memory and close pooled connections#1836
tconley1428 merged 1 commit into
mainfrom
flake/genai-mcp-inmemory

Conversation

@DABH

@DABH DABH commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

What was changed

The pooling, schema, replay, side-effect and test-server MCP tests connect to the echo server over in-memory MCP sessions; test_mcp_tool_discovery_and_call keeps the stdio subprocess. The connection fixture closes leftover pool entries instead of only clearing the dict.

Why

Two CI timeouts placed the main thread inside fork_exec while the stdio client spawned the echo server, blocking the event loop past the workflow deadline. Fork latency scales with heap size, and the suite leaked one ~67MB echo server per test because the fixture never closed them.

Testing

Live echo servers during the suite: 1 to 6 before, 0 after. MCP suite x30 under load: 240/240, 121s before, 72s after. Lint clean.

The MCP tests spawned the FastMCP echo server as a stdio subprocess for
every test and never shut the pooled connection down: the autouse fixture
only cleared the pool dict, so each test left a ~67 MB server process (and
its owner task) alive for the rest of the pytest process. On macOS CI the
spawn itself also stalled: two timed-out runs show the pytest main thread
inside _posixsubprocess.fork_exec for ~65s while forking the large test
process, freezing the worker's event loop until the workflow deadline
passed (test_mcp_side_effects, test_mcp_full_schema_propagation).

Connect the pooling, schema, replay and side-effect tests to the same echo
server over mcp.shared.memory streams instead; they exercise the connection
pool and activity scheduling, not the transport. Keep the stdio subprocess
for test_mcp_tool_discovery_and_call, and have the fixture evict (close)
leftover connections so no server outlives its test.
@DABH DABH added the skip-changelog PR changes do not require changelog updates label Sep 10, 2026
@DABH
DABH requested a balanced review from Copilot September 10, 2026 06:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused test infrastructure changes correctly address subprocess overhead and connection leaks.

Pull request overview

Updates Google GenAI MCP tests to reduce resource usage and prevent leaked echo-server connections.

Changes:

  • Uses in-memory MCP sessions for transport-independent tests.
  • Retains stdio coverage for discovery.
  • Properly evicts pooled connections during teardown.
File summaries
File Description
tests/contrib/google_genai/test_gemini_mcp.py Splits session transports and closes pooled connections.
tests/contrib/google_genai/echo_mcp_server.py Documents stdio and in-memory usage.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@DABH DABH added the ai-sdk Related to AI integrations label Sep 10, 2026
@DABH
DABH marked this pull request as ready for review September 10, 2026 07:37
@DABH
DABH requested review from a team as code owners September 10, 2026 07:37
@tconley1428
tconley1428 merged commit 226a039 into main Sep 10, 2026
34 of 37 checks passed
@tconley1428
tconley1428 deleted the flake/genai-mcp-inmemory branch September 10, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-sdk Related to AI integrations skip-changelog PR changes do not require changelog updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants