epp

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpectBufferResp

func ExpectBufferResp(body string, contentType string) []*extProcPb.ProcessingResponse

ExpectBufferResp asserts that the EPP buffers the response and rewrites the body. This uses the shared primitive but adds EPP-specific headers we expect.

func ExpectGRPCRouteTo

func ExpectGRPCRouteTo(endpoint, prompt, method string) []*extProcPb.ProcessingResponse

ExpectGRPCRouteTo asserts that the request was successfully routed to the specified endpoint.

func ExpectGRPCRouteToWithStream

func ExpectGRPCRouteToWithStream(endpoint, prompt, method string) []*extProcPb.ProcessingResponse

ExpectGRPCRouteToWithStream asserts that the request was successfully routed with streaming enabled.

func ExpectGRPCStreamResp

func ExpectGRPCStreamResp(chunks ...string) []*extProcPb.ProcessingResponse

ExpectGRPCStreamResp asserts that the EPP streams the gRPC response chunks.

func ExpectPassthroughRouteTo

func ExpectPassthroughRouteTo(endpoint string, rawBytes []byte) []*extProcPb.ProcessingResponse

ExpectPassthroughRouteTo asserts that the request was successfully routed to the specified endpoint and that the body was not parsed.

func ExpectReject

func ExpectReject(code envoyTypePb.StatusCode, msg string) []*extProcPb.ProcessingResponse

ExpectReject asserts that the EPP immediately rejected the request with the given code and message.

func ExpectRouteTo

func ExpectRouteTo(endpoint, targetModel, prompt string) []*extProcPb.ProcessingResponse

ExpectRouteTo asserts that the request was successfully routed to the specified endpoint and that the body was rewritten to match the target model.

func ExpectRouteToWithStream

func ExpectRouteToWithStream(endpoint, targetModel, prompt string) []*extProcPb.ProcessingResponse

ExpectRouteToWithStream asserts that the request was successfully routed with streaming enabled.

func ExpectStreamResp

func ExpectStreamResp(chunks ...string) []*extProcPb.ProcessingResponse

ExpectStreamResp asserts that the EPP streams the response chunks (pass-through). It constructs a sequence of: 1. ResponseHeaders (with "x-went-into-resp-headers" and "text/event-stream") 2. ResponseBody chunks (with EndOfStream=true on the final chunk)

func ReqRequestHeadersAndResponseGRPC

func ReqRequestHeadersAndResponseGRPC(
	reqHeaders map[string]string,
	respHeaders map[string]string,
	bodyChunks ...[]byte,
) []*extProcPb.ProcessingRequest

ReqRequestHeadersAndResponseGRPC creates a sequence that starts with request headers (to resolve parser) followed by response phase.

func ReqResponseOnly

func ReqResponseOnly(
	respHeaders map[string]string,
	bodyChunks ...string,
) []*extProcPb.ProcessingRequest

ReqResponseOnly creates a sequence simulating only the response phase from Envoy. It skips the RequestHeaders phase entirely.

func ReqSubset

func ReqSubset(prompt, model, target string, subsets ...string) []*extProcPb.ProcessingRequest

ReqSubset creates a request sequence with Envoy Endpoint Metadata. This simulates the "Subset Load Balancing" flow where EPP picks a specific pod IP.

Types

type HarnessConfig

type HarnessConfig struct {

	// Tracing indicates if tracing should be enabled for this test.
	Tracing bool
	// contains filtered or unexported fields
}

HarnessConfig holds configuration options for the TestHarness.

type HarnessOption

type HarnessOption func(*HarnessConfig)

HarnessOption is a functional option for configuring the TestHarness.

func WithConfigText

func WithConfigText(text string) HarnessOption

WithConfigText overrides the default EPP configuration text.

func WithStandaloneMode

func WithStandaloneMode(standaloneStrategy standaloneStrategy) HarnessOption

WithStandaloneMode configures the harness to run in standalone runMode

func WithStandardMode

func WithStandardMode() HarnessOption

WithStandardMode configures the harness to run in standard runMode

func WithTracing

func WithTracing() HarnessOption

WithTracing enables tracing for the test harness.

type PodState

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

func P

func P(idx int, q int, kv float64, models ...string) PodState

P constructs a Pod State: Index, Queue, KV%, Models... Usage: P(0, 5, 0.2, "model-a")

type TestHarness

type TestHarness struct {
	Namespace string

	Tracing bool

	Client    extProcPb.ExternalProcessor_ProcessClient
	Datastore datastore.Datastore

	// --- Tracing State ---
	Exporter *tracetest.InMemoryExporter

	Runner *eppRunner.Runner
	// contains filtered or unexported fields
}

TestHarness encapsulates the environment for a single isolated EPP test run. It manages the lifecycle of the controller manager, the EPP server, and the K8s namespace.

func NewTestHarness

func NewTestHarness(ctx context.Context, t *testing.T, opts ...HarnessOption) *TestHarness

NewTestHarness boots up a fully isolated test environment. It creates a unique Namespace, scopes the Manager to that Namespace, and starts the components. Note: EPP tests must run serially because they rely on the global Prometheus registry.

func (*TestHarness) ExpectMetrics

func (h *TestHarness) ExpectMetrics(expected map[string]string)

ExpectMetrics asserts that specific metrics match the expected Prometheus output. It uses Eventually to allow for slight delays in metric recording (e.g. async token counting).

func (*TestHarness) GetSpans

func (h *TestHarness) GetSpans() tracetest.SpanStubs

GetSpans returns the currently recorded spans from the in-memory exporter.

func (*TestHarness) WaitForReadyPodsMetric

func (h *TestHarness) WaitForReadyPodsMetric(expectedCount int)

WaitForReadyPodsMetric blocks until the prometheus metric 'inference_pool_ready_pods' matches the expected count.

func (*TestHarness) WaitForSync

func (h *TestHarness) WaitForSync(expectedPods int, checkModelObjective string) *TestHarness

WaitForSync blocks until the EPP Datastore has synced the expected number of pods.

func (*TestHarness) WithBaseResources

func (h *TestHarness) WithBaseResources() *TestHarness

WithBaseResources injects the standard pool and objective definitions into the test namespace. These resources are pre-parsed in TestMain to avoid I/O overhead in the loop.

func (*TestHarness) WithPods

func (h *TestHarness) WithPods(pods []PodState) *TestHarness

WithPods creates pod objects in the API server and configures the metrics backend.

Jump to

Keyboard shortcuts

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