Documentation
¶
Index ¶
- Constants
- func InitializeClient(ctx context.Context, t *testing.T) (*kubernetes.Clientset, *v1alpha1.Clientset)
- func InitializeKubernetesClient(t *testing.T) *kubernetes.Clientset
- func NewOpenAIClient(baseURL, apiKey string) openai.Client
- func NewOpenAIClientWithConfigProfile(baseURL, apiKey, configProfile string, respOpts ...option.RequestOption) openai.Client
- func NewOpenAIClientWithRoutingStrategy(baseURL, apiKey, routingStrategy string, respOpt option.RequestOption) openai.Client
- func NewRequestID(prefix string) string
- func PollPDChatCompletion(t *testing.T, client openai.Client, params openai.ChatCompletionNewParams) *openai.ChatCompletion
- func UpdatePodLabels(t *testing.T, ctx context.Context, client kubernetes.Interface, ...)
- func ValidateAllPodsAreReady(t *testing.T, client *kubernetes.Clientset, expectedPodCount int, ...)
- func ValidateInference(t *testing.T, modelName string)
- func ValidateInferenceWithClient(t *testing.T, client openai.Client, modelName string)
- func WaitForInference(t *testing.T, modelName string)
- func WaitForPDCombinedRouting(t *testing.T, modelName, combinedStormName, longPrompt string)
- func WaitForPDDisaggregationRouting(t *testing.T, modelName string)
- type Config
- type MockRequestRecord
- func DecodeMockRequestRecords(body []byte) ([]MockRequestRecord, error)
- func QueryAllMockRequests(ctx context.Context, client kubernetes.Interface, namespace, podName string) ([]MockRequestRecord, error)
- func QueryMockRequests(ctx context.Context, client kubernetes.Interface, ...) ([]MockRequestRecord, error)
- func SelectSuccessfulPDLegs(records []MockRequestRecord, requestID, engine string) (prefill, decode MockRequestRecord, err error)
- func WaitForMockRequestCount(ctx context.Context, client kubernetes.Interface, ...) ([]MockRequestRecord, error)
- func WaitForPDLegOutcome(t *testing.T, client kubernetes.Interface, ...) MockRequestRecord
- func WaitForPDLegOutcomeOnPods(t *testing.T, client kubernetes.Interface, namespace string, podNames []string, ...) MockRequestRecord
- func WaitForSuccessfulPDLegs(t *testing.T, client kubernetes.Interface, ...) (prefill, decode MockRequestRecord)
- type PDRequestResult
Constants ¶
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 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 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 ¶
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 WaitForInference ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.