Repository navigation
Description
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
GetMultiSessioncache-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
GetMultiSessioncall triggersRestoreSessionfrom Redis and succeeds - Integration test: when all backends fail to reconnect during
RestoreSession, session is returned with empty routing table (not an error), consistent withmakeSessionpartial-failure behavior - Integration test: when a backend session expires (
RC-16), the corresponding Redis metadata keys are removed; a subsequentRestoreSessiondoes 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:
- Spin up a
miniredisinstance - Create two
transportsession.Managerinstances both backed by the sameRedisStorage - Use the first manager to create a session (simulating pod A)
- Use the second manager's
GetMultiSessionto reconstruct the session on a cache miss (simulating pod B) - 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 inpkg/authserver/storage/redis_test.go- Table-driven,
t.Parallel()style — followpkg/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.go—GetMultiSessionwith Redis fallback (added in TASK-005)pkg/vmcp/session/factory.go—RestoreSession(added in TASK-005)pkg/vmcp/session/internal/security/security.go—RestoreHijackPrevention(added in TASK-004)pkg/transport/session/storage_redis.go—RedisStorage(added in TASK-001)pkg/transport/session/manager.go—NewManagerWithRedis(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
- Parent epic: stacklok/stacklok-epics#262
- RFC THV-0047: RFC: Horizontal Scaling for vMCP and Proxy Runner rfcs#47
- Operator equivalent: stacklok/stacklok-epics#284 (TASK-008 Unit Tests)
- miniredis: https://github.com/alicebob/miniredis
Activity
Add horizontal scaling tests for vmcp
Add horizontal scaling tests for vmcp
Add horizontal scaling tests for vmcp
Add horizontal scaling tests for vmcp
Add horizontal scaling tests for vmcp
Add horizontal scaling tests for vmcp
yrobla commentedon Apr 14, 2026
This is the implementation issue for TASK-008 in epic stacklok/stacklok-epics#262 (Horizontal Scaling for vMCP). The epic is now correctly tracking this issue as a sub-issue.
The integration test file (
pkg/vmcp/server/sessionmanager/horizontal_scaling_integration_test.go) has not been created yet — this issue remains open. stacklok-epics#288 (the planning-level tracking issue) has been reopened to match.yrobla commentedon Apr 14, 2026
Implemented by #4724, which covers all acceptance criteria:
E2E tests in test/e2e/thv-operator/virtualmcp/virtualmcp_redis_session_test.go additionally cover pod restart recovery and cross-pod lazy eviction.
Add horizontal scaling tests for vmcp (#4724)