utils

package
v0.1.0-alpha.14-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TestAPIInternalErr is an API internal server error meant to be used to mimic HTTP response code 500 for tests.
	TestAPIInternalErr = apierrors.NewInternalError(errors.New("fake internal error"))
)

Functions

func AssertErrorMatches

func AssertErrorMatches(t *testing.T, errs field.ErrorList, expectedErrorMatchers []ErrorMatcher)

AssertErrorMatches asserts that the errs contained within field.ErrorList with all the passed `expectedErrorMatchers`.

func AssertGroveError

func AssertGroveError(t *testing.T, expectedError *groveerr.GroveError, actualErr error)

AssertGroveError checks that an actual error is a Grove error and further checks its underline cause, error code and operation.

func CreateDefaultFakeClient

func CreateDefaultFakeClient(existingObjects []client.Object) client.Client

CreateDefaultFakeClient creates a default client.Client without any configured reactions to errors.

func CreateFakeClientForObjects

func CreateFakeClientForObjects(getErr, createErr, patchErr, deleteErr *apierrors.StatusError, existingObjects []client.Object)

CreateFakeClientForObjects creates a fake client.Client with initial set of existing objects along with any expected errors for the Get, Create, Patch, and Delete client methods.

func CreateFakeClientForObjectsMatchingLabels

func CreateFakeClientForObjectsMatchingLabels(deleteErr, listErr *apierrors.StatusError, namespace string, targetObjectsGVK schema.GroupVersionKind, matchingLabels map[string]string, existingObjects ...client.Object) client.Client

CreateFakeClientForObjectsMatchingLabels creates a fake client.Client with initial set of existing objects along with any expected list and/or deleteAll errors for objects matching the given matching labels for the given GVK. If the matchingLabels is nil or empty then the deleteAll/list error will be recorded for all objects matching the GVK in the given namespace.

func EntryByRole

EntryByRole returns the first entry with the given role, or a zero entry when none matches.

func NewAnchorEntry

func NewAnchorEntry(pcsGenerationHash, epoch string, anchorIndex int32, pcsgName string, pcsgReplicaIndices ...int32) grovecorev1alpha1.PodGangEntry

NewAnchorEntry builds an Anchor PodGangEntry carrying a single PodCliqueScalingGroup's replica indices. anchorIndex is the anchor's index within its generation hash. Use the builder directly when an entry also needs DependsOn or standalone PodCliques.

func NewBasicPodCliqueTemplateSpec

func NewBasicPodCliqueTemplateSpec(name string) *grovecorev1alpha1.PodCliqueTemplateSpec

NewBasicPodCliqueTemplateSpec creates a basic PodClique template without topology constraints. This is a convenience function for tests that need a simple PodClique with default configuration.

func NewContainer

func NewContainer(name, image string, command ...string) corev1.Container

NewContainer creates a simple container without GPU resources. Optional command overrides the image entrypoint (e.g. "sleep", "infinity" for a long-running placeholder).

func NewFakeSchedulerBackend

func NewFakeSchedulerBackend(name string) scheduler.Backend

NewFakeSchedulerBackend creates a new instance of FakeSchedulerBackend.

func NewGPUContainer

func NewGPUContainer(name, image string, gpuCount int64, command ...string) corev1.Container

NewGPUContainer creates a container with GPU resources. Optional command overrides the image entrypoint (e.g. "sleep", "infinity" for a long-running placeholder).

func NewScaleOutEntry

func NewScaleOutEntry(pcsGenerationHash, epoch, pcsgName string, pcsgReplicaIndices ...int32) grovecorev1alpha1.PodGangEntry

NewScaleOutEntry builds a ScaleOut PodGangEntry carrying a single PodCliqueScalingGroup's replica indices.

func NewTailEntry

func NewTailEntry(pcsGenerationHash, epoch, pcsgName string, pcsgReplicaIndices ...int32) grovecorev1alpha1.PodGangEntry

NewTailEntry builds a Tail PodGangEntry carrying a single PodCliqueScalingGroup's replica indices.

func NewVolcanoPodGroupCRD

func NewVolcanoPodGroupCRD(includeSubGroupPolicy bool) *apiextensionsv1.CustomResourceDefinition

NewVolcanoPodGroupCRD returns a minimal Volcano PodGroup CRD for tests.

func RolesOf

RolesOf returns the role of each entry in order.

func SetupFakeClient

func SetupFakeClient(objects ...client.Object) client.WithWatch

SetupFakeClient creates a fake Kubernetes client with Grove CRDs and status subresources.

Types

type ClientMethod

type ClientMethod string

ClientMethod is a name of the method on client.Client for which an error is recorded.

const (
	// ClientMethodGet is the name of the Get method on client.Client.
	ClientMethodGet ClientMethod = "Get"
	// ClientMethodList is the name of the List method on client.Client.
	ClientMethodList ClientMethod = "List"
	// ClientMethodCreate is the name of the Create method on client.Client.
	ClientMethodCreate ClientMethod = "Create"
	// ClientMethodDelete is the name of the Delete method on client.Client.
	ClientMethodDelete ClientMethod = "Delete"
	// ClientMethodDeleteAll is the name of the DeleteAllOf method on client.Client.
	ClientMethodDeleteAll ClientMethod = "DeleteAll"
	// ClientMethodPatch is the name of the Patch method on client.Client.
	ClientMethodPatch ClientMethod = "Patch"
	// ClientMethodUpdate is the name of the Update method on client.Client.
	ClientMethodUpdate ClientMethod = "Update"
	// ClientMethodStatusPatch is the name of the Patch method on the status subresource writer.
	ClientMethodStatusPatch ClientMethod = "StatusPatch"
	// ClientMethodStatusUpdate is the name of the Update method on the status subresource writer.
	ClientMethodStatusUpdate ClientMethod = "StatusUpdate"
)

type ErrorMatcher

type ErrorMatcher struct {
	// Field is the value of the value of field.Error.Field.
	Field string
	// ErrorType is the value of field.Error.Type to be compared.
	ErrorType field.ErrorType
}

ErrorMatcher matches the errors contained within field.ErrorList

func (ErrorMatcher) Matches

func (m ErrorMatcher) Matches(errs field.ErrorList) bool

Matches matches the errorType to the passed field.ErrorList

type FakeManager

type FakeManager struct {
	manager.Manager
	Client        client.Client
	Scheme        *runtime.Scheme
	Logger        logr.Logger
	WebhookServer webhook.Server
}

FakeManager is a fake controller-runtime manager

func (*FakeManager) GetClient

func (f *FakeManager) GetClient() client.Client

GetClient returns the client registered with the fake manager

func (*FakeManager) GetLogger

func (f *FakeManager) GetLogger() logr.Logger

GetLogger returns the logger registered with the fake manager

func (FakeManager) GetScheme

func (f FakeManager) GetScheme() *runtime.Scheme

GetScheme returns the scheme registered with the fake manager

func (*FakeManager) GetWebhookServer

func (f *FakeManager) GetWebhookServer() webhook.Server

GetWebhookServer returns the webhook server registered with the fake manager

type FakeSchedulerBackend

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

FakeSchedulerBackend is a minimal scheduler.Backend implementation for unit tests.

func (*FakeSchedulerBackend) Init

Init is a no-op for the fake backend.

func (*FakeSchedulerBackend) Name

func (s *FakeSchedulerBackend) Name() string

Name returns the backend name.

func (*FakeSchedulerBackend) PreparePod

func (s *FakeSchedulerBackend) PreparePod(_ *corev1.Pod) error

PreparePod is a no-op for the fake backend.

func (*FakeSchedulerBackend) SyncPodGang

SyncPodGang is a no-op for the fake backend.

func (*FakeSchedulerBackend) ValidatePodCliqueSet

ValidatePodCliqueSet is a no-op for the fake backend.

type FakeSchedulerRegistry

type FakeSchedulerRegistry struct {
	Backends       map[string]scheduler.Backend
	DefaultBackend string
}

FakeSchedulerRegistry is a test helper implementing scheduler.Registry. Set backends and defaultBackend fields directly for the desired test scenario.

func NewDefaultFakeRegistry

func NewDefaultFakeRegistry() *FakeSchedulerRegistry

NewDefaultFakeRegistry returns a FakeSchedulerRegistry pre-configured with the default kube scheduler backend.

func (*FakeSchedulerRegistry) All

All returns all registered scheduler backends keyed by name.

func (*FakeSchedulerRegistry) AllTopologyAware

func (r *FakeSchedulerRegistry) AllTopologyAware() map[string]scheduler.TopologyAwareBackend

AllTopologyAware returns the subset of registered backends that implement TopologyAwareBackend, keyed by name.

func (*FakeSchedulerRegistry) Get

Get returns the backend registered under name, or nil if not found.

func (*FakeSchedulerRegistry) GetDefault

func (r *FakeSchedulerRegistry) GetDefault() scheduler.Backend

GetDefault returns the default backend.

func (*FakeSchedulerRegistry) GetOrDefault

func (r *FakeSchedulerRegistry) GetOrDefault(name string) scheduler.Backend

GetOrDefault returns the backend registered under name, or the default backend if name is empty.

type FakeTopologyAwareBackend

type FakeTopologyAwareBackend struct {
	FakeSchedulerBackend
}

FakeTopologyAwareBackend extends FakeSchedulerBackend with a no-op TopologyAwareBackend implementation.

func NewFakeTopologyAwareBackend

func NewFakeTopologyAwareBackend(name string) *FakeTopologyAwareBackend

NewFakeTopologyAwareBackend creates a FakeSchedulerBackend that also satisfies scheduler.TopologyAwareBackend.

func (*FakeTopologyAwareBackend) CheckTopologyDrift

CheckTopologyDrift is a no-op for the fake topology-aware backend.

func (*FakeTopologyAwareBackend) OnTopologyDelete

OnTopologyDelete is a no-op for the fake topology-aware backend.

func (*FakeTopologyAwareBackend) SyncTopology

SyncTopology is a no-op for the fake topology-aware backend.

func (*FakeTopologyAwareBackend) TopologyGVR

TopologyGVR returns a zero-value GVR for the fake topology-aware backend.

func (*FakeTopologyAwareBackend) TopologyResourceName

TopologyResourceName returns an empty string for the fake topology-aware backend.

type PCLQOption

type PCLQOption func(*grovecorev1alpha1.PodClique)

PCLQOption is a function that modifies a PodClique for testing.

func WithPCLQAvailable

func WithPCLQAvailable() PCLQOption

WithPCLQAvailable sets the PodClique to a healthy state with MinAvailableBreached=False and PodCliqueScheduled=True.

func WithPCLQCurrentPCSGenerationHash

func WithPCLQCurrentPCSGenerationHash(pcsGenerationHash string) PCLQOption

WithPCLQCurrentPCSGenerationHash sets the CurrentPodCliqueSetGenerationHash in the PodClique status.

func WithPCLQMinAvailableBreached

func WithPCLQMinAvailableBreached() PCLQOption

WithPCLQMinAvailableBreached sets the PodClique to have MinAvailableBreached=True but scheduled.

func WithPCLQNoConditions

func WithPCLQNoConditions() PCLQOption

WithPCLQNoConditions removes all conditions from the PodClique status.

func WithPCLQNotScheduled

func WithPCLQNotScheduled() PCLQOption

WithPCLQNotScheduled sets the PodClique to be not scheduled. A PodClique that is not scheduled also has scheduledReplicas < minAvailable, so under the always-breach rule the MinAvailableBreached condition is True as well — this helper sets both.

func WithPCLQReplicaReadyStatus

func WithPCLQReplicaReadyStatus(ready int32) PCLQOption

WithPCLQReplicaReadyStatus sets specific ReadyReplicas count for PodClique without touching conditions.

func WithPCLQScheduledAndAvailable

func WithPCLQScheduledAndAvailable() PCLQOption

WithPCLQScheduledAndAvailable sets the PodClique to be both scheduled and available.

func WithPCLQScheduledButBreached

func WithPCLQScheduledButBreached() PCLQOption

WithPCLQScheduledButBreached sets the PodClique to be scheduled but with breached availability.

func WithPCLQTerminating

func WithPCLQTerminating() PCLQOption

WithPCLQTerminating marks the PodClique for termination with a DeletionTimestamp.

type PCSGOption

type PCSGOption func(*grovecorev1alpha1.PodCliqueScalingGroup)

PCSGOption is a function that modifies a PodCliqueScalingGroup for testing.

func WithPCSGAvailableReplicas

func WithPCSGAvailableReplicas(available int32) PCSGOption

WithPCSGAvailableReplicas sets specific AvailableReplicas count for PCSG without touching conditions.

func WithPCSGCurrentPCSGenerationHash

func WithPCSGCurrentPCSGenerationHash(pcsGenerationHash string) PCSGOption

WithPCSGCurrentPCSGenerationHash sets the CurrentPodCliqueSetGenerationHash in the PCSG status.

func WithPCSGMinAvailableBreached

func WithPCSGMinAvailableBreached() PCSGOption

WithPCSGMinAvailableBreached sets the PCSG to have MinAvailableBreached=True.

func WithPCSGObservedGeneration

func WithPCSGObservedGeneration(generation int64) PCSGOption

WithPCSGObservedGeneration sets the PCSG ObservedGeneration to enable status mutations.

func WithPCSGUnknownCondition

func WithPCSGUnknownCondition() PCSGOption

WithPCSGUnknownCondition sets the PCSG to have MinAvailableBreached=Unknown.

type PCSOption

type PCSOption func(*grovecorev1alpha1.PodCliqueSet)

PCSOption is a function that modifies a PodCliqueSet for testing.

type PodBuilder

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

PodBuilder is a builder for Pod objects.

func NewPodBuilder

func NewPodBuilder(name, namespace string) *PodBuilder

NewPodBuilder creates a new PodBuilder with the given name and namespace.

func NewPodWithBuilderWithDefaultSpec

func NewPodWithBuilderWithDefaultSpec(name, namespace string) *PodBuilder

NewPodWithBuilderWithDefaultSpec creates a new PodBuilder with a default spec.

func (*PodBuilder) Build

func (b *PodBuilder) Build() *corev1.Pod

Build builds and returns the Pod.

func (*PodBuilder) MarkForTermination

func (b *PodBuilder) MarkForTermination() *PodBuilder

MarkForTermination sets the DeletionTimestamp on the Pod.

func (*PodBuilder) WithCondition

func (b *PodBuilder) WithCondition(cond corev1.PodCondition) *PodBuilder

WithCondition adds a condition to the Pod's status.

func (*PodBuilder) WithLabels

func (b *PodBuilder) WithLabels(labels map[string]string) *PodBuilder

WithLabels adds labels to the Pod.

func (*PodBuilder) WithOwner

func (b *PodBuilder) WithOwner(ownerName string) *PodBuilder

WithOwner adds an owner reference to the Pod.

func (*PodBuilder) WithPhase

func (b *PodBuilder) WithPhase(phase corev1.PodPhase) *PodBuilder

WithPhase adds a pod phase to the Pod's status.

func (*PodBuilder) WithSchedulerName

func (b *PodBuilder) WithSchedulerName(name string) *PodBuilder

WithSchedulerName sets the scheduler name on the Pod spec.

func (*PodBuilder) WithSchedulingGate

func (b *PodBuilder) WithSchedulingGate(name string) *PodBuilder

WithSchedulingGate adds a scheduling gate with the given name to the Pod.

type PodCliqueBuilder

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

PodCliqueBuilder is a builder for creating PodClique objects. This should primarily be used for tests.

func NewPCSGPodCliqueBuilder

func NewPCSGPodCliqueBuilder(name, namespace, pcsName, pcsgName string, pcsReplicaIndex, pcsgReplicaIndex int) *PodCliqueBuilder

NewPCSGPodCliqueBuilder creates a PodClique that belongs to a PodCliqueScalingGroup.

func NewPodCliqueBuilder

func NewPodCliqueBuilder(pcsName string, pcsUID types.UID, pclqTemplateName, namespace string, pcsReplicaIndex int32) *PodCliqueBuilder

NewPodCliqueBuilder creates a new PodCliqueBuilder.

func (*PodCliqueBuilder) Build

Build creates a PodClique object.

func (*PodCliqueBuilder) WithAutoScaleMaxReplicas

func (b *PodCliqueBuilder) WithAutoScaleMaxReplicas(maximum int32) *PodCliqueBuilder

WithAutoScaleMaxReplicas sets the maximum replicas in ScaleConfig for the PodClique.

func (*PodCliqueBuilder) WithLabels

func (b *PodCliqueBuilder) WithLabels(labels map[string]string) *PodCliqueBuilder

WithLabels merges the passed labels with default labels. Passed in labels will overwrite default labels with the same keys.

func (*PodCliqueBuilder) WithMinAvailable

func (b *PodCliqueBuilder) WithMinAvailable(minAvailable int32) *PodCliqueBuilder

WithMinAvailable sets the MinAvailable for the PodClique.

func (*PodCliqueBuilder) WithOptions

func (b *PodCliqueBuilder) WithOptions(opts ...PCLQOption) *PodCliqueBuilder

WithOptions applies option functions to customize the PodClique.

func (*PodCliqueBuilder) WithOwnerReference

func (b *PodCliqueBuilder) WithOwnerReference(kind, name string, uid types.UID) *PodCliqueBuilder

WithOwnerReference sets a controller owner reference for the PodClique from individual values.

func (*PodCliqueBuilder) WithReplicas

func (b *PodCliqueBuilder) WithReplicas(replicas int32) *PodCliqueBuilder

WithReplicas sets the number of replicas for the PodClique. Default is set to 1.

func (*PodCliqueBuilder) WithStartsAfter

func (b *PodCliqueBuilder) WithStartsAfter(pclqTemplateNames []string) *PodCliqueBuilder

WithStartsAfter sets the StartsAfter field for the PodClique.

type PodCliqueScalingGroupBuilder

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

PodCliqueScalingGroupBuilder provides a fluent interface for building test PodCliqueScalingGroup objects.

func NewPodCliqueScalingGroupBuilder

func NewPodCliqueScalingGroupBuilder(name, namespace, pcsName string, pcsReplicaIndex int) *PodCliqueScalingGroupBuilder

NewPodCliqueScalingGroupBuilder creates a new PodCliqueScalingGroupBuilder with basic configuration.

func (*PodCliqueScalingGroupBuilder) Build

Build returns the constructed PodCliqueScalingGroup.

func (*PodCliqueScalingGroupBuilder) WithCliqueNames

func (b *PodCliqueScalingGroupBuilder) WithCliqueNames(cliqueNames []string) *PodCliqueScalingGroupBuilder

WithCliqueNames sets the CliqueNames field for the PodCliqueScalingGroup.

func (*PodCliqueScalingGroupBuilder) WithLabels

WithLabels adds labels to the PodCliqueScalingGroup.

func (*PodCliqueScalingGroupBuilder) WithMinAvailable

func (b *PodCliqueScalingGroupBuilder) WithMinAvailable(minAvailable int32) *PodCliqueScalingGroupBuilder

WithMinAvailable sets the MinAvailable field for the PodCliqueScalingGroup.

func (*PodCliqueScalingGroupBuilder) WithOptions

WithOptions applies option functions to customize the PodCliqueScalingGroup.

func (*PodCliqueScalingGroupBuilder) WithOwnerReference

func (b *PodCliqueScalingGroupBuilder) WithOwnerReference(kind, name string, uid types.UID) *PodCliqueScalingGroupBuilder

WithOwnerReference sets a controller owner reference on the PodCliqueScalingGroup.

func (*PodCliqueScalingGroupBuilder) WithReplicas

WithReplicas sets the number of replicas for the PodCliqueScalingGroup.

type PodCliqueSetBuilder

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

PodCliqueSetBuilder is a builder for PodCliqueSet objects.

func NewPodCliqueSetBuilder

func NewPodCliqueSetBuilder(name, namespace string, uid types.UID) *PodCliqueSetBuilder

NewPodCliqueSetBuilder creates a new PodCliqueSetBuilder.

func (*PodCliqueSetBuilder) Build

Build creates a PodCliqueSet object.

func (*PodCliqueSetBuilder) WithAnnotations

func (b *PodCliqueSetBuilder) WithAnnotations(annotations map[string]string) *PodCliqueSetBuilder

WithAnnotations sets the annotations for the PodCliqueSet.

func (*PodCliqueSetBuilder) WithCliqueStartupType

func (b *PodCliqueSetBuilder) WithCliqueStartupType(startupType *grovecorev1alpha1.CliqueStartupType) *PodCliqueSetBuilder

WithCliqueStartupType sets the StartupType for the PodCliqueSet.

func (*PodCliqueSetBuilder) WithLabels

func (b *PodCliqueSetBuilder) WithLabels(labels map[string]string) *PodCliqueSetBuilder

WithLabels sets the labels for the PodCliqueSet.

func (*PodCliqueSetBuilder) WithPodCliqueParameters

func (b *PodCliqueSetBuilder) WithPodCliqueParameters(name string, replicas int32, startsAfter []string) *PodCliqueSetBuilder

WithPodCliqueParameters is a convenience function that creates a PodCliqueTemplateSpec given the parameters and adds it to the PodCliqueSet.

func (*PodCliqueSetBuilder) WithPodCliqueScalingGroupConfig

func (b *PodCliqueSetBuilder) WithPodCliqueScalingGroupConfig(config grovecorev1alpha1.PodCliqueScalingGroupConfig) *PodCliqueSetBuilder

WithPodCliqueScalingGroupConfig adds a PodCliqueScalingGroupConfig to the PodCliqueSet.

func (*PodCliqueSetBuilder) WithPodCliqueSetGenerationHash

func (b *PodCliqueSetBuilder) WithPodCliqueSetGenerationHash(pcsGenerationHash *string) *PodCliqueSetBuilder

WithPodCliqueSetGenerationHash sets the CurrentGenerationHash in the PodCliqueSet status.

func (*PodCliqueSetBuilder) WithPodCliqueTemplateSpec

WithPodCliqueTemplateSpec sets the PodCliqueTemplateSpec for the PodCliqueSet. Consumers can use PodCliqueBuilder to create a PodCliqueTemplateSpec and then use this method to add it to the PodCliqueSet.

func (*PodCliqueSetBuilder) WithPriorityClassName

func (b *PodCliqueSetBuilder) WithPriorityClassName(priorityClassName string) *PodCliqueSetBuilder

WithPriorityClassName sets the PriorityClassName for the PodCliqueSet.

func (*PodCliqueSetBuilder) WithReplicas

func (b *PodCliqueSetBuilder) WithReplicas(replicas int32) *PodCliqueSetBuilder

WithReplicas sets the number of replicas for the PodCliqueSet.

func (*PodCliqueSetBuilder) WithScalingGroup

func (b *PodCliqueSetBuilder) WithScalingGroup(name string, cliqueNames []string) *PodCliqueSetBuilder

WithScalingGroup adds a scaling group with the specified cliques.

func (*PodCliqueSetBuilder) WithScalingGroupConfig

func (b *PodCliqueSetBuilder) WithScalingGroupConfig(name string, cliqueNames []string, replicas, minAvailable int32) *PodCliqueSetBuilder

WithScalingGroupConfig adds a scaling group with custom replicas and minAvailable.

func (*PodCliqueSetBuilder) WithStandaloneClique

func (b *PodCliqueSetBuilder) WithStandaloneClique(name string) *PodCliqueSetBuilder

WithStandaloneClique adds a standalone clique (not part of any scaling group).

func (*PodCliqueSetBuilder) WithStandaloneCliqueReplicas

func (b *PodCliqueSetBuilder) WithStandaloneCliqueReplicas(name string, replicas int32) *PodCliqueSetBuilder

WithStandaloneCliqueReplicas adds a standalone clique with specific replica count.

func (*PodCliqueSetBuilder) WithStatusConditions

func (b *PodCliqueSetBuilder) WithStatusConditions(conditions ...metav1.Condition) *PodCliqueSetBuilder

WithStatusConditions sets the status conditions on the PodCliqueSet.

func (*PodCliqueSetBuilder) WithTerminationDelay

func (b *PodCliqueSetBuilder) WithTerminationDelay(duration time.Duration) *PodCliqueSetBuilder

WithTerminationDelay sets the TerminationDelay for the PodCliqueSet.

func (*PodCliqueSetBuilder) WithTopologyConstraint

func (b *PodCliqueSetBuilder) WithTopologyConstraint(constraint *grovecorev1alpha1.TopologyConstraint) *PodCliqueSetBuilder

WithTopologyConstraint sets the TopologyConstraint for the PodCliqueSet template.

func (*PodCliqueSetBuilder) WithUpdateProgress

WithUpdateProgress sets the UpdateProgress in the PodCliqueSet status.

func (*PodCliqueSetBuilder) WithUpdateStrategy

WithUpdateStrategy sets the UpdateStrategy for the PodCliqueSet.

type PodCliqueTemplateSpecBuilder

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

PodCliqueTemplateSpecBuilder is a builder for creating PodCliqueTemplateSpec objects.

func NewPodCliqueTemplateSpecBuilder

func NewPodCliqueTemplateSpecBuilder(name string) *PodCliqueTemplateSpecBuilder

NewPodCliqueTemplateSpecBuilder creates a new PodCliqueTemplateSpecBuilder.

func (*PodCliqueTemplateSpecBuilder) Build

Build creates a PodCliqueTemplateSpec object.

func (*PodCliqueTemplateSpecBuilder) WithAnnotations

func (b *PodCliqueTemplateSpecBuilder) WithAnnotations(annotations map[string]string) *PodCliqueTemplateSpecBuilder

WithAnnotations sets the annotations for the PodCliqueTemplateSpec.

func (*PodCliqueTemplateSpecBuilder) WithAutoScaleMaxReplicas

func (b *PodCliqueTemplateSpecBuilder) WithAutoScaleMaxReplicas(maximum int32) *PodCliqueTemplateSpecBuilder

WithAutoScaleMaxReplicas sets the maximum replicas in ScaleConfig for the PodClique.

func (*PodCliqueTemplateSpecBuilder) WithAutoScaleMinReplicas

func (b *PodCliqueTemplateSpecBuilder) WithAutoScaleMinReplicas(minimum int32) *PodCliqueTemplateSpecBuilder

WithAutoScaleMinReplicas sets the minimum replicas in ScaleConfig for the PodClique.

func (*PodCliqueTemplateSpecBuilder) WithContainer

WithContainer adds a container to the PodSpec.

func (*PodCliqueTemplateSpecBuilder) WithInitContainer

WithInitContainer adds an init container to the PodSpec.

func (*PodCliqueTemplateSpecBuilder) WithLabels

WithLabels sets the labels for the PodCliqueTemplateSpec.

func (*PodCliqueTemplateSpecBuilder) WithMaxUnavailable

func (b *PodCliqueTemplateSpecBuilder) WithMaxUnavailable(maxUnavailable int32) *PodCliqueTemplateSpecBuilder

WithMaxUnavailable sets the RollingUpdate MaxUnavailable for the PodCliqueTemplateSpec.

func (*PodCliqueTemplateSpecBuilder) WithMinAvailable

func (b *PodCliqueTemplateSpecBuilder) WithMinAvailable(minAvailable int32) *PodCliqueTemplateSpecBuilder

WithMinAvailable sets the MinAvailable field for the PodCliqueTemplateSpec.

func (*PodCliqueTemplateSpecBuilder) WithPodSpec

WithPodSpec sets a custom PodSpec for the PodCliqueTemplateSpec.

func (*PodCliqueTemplateSpecBuilder) WithReplicas

WithReplicas sets the number of replicas for the PodCliqueTemplateSpec.

func (*PodCliqueTemplateSpecBuilder) WithRoleName

WithRoleName sets the RoleName for the PodCliqueTemplateSpec.

func (*PodCliqueTemplateSpecBuilder) WithScaleConfig

func (b *PodCliqueTemplateSpecBuilder) WithScaleConfig(minReplicas *int32, maxReplicas int32) *PodCliqueTemplateSpecBuilder

WithScaleConfig sets the complete ScaleConfig for the PodCliqueTemplateSpec.

func (*PodCliqueTemplateSpecBuilder) WithStartsAfter

func (b *PodCliqueTemplateSpecBuilder) WithStartsAfter(startsAfter []string) *PodCliqueTemplateSpecBuilder

WithStartsAfter sets the StartsAfter field for the PodCliqueTemplateSpec.

func (*PodCliqueTemplateSpecBuilder) WithTopologyConstraint

WithTopologyConstraint sets the TopologyConstraint for the PodCliqueTemplateSpec.

type PodGangBuilder

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

PodGangBuilder is a builder for PodGang objects (scheduler API).

func NewPodGangBuilder

func NewPodGangBuilder(name, namespace string) *PodGangBuilder

NewPodGangBuilder creates a new PodGangBuilder.

func (*PodGangBuilder) Build

Build returns the PodGang.

func (*PodGangBuilder) WithDeletionTimestamp

func (b *PodGangBuilder) WithDeletionTimestamp() *PodGangBuilder

WithDeletionTimestamp sets the DeletionTimestamp on the PodGang to simulate a pending deletion.

func (*PodGangBuilder) WithGeneration

func (b *PodGangBuilder) WithGeneration(generation int64) *PodGangBuilder

WithGeneration sets the Generation on the PodGang.

func (*PodGangBuilder) WithLabels

func (b *PodGangBuilder) WithLabels(labels map[string]string) *PodGangBuilder

WithLabels merges the given labels onto the PodGang.

func (*PodGangBuilder) WithLastScheduled

func (b *PodGangBuilder) WithLastScheduled() *PodGangBuilder

WithLastScheduled sets Status.LastScheduled to mark the PodGang as having been scheduled at least once.

func (*PodGangBuilder) WithManaged

func (b *PodGangBuilder) WithManaged(managed bool) *PodGangBuilder

WithManaged sets the managed-by label so the PodGang is considered operator-managed.

func (*PodGangBuilder) WithOwnerReference

func (b *PodGangBuilder) WithOwnerReference(kind, name string, uid types.UID) *PodGangBuilder

WithOwnerReference sets a controller owner reference of the given kind, name and uid on the PodGang. It lets a test model a PodGang owned by a specific controller instance, so ownership by UID (not just name) can be exercised.

func (*PodGangBuilder) WithPodGroup

func (b *PodGangBuilder) WithPodGroup(name string, minReplicas int32) *PodGangBuilder

WithPodGroup adds a single PodGroup (convenience for tests that need one group).

func (*PodGangBuilder) WithPodGroupPods

func (b *PodGangBuilder) WithPodGroupPods(name string, podNames ...string) *PodGangBuilder

WithPodGroupPods adds a PodGroup named name whose PodReferences list the given pods, all in the PodGang's namespace.

func (*PodGangBuilder) WithPodGroups

func (b *PodGangBuilder) WithPodGroups(groups []groveschedulerv1alpha1.PodGroup) *PodGangBuilder

WithPodGroups sets the Spec.PodGroups slice.

func (*PodGangBuilder) WithSchedulerName

func (b *PodGangBuilder) WithSchedulerName(name string) *PodGangBuilder

WithSchedulerName sets the grove.io/scheduler-name label on the PodGang.

type PodGangEntryBuilder

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

PodGangEntryBuilder provides a fluent interface for building test PodGangEntry values.

func NewPodGangEntryBuilder

func NewPodGangEntryBuilder(pcsGenerationHash, epoch string) *PodGangEntryBuilder

NewPodGangEntryBuilder creates a PodGangEntryBuilder for an entry with the given generation hash and epoch. Epoch is the entry's identity.

func (*PodGangEntryBuilder) Build

Build returns the constructed PodGangEntry.

func (*PodGangEntryBuilder) WithAnchorIndex

func (b *PodGangEntryBuilder) WithAnchorIndex(anchorIndex int32) *PodGangEntryBuilder

WithAnchorIndex sets the AnchorIndex on the entry. Set this on Anchor entries.

func (*PodGangEntryBuilder) WithDependsOn

func (b *PodGangEntryBuilder) WithDependsOn(epochs ...string) *PodGangEntryBuilder

WithDependsOn sets the epochs this entry depends on.

func (*PodGangEntryBuilder) WithPCSGReplicaIndices

func (b *PodGangEntryBuilder) WithPCSGReplicaIndices(indices map[string][]int32) *PodGangEntryBuilder

WithPCSGReplicaIndices sets the PodCliqueScalingGroup replica indices on the entry.

func (*PodGangEntryBuilder) WithPodCliques

func (b *PodGangEntryBuilder) WithPodCliques(podCliques map[string]int32) *PodGangEntryBuilder

WithPodCliques sets the standalone PodClique pod counts on the entry.

func (*PodGangEntryBuilder) WithRole

WithRole sets the Role on the entry.

type PodGangMapBuilder

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

PodGangMapBuilder provides a fluent interface for building test PodGangMap objects.

func NewPodGangMapBuilder

func NewPodGangMapBuilder(pcsName, namespace string, pcsUID types.UID, replicaIndex int) *PodGangMapBuilder

NewPodGangMapBuilder creates a builder for the PodGangMap of a PodCliqueSet replica. The map is named <pcsName>-<replicaIndex>, carries the labels the PodGangMap component selects on, and is owned by the PodCliqueSet (controller reference), matching what the reconciler creates.

func (*PodGangMapBuilder) Build

Build returns the constructed PodGangMap.

func (*PodGangMapBuilder) WithEntries

WithEntries sets the Spec.Entries on the PodGangMap.

type TestClientBuilder

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

TestClientBuilder is a builder for creating a test client.Client which is capable of recording and replaying errors.

func NewTestClientBuilder

func NewTestClientBuilder() *TestClientBuilder

NewTestClientBuilder creates a new TestClientBuilder with a default scheme. Tests that use scheduler-specific types must provide a scheme containing those types with WithScheme.

func (*TestClientBuilder) Build

func (b *TestClientBuilder) Build() client.Client

Build creates a test client.Client with the configured reactions to errors.

func (*TestClientBuilder) RecordErrorForObjects

func (b *TestClientBuilder) RecordErrorForObjects(method ClientMethod, err *apierrors.StatusError, objectKeys ...client.ObjectKey) *TestClientBuilder

RecordErrorForObjects records an error for a specific client.Client method and object keys.

func (*TestClientBuilder) RecordErrorForObjectsMatchingLabels

func (b *TestClientBuilder) RecordErrorForObjectsMatchingLabels(method ClientMethod, objectKey client.ObjectKey, targetObjectsGVK schema.GroupVersionKind, matchingLabels map[string]string, err *apierrors.StatusError) *TestClientBuilder

RecordErrorForObjectsMatchingLabels records an error for a specific client.Client method and object keys matching the given labels for a given GVK.

func (*TestClientBuilder) RecordErrorForObjectsNTimes

func (b *TestClientBuilder) RecordErrorForObjectsNTimes(method ClientMethod, err *apierrors.StatusError, consecutiveFailures int, objectKeys ...client.ObjectKey) *TestClientBuilder

RecordErrorForObjectsNTimes records an error that is returned for the first consecutiveFailures matching calls of the given method on the given object keys. Every call after that succeeds and delegates to the underlying client. A consecutiveFailures less than or equal to zero records nothing.

func (*TestClientBuilder) WithClient

func (b *TestClientBuilder) WithClient(cl client.Client) *TestClientBuilder

WithClient sets the delegating client for the TestClientBuilder.

func (*TestClientBuilder) WithIndex

func (b *TestClientBuilder) WithIndex(obj client.Object, field string, extractValue client.IndexerFunc) *TestClientBuilder

WithIndex registers a field index on the delegating fake client so that List calls using a field selector on that field are served.

func (*TestClientBuilder) WithObjects

func (b *TestClientBuilder) WithObjects(objects ...client.Object) *TestClientBuilder

WithObjects initializes the delegating fake client builder with objects.

func (*TestClientBuilder) WithScheme

func (b *TestClientBuilder) WithScheme(scheme *runtime.Scheme) *TestClientBuilder

WithScheme sets the scheme used by the delegating fake client.

func (*TestClientBuilder) WithStatusSubresource

func (b *TestClientBuilder) WithStatusSubresource(objs ...client.Object) *TestClientBuilder

WithStatusSubresource registers types that have status subresources so that Status().Patch() works with the fake client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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