e2eframework

package
v0.8.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 29 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ModelName                     = "llama2-7b"
	ModelNameQwen3                = "qwen3-8b"
	ModelNameQwen3ReplicaRPS      = "qwen3-8b-replica-rps"
	ModelNameQwen3ReplicaInflight = "qwen3-8b-replica-inflight"
	ModelNameVLLM                 = "llama2-7b-vllm"
	ModelNameVLLMBucket           = "llama2-7b-vllm-bucket"
	ModelNameSGLang               = "llama2-7b-sglang"
	ModelNameTRTLLM               = "llama2-7b-trtllm"
)

Variables

This section is empty.

Functions

func InitializeClient

func InitializeClient(ctx context.Context, t *testing.T) (*kubernetes.Clientset, *v1alpha1.Clientset)

func InitializeKubernetesClient

func InitializeKubernetesClient(t *testing.T) *kubernetes.Clientset

InitializeKubernetesClient creates a client for tests that only need direct API calls. Unlike InitializeClient, it does not start shared informers or wait for cache sync.

func NewOpenAIClient

func NewOpenAIClient(baseURL, apiKey string) openai.Client

func NewOpenAIClientWithConfigProfile

func NewOpenAIClientWithConfigProfile(baseURL, apiKey, configProfile string,
	respOpts ...option.RequestOption) openai.Client

NewOpenAIClientWithConfigProfile creates a client that sends config-profile header. The gateway plugin selects routing-strategy from the model's config profile (model.aibrix.ai/config) based on this header, rather than from the routing-strategy header.

func NewOpenAIClientWithRoutingStrategy

func NewOpenAIClientWithRoutingStrategy(baseURL, apiKey, routingStrategy string,
	respOpt option.RequestOption) openai.Client

func NewRequestID

func NewRequestID(prefix string) string

NewRequestID returns a request ID suitable for correlating gateway and backend records.

func PollPDChatCompletion

func PollPDChatCompletion(
	t *testing.T, client openai.Client, params openai.ChatCompletionNewParams,
) *openai.ChatCompletion

PollPDChatCompletion retries a PD chat completion until it succeeds or timeout. A single 503 after pod churn is not treated as failure: Envoy may still be hitting a gateway-plugin replica whose pod cache has not caught up.

func UpdatePodLabels

func UpdatePodLabels(
	t *testing.T,
	ctx context.Context,
	client kubernetes.Interface,
	namespace, podName string,
	updates map[string]string,
)

UpdatePodLabels updates selected labels and restores their previous values after the test. Both operations retry resource-version conflicts because Pods can be updated concurrently by Kubernetes and AIBrix controllers.

func ValidateAllPodsAreReady

func ValidateAllPodsAreReady(t *testing.T, client *kubernetes.Clientset, expectedPodCount int,
	labelSelector ...string)

ValidateAllPodsAreReady waits until the default namespace has exactly expectedPodCount active pods. An optional labelSelector scopes the count to a subset of pods, which is necessary when other, unrelated workloads share the namespace.

func ValidateInference

func ValidateInference(t *testing.T, modelName string)

func ValidateInferenceWithClient

func ValidateInferenceWithClient(t *testing.T, client openai.Client, modelName string)

func WaitForInference

func WaitForInference(t *testing.T, modelName string)

WaitForInference polls the public gateway until the model is actually servable. Kubernetes objects may exist before HTTPRoute backend references and gateway caches have converged, so object existence alone is not enough.

func WaitForPDCombinedRouting

func WaitForPDCombinedRouting(t *testing.T, modelName, combinedStormName, longPrompt string)

WaitForPDCombinedRouting polls until the gateway routes a long prompt to a combined pod (no prefill-target-pod header). Pod cache may lag behind Kubernetes readiness.

func WaitForPDDisaggregationRouting

func WaitForPDDisaggregationRouting(t *testing.T, modelName string)

WaitForPDDisaggregationRouting polls until the gateway can route a PD request for modelName. Pod readiness alone is not enough: the gateway pod cache may lag after pod churn, and with two plugin replicas one success can be a lucky hit on the warm replica.

Types

type Config

type Config struct {
	GatewayURL       string
	Namespace        string
	APIKey           string
	GatewayNamespace string
}

Config holds the environment-dependent endpoints and namespaces for live-cluster e2e tests.

func LoadConfig

func LoadConfig() Config

LoadConfig reads e2e configuration while preserving the previous local Kind defaults.

type MockRequestRecord

type MockRequestRecord struct {
	Sequence      int               `json:"sequence"`
	RequestID     string            `json:"request_id"`
	Path          string            `json:"path"`
	Headers       map[string]string `json:"headers"`
	RawBodyBase64 string            `json:"raw_body_base64"`
	ParsedJSON    json.RawMessage   `json:"parsed_json"`
	Pod           string            `json:"pod"`
	Engine        string            `json:"engine"`
	Role          string            `json:"role"`
	Outcome       string            `json:"outcome"`
	StatusCode    int               `json:"status_code"`
	Error         string            `json:"error"`
	Response      json.RawMessage   `json:"response"`
	DelayMS       int               `json:"delay_ms"`
}

MockRequestRecord is a JSON-compatible request record returned by the mock app.

func DecodeMockRequestRecords

func DecodeMockRequestRecords(body []byte) ([]MockRequestRecord, error)

DecodeMockRequestRecords decodes and orders records returned by the mock app.

func QueryAllMockRequests

func QueryAllMockRequests(
	ctx context.Context,
	client kubernetes.Interface,
	namespace, podName string,
) ([]MockRequestRecord, error)

QueryAllMockRequests reads every request record the mock pod still holds. Records the gateway did not tag with a request ID - the PD decode abort, which the engine matches on its own rid - are only reachable this way.

func QueryMockRequests

func QueryMockRequests(
	ctx context.Context,
	client kubernetes.Interface,
	namespace, podName, requestID string,
) ([]MockRequestRecord, error)

QueryMockRequests reads request records through the Kubernetes pod proxy.

func SelectSuccessfulPDLegs

func SelectSuccessfulPDLegs(
	records []MockRequestRecord,
	requestID, engine string,
) (prefill, decode MockRequestRecord, err error)

SelectSuccessfulPDLegs returns the unique successful prefill and decode legs.

func WaitForMockRequestCount

func WaitForMockRequestCount(
	ctx context.Context,
	client kubernetes.Interface,
	namespace, podName, requestID string,
	expected int,
	timeout time.Duration,
) ([]MockRequestRecord, error)

WaitForMockRequestCount waits for exactly expected completed recorder entries for one request ID. A backend can finish after the gateway has returned, so callers should wait for the recorder rather than race the backend response.

func WaitForPDLegOutcome

func WaitForPDLegOutcome(
	t *testing.T,
	client kubernetes.Interface,
	namespace, podName, requestID, engine, role, expectedOutcome string,
) MockRequestRecord

WaitForPDLegOutcome waits for one recorder entry with the requested outcome.

func WaitForPDLegOutcomeOnPods

func WaitForPDLegOutcomeOnPods(
	t *testing.T,
	client kubernetes.Interface,
	namespace string,
	podNames []string,
	requestID, engine, role, expectedOutcome string,
) MockRequestRecord

WaitForPDLegOutcomeOnPods waits for an outcome across a set of candidate pods. This is used when a gateway returns an error before exposing routing headers for the selected pods.

func WaitForSuccessfulPDLegs

func WaitForSuccessfulPDLegs(
	t *testing.T,
	client kubernetes.Interface,
	namespace, prefillPod, decodePod, requestID, engine string,
) (prefill, decode MockRequestRecord)

WaitForSuccessfulPDLegs waits for one successful HTTP-200 recorder entry per PD role.

type PDRequestResult

type PDRequestResult struct {
	StatusCode int
	Headers    http.Header
	Body       []byte
	RequestID  string
}

PDRequestResult contains the raw HTTP response from a PD gateway request.

func SendPDRequest

func SendPDRequest(
	ctx context.Context,
	config Config,
	routingStrategy, requestID string,
	body []byte,
) (PDRequestResult, error)

SendPDRequest sends an already-serialized JSON request through the gateway.

func SendPDRequestWithHeaders

func SendPDRequestWithHeaders(
	ctx context.Context,
	config Config,
	routingStrategy, requestID string,
	body []byte,
	extraHeaders http.Header,
) (PDRequestResult, error)

SendPDRequestWithHeaders sends an already-serialized JSON request with additional request-scoped headers used by mock PD contract tests.

Jump to

Keyboard shortcuts

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