Skip to content

[TESTING][GRPC]: Expand integration test depth (chunked deletes, metadata, exception wrap) #4618

@jonpspri

Description

@jonpspri

🧪 Testing Summary

PR #3202's deep review test-coverage analyzer flagged six paths in mcpgateway/services/grpc_service.py and mcpgateway/services/tool_service.py that are unit-tested at the helper level but not exercised end-to-end. Bundling them into a single follow-up issue rather than scattering 6 micro-issues.

📋 Test gaps

Production code in scope:

  • mcpgateway/services/grpc_service.py::invoke_method()
  • mcpgateway/services/grpc_service.py::delete_service()
  • mcpgateway/services/grpc_service.py::_sync_tools_from_reflection()
  • mcpgateway/services/tool_service.py::invoke_tool() (gRPC dispatch branch)

Specific paths needing coverage:

  1. delete_service chunked deletion (>500 tools) — the range(0, len(tool_ids), 500) loop is correct by inspection but never exercised by a test. Fixture: 1200 stale tools, assert 9 execute calls (3 chunks × 3 deletes).

  2. invoke_method gRPC metadata propagationservice.grpc_metadata is forwarded to GrpcEndpoint(metadata=...) but no test verifies the kwarg actually arrives. Spy on the GrpcEndpoint constructor.

  3. invoke_method exception wrapping — when endpoint.invoke() raises an arbitrary RuntimeError, the catch site re-raises as GrpcServiceError("Method invocation failed: …"). Verify the wrap and the from e chain.

  4. invoke_method finally-block close — when endpoint.invoke() raises, endpoint.close() must still be called. Today only happy-path tests exercise the close.

  5. _sync_tools_from_reflection schema-only-changed update — existing test changes url; need a test that ONLY changes input_schema (e.g., a method's input proto type changes between reflections) and verifies the tool is updated and the tools_updated counter increments.

  6. _sync_tools_from_reflection custom-description preserved counter — existing test verifies the description is preserved; need to assert tools_updated is NOT incremented in that branch (the changed=False path).

📋 Acceptance Criteria

Each gap above lands as a named test in tests/unit/mcpgateway/services/test_grpc_service.py and tests/unit/mcpgateway/services/test_tool_service.py. All 6 tests pass. No production code changes.

🔗 Context

Metadata

Metadata

Labels

COULDP3: Nice-to-have features with minimal impact if left out; included if time permitsmcp-protocolAlignment with MCP protocol or specificationtestingTesting (unit, e2e, manual, automated, etc)

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions