Skip to content

Split vMCP e2e tests into e2e and integration test layers #2852

Closed as not planned

Description

@JAORMX

Summary

Reorganize vMCP tests into distinct e2e and integration test layers for faster feedback loops and better edge case coverage.

Background

Current vMCP test architecture:

  • ~5,500 lines of e2e tests in test/e2e/thv-operator/virtualmcp/
  • Tests cover: auth discovery, aggregation, filtering, overrides, conflict resolution, composite workflows
  • All tests run against a real Kubernetes cluster
  • E2E tests are slow due to full cluster setup/teardown

Current Test Files

test/e2e/thv-operator/virtualmcp/
├── suite_test.go                              (101 lines)
├── helpers.go                                 (631 lines)
├── virtualmcp_auth_discovery_test.go          (1,591 lines)
├── virtualmcp_aggregation_filtering_test.go   (322 lines)
├── virtualmcp_aggregation_overrides_test.go   (295 lines)
├── virtualmcp_conflict_resolution_test.go     (686 lines)
├── virtualmcp_composite_parallel_test.go      (374 lines)
├── virtualmcp_composite_sequential_test.go    (317 lines)
├── virtualmcp_discovered_mode_test.go         (391 lines)
├── virtualmcp_inline_auth_test.go             (467 lines)
└── virtualmcp_yardstick_base_test.go          (337 lines)

Problem

  1. Slow CI feedback - Full e2e tests take significant time
  2. Edge case difficulty - Hard to test timeouts, network failures, partial failures in e2e
  3. No test layer separation - All tests require full Kubernetes environment

Proposed Structure

Integration Tests (test/integration/vmcp/)

Fast tests that don't require Kubernetes:

  • Aggregator logic (conflict resolution, capability merging)
  • Router logic (tool routing, backend selection)
  • Composer logic (workflow execution, template expansion)
  • Config loading and validation
  • Mock backend interactions

E2E Tests (test/e2e/thv-operator/virtualmcp/)

Full cluster tests for end-to-end validation:

  • CRD creation and reconciliation
  • Full request flow (client → vMCP → backend)
  • Auth flows (OIDC, token exchange)
  • Status reporting

Implementation

  1. Create integration test structure

    test/integration/vmcp/
    ├── aggregator_test.go      # Conflict resolution, capability merging
    ├── router_test.go          # Request routing logic
    ├── composer_test.go        # Workflow execution
    ├── config_test.go          # Configuration validation
    └── helpers.go              # Mock backends, test utilities
    
  2. Extract testable logic

    • Ensure vMCP packages are unit-testable
    • Add interfaces for backend interactions (already exists)
    • Create mock implementations for testing
  3. Move edge case tests to integration

    • Timeout handling
    • Partial backend failures
    • Invalid configurations
    • Concurrent request handling
  4. Update CI pipeline

    • Run integration tests on every PR
    • Run e2e tests on merge to main (or nightly)

Acceptance Criteria

  • Integration test directory created
  • Core logic tests extracted from e2e
  • Integration tests run without Kubernetes
  • Edge case tests (timeouts, failures) in integration layer
  • E2E tests remain for full flow validation
  • CI pipeline updated for two-tier testing
  • Test documentation updated

Activity

  1. added
    enhancement
    vmcp
    on Dec 2, 2025
  2. added
    go
    kubernetes
    on Dec 2, 2025
  3. jerm-dro commented on Dec 12, 2025

    @jerm-dro
    Collaborator

    I'm concerned that if we rewrite k8s tests into simpler integration tests then we'll lose coverage of the operator and config plumbing. This lack of coverage could result in functionality that is working in integration tests but fails when using the k8s operator.

    Background: Currently, config for operators goes through many transformation: CRD config -> yaml -> rawConfig -> actual config.

    I've first-hand experienced this where I have passing integration tests and the problem is something broken/missing in this series of transformations.

    I'd suggest we don't do this work until P(Feature X works in operator | Feature X works in integration tests) is nearly 1. In other words, I think we need to simplify the configuration system before reducing our test coverage on the operator.

  4. assigned and unassigned on Dec 15, 2025
  5. jhrozek commented on Dec 15, 2025

    @jhrozek
    Contributor

    I'm concerned that if we rewrite k8s tests into simpler integration tests then we'll lose coverage of the operator and config plumbing. This lack of coverage could result in functionality that is working in integration tests but fails when using the k8s operator.

    Background: Currently, config for operators goes through many transformation: CRD config -> yaml -> rawConfig -> actual config.

    I've first-hand experienced this where I have passing integration tests and the problem is something broken/missing in this series of transformations.

    I'd suggest we don't do this work until P(Feature X works in operator | Feature X works in integration tests) is nearly 1. In other words, I think we need to simplify the configuration system before reducing our test coverage on the operator.

    I'm not against that, the argument was that integration tests are faster to run and can test corner cases, too, where many of our e2e tests were just testing the conversion to the right config anyway.

    If you want to take the issue, reword it and propose how you feel the testing should be done, it would be very much appreciated.

    (Don't feel bound by the issue title, the point really is to "make sure we have appropriate test coverage")

  6. jerm-dro commented on Dec 19, 2025

    @jerm-dro
    Collaborator

    @jhrozek I think this issue has merit as is, but should be proceeded by other work. I was once again bitten by a config plumbing issue: https://github.com/stacklok/toolhive/compare/jerm/2025-12-18-fix-config-plumbing?expand=1. I haven't had the time to write a regression test for this, but we already have an integration test that passes.

    I'll draft an issue tomorrow describing the config problem and potential solution in greater detail..

  7. self-assigned this
    on Jan 7, 2026
  8. jerm-dro commented on Jan 7, 2026

    @jerm-dro
    Collaborator

    I'll be picking this up once #3125 is completed

  9. removed their assignment
    on Jan 14, 2026
  10. jerm-dro commented on Feb 3, 2026

    @jerm-dro
    Collaborator

    The vMCP folks and I discussed this a bit today and decided to deprioritize this issue. Re-writing tests will be a non-negligible lift. Within the vMCP work, we have been working towards writing more unit tests and only relying on integration tests as smoke tests. Furthermore, the current factoring of the vMCP system means a lot of these e2e tests provide meaningful coverage that can't be verified at lower levels (e.g. config plumbing, reconciler behavior).

    For the time being, I've removed this from Stacklok's productionization epic. We can revisit this again in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgokubernetesoperatorvmcp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions