Skip to content

Add dual-era (Legacy/Modern) MCP support and fault-injection modes for ToolHive e2e tests #138

Closed

Description

@jhrozek

Why

stacklok/toolhive#5837 needs live e2e tests for dual-era MCP proxy behavior: Legacy
(2025-11-25, session-based, Mcp-Session-Id) and Modern (2026-07-28, stateless,
per-request _meta), plus concurrency/fault-injection coverage for a
confidentiality-sensitive code path. Rather than growing bespoke test infrastructure
in the ToolHive repo, this pushes the reusable capability into yardstick — the shared
in-house MCP test tool — so ToolHive can drive both eras, and inject faults, through it
directly.

What this adds

  • Fault-injection modes (BACKEND_MODE=echo|barrier|hang|crash on yardstick-server,
    plus BARRIER_N/HANG_AFTER_N/CRASH_AFTER_N/BARRIER_TIMEOUT_SECONDS): a shared
    AddReceivingMiddleware hook makes the server a controllable backend — buffer N
    requests and release together (barrier, for testing response cross-delivery /
    confidentiality under concurrency), stop responding after N (hang), or exit non-zero
    after N (crash) — uniformly across stdio/SSE/streamable-http. Lifecycle traffic
    (initialize, ping, server/discover, notifications/initialized) is exempted so
    the fault fires on the Nth real backend call, not during connection setup.
  • Modern (2026-07-28) support: go-sdk bumped to v1.7.0-pre.3 (no stable v1.7.0 tag
    exists yet — flagged as an open question below), a --stateless flag/STATELESS env
    var wiring StreamableHTTPOptions.Stateless for the streamable-http transport, and
    yardstick-client now reports the negotiated protocol version and correctly skips
    Ping when talking to a Modern session (go-sdk's server rejects ping under the new
    protocol's per-request _meta).
  • e2e coverage: test/integration-test.sh (the project's real black-box e2e script,
    already a required CI gate via task test-integration) got four new blocks — barrier,
    hang, crash, stateless — matching the existing per-transport block conventions exactly,
    so every new capability has the same real-container, real-binary check every prior
    capability already gets.

Open questions carried over from design

  • Willing to take the go-sdk v1.7.0-pre.3 pre-release now, or wait for a stable
    v1.7.0 tag? It's isolated to its own commit so re-pinning later is a one-line change.
  • Preferred config surface going forward: the fault-injection knobs are intentionally
    env-only (no flags) since they need to work identically through thv run -e, an
    MCPServer CRD's env, and plain k8s pod env — is that the right call long-term, or
    should there also be flag equivalents?
  • Release cadence / image tagging: ToolHive would pin a yardstick image tag once this
    lands — how fast can a new tag ship if a future test needs a new mode?
  • barrier mode is per-process, so it can't fill across k8s replicas — ToolHive's
    multi-replica step should use echo, not barrier, for that scenario.

PR incoming with the full implementation.

Activity

  1. added
    needs-triage
    on Jul 22, 2026
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

    needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions