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
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
miniredis instance
- Create two
transportsession.Manager instances both backed by the same RedisStorage
- Use the first manager to create a session (simulating pod A)
- Use the second manager's
GetMultiSession to 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 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.go — GetMultiSession with 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
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
miniredisto 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
GetMultiSessioncache-miss pathGetMultiSessioncall triggersRestoreSessionfrom Redis and succeedsRestoreSession, session is returned with empty routing table (not an error), consistent withmakeSessionpartial-failure behaviorRC-16), the corresponding Redis metadata keys are removed; a subsequentRestoreSessiondoes not attempt to reconnect that backendRedisConfig), vMCP operates with in-memory-only storage and the above multi-pod scenarios are not exercised (verifies R-VMCP-4 regression guard)miniredis.RunT(t)— no live Redis requiredgo 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:miniredisinstancetransportsession.Managerinstances both backed by the sameRedisStorageGetMultiSessionto reconstruct the session on a cache miss (simulating pod B)Patterns & Frameworks
github.com/alicebob/miniredis/v2— in-process Redis for tests; follow pattern inpkg/authserver/storage/redis_test.got.Parallel()style — followpkg/transport/session/storage_test.gopkg/vmcp/session/connector_integration_test.goCode 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 followOut of Scope
References