testutils

package
v0.0.0-...-633c2b7 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperatorReadyTime     = 3 * time.Minute
	OperatorPoll          = 10 * time.Second
	OperatorNamespace     = "openshift-kueue-operator"
	OpenShiftManagedLabel = "kueue.openshift.io/managed"
	QueueLabel            = "kueue.x-k8s.io/queue-name"
	DefaultLocalQueueName = "default"
	DeletionTime          = 3 * time.Minute
	DeletionPoll          = 5 * time.Second
	ConsistentlyTimeout   = 5 * time.Second
	ConsistentlyPoll      = 1 * time.Second
)

Variables

This section is empty.

Functions

func AddLabelAndPatch

func AddLabelAndPatch(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, resourceName, resourceType string) error

func CleanUpJob

func CleanUpJob(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, name string)

CleanUpJob deletes the specified Job in the given namespace.

func CleanUpKueueInstance

func CleanUpKueueInstance(ctx context.Context, kueueClientset *kueueclient.Clientset, name string, kubeClient *kubernetes.Clientset)

CleanUpKueueInstance deletes the specified Kueue instance and waits for its removal. It also waits for webhook endpointslices to be completely gone if kubeClient is provided.

func CleanUpObject

func CleanUpObject(ctx context.Context, kubeClient client.Client, obj client.Object)

CleanUpObject deletes the specified kubernetes object and waits for its removal.

func CleanUpWorkload

func CleanUpWorkload(ctx context.Context, kueueClient *upstreamkueueclient.Clientset, namespace, name string)

CleanUpWorkload deletes the specified Kueue Workload in the given namespace.

func CreateClusterQueue

func CreateClusterQueue(ctx context.Context, client *upstreamkueueclient.Clientset) (func(), error)

func CreateJob

func CreateJob(kubeClient *kubernetes.Clientset, job *batchv1.Job) (func(), error)

func CreateLocalQueue

func CreateLocalQueue(ctx context.Context, client *upstreamkueueclient.Clientset, namespace, name string) (func(), error)

func CreateNamespace

func CreateNamespace(kubeClient *kubernetes.Clientset, namespace *corev1.Namespace) (func(), error)

func CreatePod

func CreatePod(kubeClient *kubernetes.Clientset, pod *corev1.Pod) (func(), error)

func CreateResourceFlavor

func CreateResourceFlavor(ctx context.Context, client *upstreamkueueclient.Clientset) (func(), error)

func CreateWorkload

func CreateWorkload(client *upstreamkueueclient.Clientset, namespace, queueName, workloadName string) (func(), error)

func DumpKueueControllerManagerLogs

func DumpKueueControllerManagerLogs(ctx context.Context, kubeClient *kubernetes.Clientset, tailLines int64)

DumpKueueControllerManagerLogs dumps the logs from kueue-controller-manager pods when a test fails. This should be called from JustAfterEach.

func GetContainerImageForWorkloads

func GetContainerImageForWorkloads() string

func IsJobSetRunning

func IsJobSetRunning(ctx context.Context, genericClient client.Client, jobSet *jobsetapi.JobSet) (bool, error)

func IsJobSuspended

func IsJobSuspended(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, jobName string) bool

func IsPodScheduled

func IsPodScheduled(ctx context.Context, kubeClient *kubernetes.Clientset, namespace, podName string) bool

func WaitForAllPodsInNamespaceDeleted

func WaitForAllPodsInNamespaceDeleted(ctx context.Context, c client.Client, ns *corev1.Namespace)

Types

type ClusterQueueWrapper

type ClusterQueueWrapper struct {
	*kueuev1beta2.ClusterQueue
}

ClusterQueueWrapper wraps a ClusterQueue and provides builder methods.

func NewClusterQueue

func NewClusterQueue() *ClusterQueueWrapper

NewClusterQueue creates a new wrapper with default values.

func (*ClusterQueueWrapper) Create

func (cqw *ClusterQueueWrapper) Create(ctx context.Context, client *upstreamkueueclient.Clientset) (func(), error)

Create creates the ClusterQueue in the cluster and returns cleanup function.

func (*ClusterQueueWrapper) CreateWithObject

func (cqw *ClusterQueueWrapper) CreateWithObject(ctx context.Context, client *upstreamkueueclient.Clientset) (*kueuev1beta2.ClusterQueue, func(), error)

CreateWithObject creates the ClusterQueue in the cluster and returns the created object, cleanup function, and error.

func (*ClusterQueueWrapper) WithBorrowingLimit

func (cqw *ClusterQueueWrapper) WithBorrowingLimit(resourceName corev1.ResourceName, limit string) *ClusterQueueWrapper

WithBorrowingLimit sets the borrowing limit for a specific resource. resourceName is the name of the resource (e.g., "cpu", "memory"). limit is the maximum amount that can be borrowed from the cohort.

func (*ClusterQueueWrapper) WithCPU

func (cqw *ClusterQueueWrapper) WithCPU(cpu string) *ClusterQueueWrapper

WithCPU sets the CPU quota.

func (*ClusterQueueWrapper) WithCohort

func (cqw *ClusterQueueWrapper) WithCohort(cohort string) *ClusterQueueWrapper

WithCohort sets the cohort name for the ClusterQueue.

func (*ClusterQueueWrapper) WithFlavorName

func (cqw *ClusterQueueWrapper) WithFlavorName(flavorName string) *ClusterQueueWrapper

WithFlavorName sets the resource flavor name.

func (*ClusterQueueWrapper) WithGenerateName

func (cqw *ClusterQueueWrapper) WithGenerateName() *ClusterQueueWrapper

WithGenerateName switches to using GenerateName with "cluster-queue-" prefix.

func (*ClusterQueueWrapper) WithMemory

func (cqw *ClusterQueueWrapper) WithMemory(memory string) *ClusterQueueWrapper

WithMemory sets the memory quota.

func (*ClusterQueueWrapper) WithPreemption

func (cqw *ClusterQueueWrapper) WithPreemption(withinClusterQueue kueuev1beta2.PreemptionPolicy) *ClusterQueueWrapper

WithPreemption sets the preemption policy for the ClusterQueue. withinClusterQueue controls preemption within the same ClusterQueue (e.g., "LowerPriority", "Never").

func (*ClusterQueueWrapper) WithReclaimWithinCohort

func (cqw *ClusterQueueWrapper) WithReclaimWithinCohort(policy kueuev1beta2.PreemptionPolicy) *ClusterQueueWrapper

WithReclaimWithinCohort sets the reclaimWithinCohort preemption policy. This controls whether a pending workload can preempt workloads from other ClusterQueues in the cohort.

type KueueWrapper

type KueueWrapper struct {
	*ssv1.Kueue
}

func NewKueueDefault

func NewKueueDefault() *KueueWrapper

NewKueueDefault returns a default Kueue instance for testing

func (*KueueWrapper) EnableDebug

func (k *KueueWrapper) EnableDebug() *KueueWrapper

func (*KueueWrapper) GetKueue

func (k *KueueWrapper) GetKueue() *ssv1.Kueue

type LeaderWorkerSetOptions

type LeaderWorkerSetOptions struct {
	// QueueName: if non-empty, adds the kueue.x-k8s.io/queue-name label
	QueueName string
	// PriorityClassName: if non-empty, sets the priorityClassName in the leader template spec
	PriorityClassName string
	// Size: defaults to 2 if <= 0
	Size int
}

type LocalQueueWrapper

type LocalQueueWrapper struct {
	*kueuev1beta2.LocalQueue
}

LocalQueueWrapper wraps a LocalQueue and provides builder methods.

func NewLocalQueue

func NewLocalQueue(namespace, name string) *LocalQueueWrapper

NewLocalQueue creates a new wrapper with default values.

func (*LocalQueueWrapper) Create

func (lqw *LocalQueueWrapper) Create(ctx context.Context, client *upstreamkueueclient.Clientset) (func(), error)

Create creates the LocalQueue in the cluster and returns cleanup function.

func (*LocalQueueWrapper) CreateWithObject

func (lqw *LocalQueueWrapper) CreateWithObject(ctx context.Context, client *upstreamkueueclient.Clientset) (*kueuev1beta2.LocalQueue, func(), error)

CreateWithObject creates the LocalQueue in the cluster and returns the created object, cleanup function, and error.

func (*LocalQueueWrapper) WithClusterQueue

func (lqw *LocalQueueWrapper) WithClusterQueue(clusterQueue string) *LocalQueueWrapper

WithClusterQueue sets the ClusterQueue name.

func (*LocalQueueWrapper) WithGenerateName

func (lqw *LocalQueueWrapper) WithGenerateName() *LocalQueueWrapper

WithGenerateName switches to using GenerateName with "local-queue-" prefix.

type PodWrapper

type PodWrapper struct {
	corev1.Pod
}

PodWrapper wraps a Pod.

func MakeCurlMetricsPod

func MakeCurlMetricsPod(namespace string) *PodWrapper

func MakePod

func MakePod(name, ns string) *PodWrapper

func (*PodWrapper) Obj

func (p *PodWrapper) Obj() *corev1.Pod

Obj returns the inner Pod.

type ResourceFlavorWrapper

type ResourceFlavorWrapper struct {
	*kueuev1beta2.ResourceFlavor
}

ResourceFlavorWrapper wraps a ResourceFlavor and provides builder methods.

func NewResourceFlavor

func NewResourceFlavor() *ResourceFlavorWrapper

NewResourceFlavor creates a new wrapper with default values.

func (*ResourceFlavorWrapper) Create

func (rfw *ResourceFlavorWrapper) Create(ctx context.Context, client *upstreamkueueclient.Clientset) (func(), error)

Create creates the ResourceFlavor in the cluster and returns cleanup function.

func (*ResourceFlavorWrapper) CreateWithObject

func (rfw *ResourceFlavorWrapper) CreateWithObject(ctx context.Context, client *upstreamkueueclient.Clientset) (*kueuev1beta2.ResourceFlavor, func(), error)

CreateWithObject creates the ResourceFlavor in the cluster and returns the created object, cleanup function, and error.

func (*ResourceFlavorWrapper) WithGenerateName

func (rfw *ResourceFlavorWrapper) WithGenerateName() *ResourceFlavorWrapper

WithGenerateName switches to using GenerateName with "resource-flavor-" prefix.

type TestClients

type TestClients struct {
	GenericClient         client.Client
	KubeClient            *kubernetes.Clientset
	APIExtClient          *apiextv1.ApiextensionsV1Client
	KueueClient           *kueueclient.Clientset
	UpstreamKueueClient   *upstreamkueueclient.Clientset
	DynamicClient         dynamic.Interface
	ApiregistrationClient *apiregistrationv1client.ApiregistrationV1Client
	RestConfig            *rest.Config
}

func NewTestClients

func NewTestClients() *TestClients

type TestResourceBuilder

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

func NewTestResourceBuilder

func NewTestResourceBuilder(namespace, queueName string) *TestResourceBuilder

func (*TestResourceBuilder) NewDeployment

func (b *TestResourceBuilder) NewDeployment() *appsv1.Deployment

func (*TestResourceBuilder) NewDeploymentWithoutQueue

func (b *TestResourceBuilder) NewDeploymentWithoutQueue() *appsv1.Deployment

func (*TestResourceBuilder) NewJob

func (b *TestResourceBuilder) NewJob() *batchv1.Job

func (*TestResourceBuilder) NewJobSet

func (b *TestResourceBuilder) NewJobSet() *jobsetapi.JobSet

func (*TestResourceBuilder) NewJobSetWithoutQueue

func (b *TestResourceBuilder) NewJobSetWithoutQueue() *jobsetapi.JobSet

func (*TestResourceBuilder) NewJobWithoutQueue

func (b *TestResourceBuilder) NewJobWithoutQueue() *batchv1.Job

func (*TestResourceBuilder) NewLeaderWorkerSet

NewLeaderWorkerSet creates a LeaderWorkerSet with optional queue name, priority class, and size.

func (*TestResourceBuilder) NewPod

func (b *TestResourceBuilder) NewPod() *corev1.Pod

func (*TestResourceBuilder) NewPodWithoutQueue

func (b *TestResourceBuilder) NewPodWithoutQueue() *corev1.Pod

func (*TestResourceBuilder) NewStatefulSet

func (b *TestResourceBuilder) NewStatefulSet() *appsv1.StatefulSet

func (*TestResourceBuilder) NewStatefulSetWithoutQueue

func (b *TestResourceBuilder) NewStatefulSetWithoutQueue() *appsv1.StatefulSet

Jump to

Keyboard shortcuts

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