e2e

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const TestClientInstanceHeader = "X-Test-Tunnel-Client-Instance"

TestClientInstanceHeader identifies harnessed tunnel-client instances in mock control-plane requests.

Variables

This section is empty.

Functions

This section is empty.

Types

type Harness

type Harness struct {
	ControlPlane    *mocktunnelservice.MockTunnelService
	MCP             *mockmcpserver.MockMCPServer
	HarpoonRegistry *harpoon.Registry
	MCPProbeState   *mcpclient.ProbeState
	// contains filtered or unexported fields
}

Harness wires together the mock control plane, mock MCP server, and a running tunnel-client.

func NewHarness

func NewHarness(t testing.TB, opts ...HarnessOption) *Harness

NewHarness configures the mocks and client wiring using the provided options.

func (*Harness) ExecuteScenario

func (h *Harness) ExecuteScenario(t testing.TB) error

ExecuteScenario returns the error (if any) instead of failing the test directly.

func (*Harness) ExecuteScenarious

func (h *Harness) ExecuteScenarious(t testing.TB)

ExecuteScenarious orchestrates the tunnel lifecycle, waits for the control plane queue to drain, and then shuts everything down before returning.

func (*Harness) PrimaryClient

func (h *Harness) PrimaryClient() *TunnelClient

PrimaryClient returns the first tunnel-client instance started by the harness.

func (*Harness) SetTLSBundle

func (h *Harness) SetTLSBundle(bundle *tlsconfig.Bundle)

SetTLSBundle updates the TLS bundle used by the harnessed tunnel-client.

func (*Harness) StartAdditionalClient

func (h *Harness) StartAdditionalClient(t testing.TB) *TunnelClient

StartAdditionalClient starts another tunnel-client against the harnessed mocks.

func (*Harness) WaitForMCPProbe

func (h *Harness) WaitForMCPProbe(ctx context.Context) error

WaitForMCPProbe blocks until the startup MCP probe records a result or ctx is canceled.

type HarnessOption

type HarnessOption func(*harnessConfig)

HarnessOption customizes the E2E harness configuration.

func WithAPIKey

func WithAPIKey(key string) HarnessOption

WithAPIKey overrides the API key used between the client and mock control plane.

func WithAfterClientStart

func WithAfterClientStart(fn func(*Harness)) HarnessOption

WithAfterClientStart registers a hook that runs after tunnel-client starts.

func WithBeforeClientStart

func WithBeforeClientStart(fn func(*Harness)) HarnessOption

WithBeforeClientStart registers a hook that runs after mocks start but before tunnel-client starts.

func WithBeforeClientStop

func WithBeforeClientStop(fn func(*Harness)) HarnessOption

WithBeforeClientStop registers a hook that runs after scripted commands drain and before tunnel-client stops.

func WithClientConfig

func WithClientConfig(fn func(*config.Config)) HarnessOption

WithClientConfig allows tests to customize the derived tunnel-client config.

func WithControlPlaneOptions

func WithControlPlaneOptions(opts ...mocktunnelservice.Option) HarnessOption

WithControlPlaneOptions forwards additional options to the mock control plane.

func WithHarpoonInMemoryTransport

func WithHarpoonInMemoryTransport() HarnessOption

WithHarpoonInMemoryTransport routes MCP traffic to the embedded harpoon server.

func WithInMemoryMCPTransport

func WithInMemoryMCPTransport() HarnessOption

WithInMemoryMCPTransport uses the in-memory MCP transport for this harness.

func WithLogWriter

func WithLogWriter(w io.Writer) HarnessOption

WithLogWriter overrides the writer used by the tunnel-client logging module. The harness always tees writes into an internal buffer so logs can be dumped when ExecuteScenarious encounters an error.

func WithMCPCommand

func WithMCPCommand(commandArgs []string) HarnessOption

WithMCPCommand configures the client to launch an MCP server over stdio.

func WithMCPOptions

func WithMCPOptions(opts ...mockmcpserver.Option) HarnessOption

WithMCPOptions forwards additional options to the mock MCP server.

func WithPreserveClientURLs

func WithPreserveClientURLs() HarnessOption

WithPreserveClientURLs prevents the harness from overwriting control-plane and MCP URLs.

func WithScenarioTimeout

func WithScenarioTimeout(timeout time.Duration) HarnessOption

WithScenarioTimeout overrides the time ExecuteScenarious waits for the scripted tunnel commands to drain before failing the test.

func WithTunnelID

func WithTunnelID(id types.TunnelID) HarnessOption

WithTunnelID overrides the tunnel identifier advertised to the client.

func WithUnixControlPlane

func WithUnixControlPlane() HarnessOption

WithUnixControlPlane routes tunnel-client control-plane HTTP over a Unix-domain socket.

func WithUnixMCP

func WithUnixMCP() HarnessOption

WithUnixMCP routes tunnel-client MCP HTTP over a Unix-domain socket.

type TunnelClient

type TunnelClient struct {
	// contains filtered or unexported fields
}

TunnelClient exposes deterministic poller control for one harnessed tunnel-client instance.

func (*TunnelClient) Name

func (c *TunnelClient) Name() string

Name returns the deterministic instance label added to control-plane test requests.

func (*TunnelClient) PausePoller

func (c *TunnelClient) PausePoller(ctx context.Context) error

PausePoller blocks future polls and cancels any active poll before returning.

func (*TunnelClient) PollCount

func (c *TunnelClient) PollCount() int

PollCount returns the number of poll cycles this client has started.

func (*TunnelClient) UnpausePoller

func (c *TunnelClient) UnpausePoller()

UnpausePoller allows a paused poller to resume polling.

func (*TunnelClient) WaitForPolls

func (c *TunnelClient) WaitForPolls(ctx context.Context, want int) error

WaitForPolls blocks until this client has started at least want poll cycles.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL