From 7a443c79367d5c0320aa00724b20384191c217b3 Mon Sep 17 00:00:00 2001 From: Aldo Culquicondor Date: Tue, 10 Jan 2023 14:24:12 -0500 Subject: [PATCH] Define priority by value in testing wrappers Change-Id: Ifa67274f60077c300d7b822bfde74974beea964a --- apis/kueue/webhooks/workload_webhook_test.go | 3 +-- pkg/util/priority/priority_test.go | 3 +-- pkg/util/testing/wrappers.go | 4 ++-- test/integration/scheduler/scheduler_test.go | 17 ++++++++--------- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/apis/kueue/webhooks/workload_webhook_test.go b/apis/kueue/webhooks/workload_webhook_test.go index 513717bf4783..e02dc382c485 100644 --- a/apis/kueue/webhooks/workload_webhook_test.go +++ b/apis/kueue/webhooks/workload_webhook_test.go @@ -27,7 +27,6 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" kueue "sigs.k8s.io/kueue/apis/kueue/v1alpha2" - "sigs.k8s.io/kueue/pkg/util/pointer" testingutil "sigs.k8s.io/kueue/pkg/util/testing" ) @@ -220,7 +219,7 @@ func TestValidateWorkload(t *testing.T) { "should have valid priorityClassName": { workload: testingutil.MakeWorkload(testWorkloadName, testWorkloadNamespace). PriorityClass("invalid_class"). - Priority(pointer.Int32(0)). + Priority(0). Obj(), wantErr: field.ErrorList{ field.Invalid(specField.Child("priorityClassName"), nil, ""), diff --git a/pkg/util/priority/priority_test.go b/pkg/util/priority/priority_test.go index 79c898014d61..b5e995ff27ae 100644 --- a/pkg/util/priority/priority_test.go +++ b/pkg/util/priority/priority_test.go @@ -28,7 +28,6 @@ import ( kueue "sigs.k8s.io/kueue/apis/kueue/v1alpha2" "sigs.k8s.io/kueue/pkg/constants" - "sigs.k8s.io/kueue/pkg/util/pointer" utiltesting "sigs.k8s.io/kueue/pkg/util/testing" ) @@ -38,7 +37,7 @@ func TestPriority(t *testing.T) { want int32 }{ "priority is specified": { - workload: utiltesting.MakeWorkload("name", "ns").Priority(pointer.Int32(100)).Obj(), + workload: utiltesting.MakeWorkload("name", "ns").Priority(100).Obj(), want: 100, }, "priority is empty": { diff --git a/pkg/util/testing/wrappers.go b/pkg/util/testing/wrappers.go index b2c1f5eedc30..ea51cdee02c9 100644 --- a/pkg/util/testing/wrappers.go +++ b/pkg/util/testing/wrappers.go @@ -210,8 +210,8 @@ func (w *WorkloadWrapper) RuntimeClass(name string) *WorkloadWrapper { return w } -func (w *WorkloadWrapper) Priority(priority *int32) *WorkloadWrapper { - w.Spec.Priority = priority +func (w *WorkloadWrapper) Priority(priority int32) *WorkloadWrapper { + w.Spec.Priority = &priority return w } diff --git a/test/integration/scheduler/scheduler_test.go b/test/integration/scheduler/scheduler_test.go index 7625d845c862..5d1084780e1c 100644 --- a/test/integration/scheduler/scheduler_test.go +++ b/test/integration/scheduler/scheduler_test.go @@ -26,7 +26,6 @@ import ( kueue "sigs.k8s.io/kueue/apis/kueue/v1alpha2" "sigs.k8s.io/kueue/pkg/metrics" - "sigs.k8s.io/kueue/pkg/util/pointer" "sigs.k8s.io/kueue/pkg/util/testing" "sigs.k8s.io/kueue/test/util" ) @@ -157,9 +156,9 @@ var _ = ginkgo.Describe("Scheduler", func() { lowPriorityVal, highPriorityVal := int32(10), int32(100) - wlLowPriority := testing.MakeWorkload("wl-low-priority", ns.Name).Queue(queue.Name).Request(corev1.ResourceCPU, "5").Priority(&lowPriorityVal).Obj() + wlLowPriority := testing.MakeWorkload("wl-low-priority", ns.Name).Queue(queue.Name).Request(corev1.ResourceCPU, "5").Priority(lowPriorityVal).Obj() gomega.Expect(k8sClient.Create(ctx, wlLowPriority)).Should(gomega.Succeed()) - wlHighPriority := testing.MakeWorkload("wl-high-priority", ns.Name).Queue(queue.Name).Request(corev1.ResourceCPU, "5").Priority(&highPriorityVal).Obj() + wlHighPriority := testing.MakeWorkload("wl-high-priority", ns.Name).Queue(queue.Name).Request(corev1.ResourceCPU, "5").Priority(highPriorityVal).Obj() gomega.Expect(k8sClient.Create(ctx, wlHighPriority)).Should(gomega.Succeed()) util.ExpectPendingWorkloadsMetric(prodClusterQ, 0, 0) @@ -873,14 +872,14 @@ var _ = ginkgo.Describe("Scheduler", func() { ginkgo.By("Creating workloads") wl1 := testing.MakeWorkload("wl1", matchingNS.Name).Queue(strictFIFOQueue. - Name).Request(corev1.ResourceCPU, "2").Priority(pointer.Int32(100)).Obj() + Name).Request(corev1.ResourceCPU, "2").Priority(100).Obj() gomega.Expect(k8sClient.Create(ctx, wl1)).Should(gomega.Succeed()) wl2 := testing.MakeWorkload("wl2", matchingNS.Name).Queue(strictFIFOQueue. - Name).Request(corev1.ResourceCPU, "5").Priority(pointer.Int32(10)).Obj() + Name).Request(corev1.ResourceCPU, "5").Priority(10).Obj() gomega.Expect(k8sClient.Create(ctx, wl2)).Should(gomega.Succeed()) // wl3 can't be scheduled before wl2 even though there is enough quota. wl3 := testing.MakeWorkload("wl3", matchingNS.Name).Queue(strictFIFOQueue. - Name).Request(corev1.ResourceCPU, "1").Priority(pointer.Int32(1)).Obj() + Name).Request(corev1.ResourceCPU, "1").Priority(1).Obj() gomega.Expect(k8sClient.Create(ctx, wl3)).Should(gomega.Succeed()) gomega.Expect(k8sClient.Create(ctx, strictFIFOQueue)).Should(gomega.Succeed()) @@ -907,14 +906,14 @@ var _ = ginkgo.Describe("Scheduler", func() { ginkgo.By("Creating workloads") wl1 := testing.MakeWorkload("wl1", matchingNS.Name).Queue(matchingQueue. - Name).Request(corev1.ResourceCPU, "2").Priority(pointer.Int32(100)).Obj() + Name).Request(corev1.ResourceCPU, "2").Priority(100).Obj() gomega.Expect(k8sClient.Create(ctx, wl1)).Should(gomega.Succeed()) wl2 := testing.MakeWorkload("wl2", ns.Name).Queue(notMatchingQueue. - Name).Request(corev1.ResourceCPU, "5").Priority(pointer.Int32(10)).Obj() + Name).Request(corev1.ResourceCPU, "5").Priority(10).Obj() gomega.Expect(k8sClient.Create(ctx, wl2)).Should(gomega.Succeed()) // wl2 can't block wl3 from getting scheduled. wl3 := testing.MakeWorkload("wl3", matchingNS.Name).Queue(matchingQueue. - Name).Request(corev1.ResourceCPU, "1").Priority(pointer.Int32(1)).Obj() + Name).Request(corev1.ResourceCPU, "1").Priority(1).Obj() gomega.Expect(k8sClient.Create(ctx, wl3)).Should(gomega.Succeed()) util.ExpectWorkloadsToBeAdmitted(ctx, k8sClient, strictFIFOClusterQ.Name, wl1, wl3)