Documentation
¶
Overview ¶
Package controller provides helpers for controller integration tests.
Index ¶
- func CreateNamespace(ctx context.Context, c client.Client, generateName string, ...) *corev1.Namespace
- func DeleteNamespace(ctx context.Context, c client.Client, ns *corev1.Namespace)
- func FindBindableNonLoopbackIPv4(port int) string
- func ListModelWarmupJobs(g gomega.Gomega, ctx context.Context, c client.Client, namespace, name string) []batchv1.Job
- func ModelWarmupJobNode(job *batchv1.Job) string
- func NewModelWarmup(namespace, name, node string) *modelapi.ModelWarmup
- func StartFixedPortHTTPServer(ip string, port int, handler http.Handler, timeout time.Duration, ...) *httptest.Server
- type FakeModelClaimRuntime
- func (f *FakeModelClaimRuntime) ActivateCallCount() int
- func (f *FakeModelClaimRuntime) ClaimUIDs() []string
- func (f *FakeModelClaimRuntime) Close()
- func (f *FakeModelClaimRuntime) DeactivateRequests() []modelclaimcontroller.DeactivateRequest
- func (f *FakeModelClaimRuntime) FailNextActivations(count int)
- func (f *FakeModelClaimRuntime) FailNextWakes(count int)
- func (f *FakeModelClaimRuntime) IP() string
- func (f *FakeModelClaimRuntime) KVLimitRequests() []modelclaimcontroller.SetKVLimitRequest
- func (f *FakeModelClaimRuntime) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (f *FakeModelClaimRuntime) SetCard(bytes int64)
- func (f *FakeModelClaimRuntime) SetCards(sizes ...int64)
- func (f *FakeModelClaimRuntime) SetClaimKV(uid string, used, capacity int64)
- func (f *FakeModelClaimRuntime) SetClaimRequests(uid string, running, waiting int64)
- func (f *FakeModelClaimRuntime) SetClaimState(uid, phase string, ready bool, lastError string)
- func (f *FakeModelClaimRuntime) SetDefaultState(phase string, ready bool)
- func (f *FakeModelClaimRuntime) SetKVLimitReadBack(enabled bool)
- func (f *FakeModelClaimRuntime) SetSleepingFootprint(bytes int64)
- func (f *FakeModelClaimRuntime) SleepRequests() []modelclaimcontroller.SleepRequest
- func (f *FakeModelClaimRuntime) WakeRequests() []modelclaimcontroller.WakeRequest
- type ModelClaimFixture
- func (f *ModelClaimFixture) Close()
- func (f *ModelClaimFixture) CreateClaim(namespace, name, pool string, modelName *string, engineArgs map[string]string) *modelapi.ModelClaim
- func (f *ModelClaimFixture) CreatePoolPod(namespace, name, pool, policy string) *corev1.Pod
- func (f *ModelClaimFixture) CreateWarmPod(namespace, name, pool string) *corev1.Pod
- func (f *ModelClaimFixture) CreateWarmPodPending(namespace, name, pool string, gpuCount int64) *corev1.Pod
- func (f *ModelClaimFixture) ExpectEvent(claim *modelapi.ModelClaim, eventType, reason string)
- func (f *ModelClaimFixture) ExpectRoute(g gomega.Gomega, namespace, podName, claimName string, port int32, ...)
- func (f *ModelClaimFixture) GetClaim(g gomega.Gomega, claim *modelapi.ModelClaim) *modelapi.ModelClaim
- func (f *ModelClaimFixture) MarkWarmPodRunning(pod *corev1.Pod)
- func (f *ModelClaimFixture) RequestWake(namespace, podName, claimName string)
- func (f *ModelClaimFixture) Runtime() *FakeModelClaimRuntime
- func (f *ModelClaimFixture) TriggerReconcile(claim *modelapi.ModelClaim)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNamespace ¶
func CreateNamespace( ctx context.Context, c client.Client, generateName string, timeout time.Duration, pollingInterval ...time.Duration, ) *corev1.Namespace
CreateNamespace creates a namespace and waits until it can be retrieved.
func DeleteNamespace ¶
DeleteNamespace deletes a non-nil namespace, ignoring an already absent namespace.
func FindBindableNonLoopbackIPv4 ¶
FindBindableNonLoopbackIPv4 returns a non-loopback IPv4 address that can bind port.
func ListModelWarmupJobs ¶
func ModelWarmupJobNode ¶
func NewModelWarmup ¶
func NewModelWarmup(namespace, name, node string) *modelapi.ModelWarmup
Types ¶
type FakeModelClaimRuntime ¶
type FakeModelClaimRuntime struct {
// contains filtered or unexported fields
}
FakeModelClaimRuntime serves controllable runtime responses for ModelClaim tests.
func (*FakeModelClaimRuntime) ActivateCallCount ¶
func (f *FakeModelClaimRuntime) ActivateCallCount() int
ActivateCallCount returns the total number of activation attempts, including failures.
func (*FakeModelClaimRuntime) ClaimUIDs ¶
func (f *FakeModelClaimRuntime) ClaimUIDs() []string
ClaimUIDs returns the unique claim UIDs recorded in activation requests.
func (*FakeModelClaimRuntime) Close ¶
func (f *FakeModelClaimRuntime) Close()
Close stops the fake server and tolerates incomplete setup.
func (*FakeModelClaimRuntime) DeactivateRequests ¶
func (f *FakeModelClaimRuntime) DeactivateRequests() []modelclaimcontroller.DeactivateRequest
DeactivateRequests returns a defensive copy of the recorded deactivation requests.
func (*FakeModelClaimRuntime) FailNextActivations ¶
func (f *FakeModelClaimRuntime) FailNextActivations(count int)
FailNextActivations injects failures into the next count activation requests.
func (*FakeModelClaimRuntime) FailNextWakes ¶
func (f *FakeModelClaimRuntime) FailNextWakes(count int)
FailNextWakes makes the next count wake requests fail, as a runtime does when vLLM cannot wake its engine.
func (*FakeModelClaimRuntime) IP ¶
func (f *FakeModelClaimRuntime) IP() string
IP returns the address used by fixture pods to reach the runtime.
func (*FakeModelClaimRuntime) KVLimitRequests ¶
func (f *FakeModelClaimRuntime) KVLimitRequests() []modelclaimcontroller.SetKVLimitRequest
KVLimitRequests returns a defensive copy of the recorded KV-limit requests.
func (*FakeModelClaimRuntime) ServeHTTP ¶
func (f *FakeModelClaimRuntime) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles the runtime activation, deactivation, snapshot, and model-list endpoints.
func (*FakeModelClaimRuntime) SetCard ¶
func (f *FakeModelClaimRuntime) SetCard(bytes int64)
SetCard has the runtime report one card of the given size.
func (*FakeModelClaimRuntime) SetCards ¶
func (f *FakeModelClaimRuntime) SetCards(sizes ...int64)
SetCards has the runtime report cards of the given sizes.
func (*FakeModelClaimRuntime) SetClaimKV ¶
func (f *FakeModelClaimRuntime) SetClaimKV(uid string, used, capacity int64)
SetClaimKV changes the KV usage and capacity reported for an activated claim.
func (*FakeModelClaimRuntime) SetClaimRequests ¶
func (f *FakeModelClaimRuntime) SetClaimRequests(uid string, running, waiting int64)
SetClaimRequests changes the request counts reported for an activated claim.
func (*FakeModelClaimRuntime) SetClaimState ¶
func (f *FakeModelClaimRuntime) SetClaimState(uid, phase string, ready bool, lastError string)
SetClaimState updates the runtime state for an already activated claim UID. An engine set asleep holds the sleeping footprint the fixture sets.
func (*FakeModelClaimRuntime) SetDefaultState ¶
func (f *FakeModelClaimRuntime) SetDefaultState(phase string, ready bool)
SetDefaultState sets the initial phase and readiness of future activations.
func (*FakeModelClaimRuntime) SetKVLimitReadBack ¶
func (f *FakeModelClaimRuntime) SetKVLimitReadBack(enabled bool)
SetKVLimitReadBack controls whether a successful KV-limit write changes the capacity returned by subsequent snapshots.
func (*FakeModelClaimRuntime) SetSleepingFootprint ¶
func (f *FakeModelClaimRuntime) SetSleepingFootprint(bytes int64)
SetSleepingFootprint sets what an engine holds once it is asleep.
func (*FakeModelClaimRuntime) SleepRequests ¶
func (f *FakeModelClaimRuntime) SleepRequests() []modelclaimcontroller.SleepRequest
SleepRequests returns a copy of the recorded sleep requests.
func (*FakeModelClaimRuntime) WakeRequests ¶
func (f *FakeModelClaimRuntime) WakeRequests() []modelclaimcontroller.WakeRequest
WakeRequests returns a defensive copy of the recorded wake requests.
type ModelClaimFixture ¶
type ModelClaimFixture struct {
// contains filtered or unexported fields
}
ModelClaimFixture owns the client dependencies and fake runtime for a ModelClaim scenario.
func NewModelClaimFixture ¶
func NewModelClaimFixture(ctx context.Context, c client.Client, timeout, interval time.Duration) *ModelClaimFixture
NewModelClaimFixture starts a runtime, registers cleanup, and configures the scenario's polling helpers.
func (*ModelClaimFixture) Close ¶
func (f *ModelClaimFixture) Close()
Close stops the fixture runtime and tolerates incomplete setup.
func (*ModelClaimFixture) CreateClaim ¶
func (f *ModelClaimFixture) CreateClaim( namespace, name, pool string, modelName *string, engineArgs map[string]string, ) *modelapi.ModelClaim
CreateClaim creates a ModelClaim with the integration runtime defaults.
func (*ModelClaimFixture) CreatePoolPod ¶
func (f *ModelClaimFixture) CreatePoolPod(namespace, name, pool, policy string) *corev1.Pod
CreatePoolPod creates a running pool pod that belongs to a Deployment, through a ReplicaSet, as a warm pool's pods do. The Deployment carries the given pool policy.
func (*ModelClaimFixture) CreateWarmPod ¶
func (f *ModelClaimFixture) CreateWarmPod(namespace, name, pool string) *corev1.Pod
CreateWarmPod creates a running pool pod pointing to the fixture runtime.
func (*ModelClaimFixture) CreateWarmPodPending ¶
func (f *ModelClaimFixture) CreateWarmPodPending(namespace, name, pool string, gpuCount int64) *corev1.Pod
CreateWarmPodPending creates a pool pod without making it a runtime candidate. Tests can change the same object to Running with a Pod IP to exercise the controller's Pod update watch.
func (*ModelClaimFixture) ExpectEvent ¶
func (f *ModelClaimFixture) ExpectEvent(claim *modelapi.ModelClaim, eventType, reason string)
ExpectEvent waits for an event matching the claim UID, type, and reason.
func (*ModelClaimFixture) ExpectRoute ¶
func (f *ModelClaimFixture) ExpectRoute( g gomega.Gomega, namespace, podName, claimName string, port int32, state string, )
ExpectRoute checks the pod routing annotation for a claim's port and state.
func (*ModelClaimFixture) GetClaim ¶
func (f *ModelClaimFixture) GetClaim(g gomega.Gomega, claim *modelapi.ModelClaim) *modelapi.ModelClaim
GetClaim retrieves the latest claim using the supplied polling assertions.
func (*ModelClaimFixture) MarkWarmPodRunning ¶
func (f *ModelClaimFixture) MarkWarmPodRunning(pod *corev1.Pod)
MarkWarmPodRunning makes a previously-created pool pod eligible for model placement without replacing it.
func (*ModelClaimFixture) RequestWake ¶
func (f *ModelClaimFixture) RequestWake(namespace, podName, claimName string)
RequestWake writes a wake request for a claim on a pod, as the gateway does for a request that finds the claim's engine asleep.
func (*ModelClaimFixture) Runtime ¶
func (f *ModelClaimFixture) Runtime() *FakeModelClaimRuntime
Runtime returns the fake runtime used by this fixture.
func (*ModelClaimFixture) TriggerReconcile ¶
func (f *ModelClaimFixture) TriggerReconcile(claim *modelapi.ModelClaim)
TriggerReconcile updates a claim annotation to trigger reconciliation.