Documentation
¶
Index ¶
- Constants
- func AssertDecisionCount(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision, ...)
- func AssertDeletedHosts(t *testing.T, result decisionsv1alpha1.SchedulingDecisionResult, ...)
- func AssertDescriptionContains(t *testing.T, description string, expectedContents ...string)
- func AssertFinalScores(t *testing.T, result decisionsv1alpha1.SchedulingDecisionResult, ...)
- func AssertNoError(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision)
- func AssertResourceDeleted(t *testing.T, c client.Client, name string, namespace ...string)
- func AssertResourceError(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision, ...)
- func AssertResourceExists(t *testing.T, c client.Client, name string, namespace ...string) *decisionsv1alpha1.SchedulingDecision
- func AssertResourceState(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision, ...)
- func AssertResultCount(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision, ...)
- func CreateTestRequest(name string, namespace ...string) ctrl.Request
- func NewTestPipelineOutput(step string, activations map[string]float64) decisionsv1alpha1.SchedulingDecisionPipelineOutputSpec
- func SetupTestEnvironment(t *testing.T, resources ...client.Object) (client.Client, *runtime.Scheme)
- type Config
- type SchedulingDecisionReconciler
- type SchedulingDecisionTTLController
- type StepImpact
- type TTLStartupReconciler
- type TestDecisionBuilder
- func (b *TestDecisionBuilder) Build() decisionsv1alpha1.SchedulingDecisionRequest
- func (b *TestDecisionBuilder) WithEventType(eventType decisionsv1alpha1.SchedulingEventType) *TestDecisionBuilder
- func (b *TestDecisionBuilder) WithInput(input map[string]float64) *TestDecisionBuilder
- func (b *TestDecisionBuilder) WithPipelineOutputs(outputs ...decisionsv1alpha1.SchedulingDecisionPipelineOutputSpec) *TestDecisionBuilder
- func (b *TestDecisionBuilder) WithRequestedAt(t time.Time) *TestDecisionBuilder
- type TestSchedulingDecisionBuilder
- func (b *TestSchedulingDecisionBuilder) Build() *decisionsv1alpha1.SchedulingDecision
- func (b *TestSchedulingDecisionBuilder) WithCreationTimestamp(t time.Time) *TestSchedulingDecisionBuilder
- func (b *TestSchedulingDecisionBuilder) WithDecisions(decisions ...decisionsv1alpha1.SchedulingDecisionRequest) *TestSchedulingDecisionBuilder
- func (b *TestSchedulingDecisionBuilder) WithNamespace(namespace string) *TestSchedulingDecisionBuilder
Constants ¶
const ( DefaultTestTTL = 2 * time.Hour DefaultTestAge = 1 * time.Hour OldTestAge = 3 * time.Hour TestTolerance = 1 * time.Minute DefaultTestVCPUs = 1 DefaultTestRAM = 2048 DefaultTestDisk = 10 )
Test constants to reduce magic numbers
const (
DefaultTTLAfterDecisionSeconds = 24 * 60 * 60 // 24 hours in seconds
)
const (
MinScoreValue = -999999
)
Variables ¶
This section is empty.
Functions ¶
func AssertDecisionCount ¶
func AssertDecisionCount(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision, expectedCount int)
AssertDecisionCount checks the decision count in a SchedulingDecision
func AssertDeletedHosts ¶
func AssertDeletedHosts(t *testing.T, result decisionsv1alpha1.SchedulingDecisionResult, expectedDeletedHosts map[string][]string)
AssertDeletedHosts checks the deleted hosts in a result
func AssertDescriptionContains ¶
AssertDescriptionContains checks that a description contains expected text
func AssertFinalScores ¶
func AssertFinalScores(t *testing.T, result decisionsv1alpha1.SchedulingDecisionResult, expectedScores map[string]float64)
AssertFinalScores checks the final scores in a result
func AssertNoError ¶
func AssertNoError(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision)
AssertNoError checks that there's no error in the resource status
func AssertResourceDeleted ¶
AssertResourceDeleted checks that a resource has been deleted
func AssertResourceError ¶
func AssertResourceError(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision, expectedError string)
AssertResourceError checks the error message of a SchedulingDecision
func AssertResourceExists ¶
func AssertResourceExists(t *testing.T, c client.Client, name string, namespace ...string) *decisionsv1alpha1.SchedulingDecision
AssertResourceExists checks that a resource exists and returns it
func AssertResourceState ¶
func AssertResourceState(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision, expectedState decisionsv1alpha1.SchedulingDecisionState)
AssertResourceState checks the state of a SchedulingDecision
func AssertResultCount ¶
func AssertResultCount(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision, expectedCount int)
AssertResultCount checks the number of results in a SchedulingDecision
func CreateTestRequest ¶
CreateTestRequest creates a controller request for testing
func NewTestPipelineOutput ¶
func NewTestPipelineOutput(step string, activations map[string]float64) decisionsv1alpha1.SchedulingDecisionPipelineOutputSpec
NewTestPipelineOutput creates a pipeline output spec for testing
Types ¶
type Config ¶
type Config struct {
// TTL for scheduling decisions after the last decision's RequestedAt timestamp (in seconds)
TTLAfterDecisionSeconds int `json:"ttlAfterDecisionSeconds,omitempty"`
}
Configuration for the decisions operator.
type SchedulingDecisionReconciler ¶
type SchedulingDecisionReconciler struct {
// Client for the kubernetes API.
client.Client
// Kubernetes scheme to use for the decisions.
Scheme *runtime.Scheme
// Configuration for the controller.
Conf Config
}
SchedulingDecisionReconciler reconciles a SchedulingDecision object
func CreateSchedulingReconciler ¶
func CreateSchedulingReconciler(fakeClient client.Client, conf ...Config) *SchedulingDecisionReconciler
CreateSchedulingReconciler creates a scheduling decision reconciler If conf is empty, uses default empty config
func (*SchedulingDecisionReconciler) SetupWithManager ¶
func (r *SchedulingDecisionReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type SchedulingDecisionTTLController ¶
type SchedulingDecisionTTLController struct {
// Client for the kubernetes API.
client.Client
// Kubernetes scheme to use for the decisions.
Scheme *runtime.Scheme
// Configuration for the TTL controller.
Conf Config
}
SchedulingDecisionTTLController handles automatic cleanup of resolved SchedulingDecision resources after a configurable TTL period.
func CreateTTLReconciler ¶
func CreateTTLReconciler(fakeClient client.Client, scheme *runtime.Scheme, ttl time.Duration) *SchedulingDecisionTTLController
CreateTTLReconciler creates a TTL reconciler with the given TTL duration If ttlSeconds is 0, the reconciler will use its internal default
func (*SchedulingDecisionTTLController) SetupWithManager ¶
func (r *SchedulingDecisionTTLController) SetupWithManager(mgr ctrl.Manager) error
type StepImpact ¶
type StepImpact struct {
Step string
ScoreBefore float64
ScoreAfter float64
ScoreDelta float64
CompetitorsRemoved int
PromotedToFirst bool
}
StepImpact represents the impact of a single pipeline step on the winning host
type TTLStartupReconciler ¶
type TTLStartupReconciler struct {
// contains filtered or unexported fields
}
TTLStartupReconciler handles startup reconciliation for existing resources
type TestDecisionBuilder ¶
type TestDecisionBuilder struct {
// contains filtered or unexported fields
}
TestDecisionBuilder helps build SchedulingDecisionRequest objects for tests
func NewTestDecision ¶
func NewTestDecision(id string) *TestDecisionBuilder
func (*TestDecisionBuilder) Build ¶
func (b *TestDecisionBuilder) Build() decisionsv1alpha1.SchedulingDecisionRequest
Build returns the built SchedulingDecisionRequest
func (*TestDecisionBuilder) WithEventType ¶
func (b *TestDecisionBuilder) WithEventType(eventType decisionsv1alpha1.SchedulingEventType) *TestDecisionBuilder
WithEventType sets the event type
func (*TestDecisionBuilder) WithInput ¶
func (b *TestDecisionBuilder) WithInput(input map[string]float64) *TestDecisionBuilder
WithInput sets the input hosts and scores
func (*TestDecisionBuilder) WithPipelineOutputs ¶
func (b *TestDecisionBuilder) WithPipelineOutputs(outputs ...decisionsv1alpha1.SchedulingDecisionPipelineOutputSpec) *TestDecisionBuilder
WithPipelineOutputs sets the pipeline outputs
func (*TestDecisionBuilder) WithRequestedAt ¶
func (b *TestDecisionBuilder) WithRequestedAt(t time.Time) *TestDecisionBuilder
WithRequestedAt sets the RequestedAt timestamp
type TestSchedulingDecisionBuilder ¶
type TestSchedulingDecisionBuilder struct {
// contains filtered or unexported fields
}
TestSchedulingDecisionBuilder helps build SchedulingDecision objects for tests
func NewTestSchedulingDecision ¶
func NewTestSchedulingDecision(name string) *TestSchedulingDecisionBuilder
NewTestSchedulingDecision creates a new test SchedulingDecision builder
func (*TestSchedulingDecisionBuilder) Build ¶
func (b *TestSchedulingDecisionBuilder) Build() *decisionsv1alpha1.SchedulingDecision
Build returns the built SchedulingDecision
func (*TestSchedulingDecisionBuilder) WithCreationTimestamp ¶
func (b *TestSchedulingDecisionBuilder) WithCreationTimestamp(t time.Time) *TestSchedulingDecisionBuilder
WithCreationTimestamp sets the creation timestamp
func (*TestSchedulingDecisionBuilder) WithDecisions ¶
func (b *TestSchedulingDecisionBuilder) WithDecisions(decisions ...decisionsv1alpha1.SchedulingDecisionRequest) *TestSchedulingDecisionBuilder
WithDecisions adds decisions to the SchedulingDecision
func (*TestSchedulingDecisionBuilder) WithNamespace ¶
func (b *TestSchedulingDecisionBuilder) WithNamespace(namespace string) *TestSchedulingDecisionBuilder
WithNamespace sets the namespace