Skip to content

Integration tests for vMCP horizontal scaling (THV-0047) #4222

@yrobla

Description

@yrobla

Description

Add integration tests covering the end-to-end vMCP horizontal scaling scenario implemented by TASK-001 through TASK-007 in the vMCP epic (stacklok/stacklok-epics#262). These tests verify that session reconstruction, cross-pod hijack prevention, LRU eviction, and Redis metadata lifecycle work correctly together, using miniredis to avoid a live Redis dependency.

Parent epic: stacklok/stacklok-epics#262

Dependencies: #283 (RC-9: Reconstruct vMCP Sessions from Redis on Cache Miss), #285 (RC-10: LRU Eviction), #276 (RC-16: Update Redis Metadata When Backend Sessions Expire)

Context

Individual task issues (TASK-001 through TASK-007) include unit-test acceptance criteria for their respective packages. This task adds higher-level integration tests that exercise the full session lifecycle across the components introduced by those tasks, analogous to TASK-008 in the operator epic (stacklok/stacklok-epics#284).

Acceptance Criteria

  • Integration test: session created on "pod A" (Redis-backed manager) can be reconstructed and served on "pod B" (second Redis-backed manager pointing at the same miniredis instance) via GetMultiSession cache-miss path
  • Integration test: hijack prevention is enforced cross-pod — a request with a different token cannot use a session restored from Redis
  • Integration test: LRU eviction on "pod A" causes session to be evicted from memory; subsequent GetMultiSession call triggers RestoreSession from Redis and succeeds
  • Integration test: when all backends fail to reconnect during RestoreSession, session is returned with empty routing table (not an error), consistent with makeSession partial-failure behavior
  • Integration test: when a backend session expires (RC-16), the corresponding Redis metadata keys are removed; a subsequent RestoreSession does not attempt to reconnect that backend
  • Integration test: when Redis is not configured (nil RedisConfig), vMCP operates with in-memory-only storage and the above multi-pod scenarios are not exercised (verifies R-VMCP-4 regression guard)
  • All tests use miniredis.RunT(t) — no live Redis required
  • All tests pass: go test ./pkg/vmcp/... ./pkg/transport/session/...

Technical Approach

Test Location

Add a new file pkg/vmcp/server/sessionmanager/horizontal_scaling_integration_test.go (or equivalent) containing table-driven tests that:

  1. Spin up a miniredis instance
  2. Create two transportsession.Manager instances both backed by the same RedisStorage
  3. Use the first manager to create a session (simulating pod A)
  4. Use the second manager's GetMultiSession to reconstruct the session on a cache miss (simulating pod B)
  5. Verify the reconstructed session responds correctly to tool calls with the original caller identity

Patterns & Frameworks

  • github.com/alicebob/miniredis/v2 — in-process Redis for tests; follow pattern in pkg/authserver/storage/redis_test.go
  • Table-driven, t.Parallel() style — follow pkg/transport/session/storage_test.go
  • Fake backend connector pattern — follow pkg/vmcp/session/connector_integration_test.go

Code Pointers

  • pkg/vmcp/server/sessionmanager/session_manager.goGetMultiSession with Redis fallback (added in TASK-005)
  • pkg/vmcp/session/factory.goRestoreSession (added in TASK-005)
  • pkg/vmcp/session/internal/security/security.goRestoreHijackPrevention (added in TASK-004)
  • pkg/transport/session/storage_redis.goRedisStorage (added in TASK-001)
  • pkg/transport/session/manager.goNewManagerWithRedis (added in TASK-002)
  • pkg/authserver/storage/redis_test.go — miniredis helper pattern to follow

Out of Scope

  • E2E tests against a real Kubernetes cluster
  • Load or performance testing
  • Operator-level integration tests (covered in stacklok/stacklok-epics#284)

References

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestgoPull requests that update go codescalabilityItems related to scalabilityvmcpVirtual MCP Server related issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions