Skip to content

Commit

Permalink
test dedicated for StrictFIFO
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Wang <wangqingcan1990@gmail.com>
  • Loading branch information
denkensk committed May 1, 2022
1 parent 929ec3d commit 214990a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkg/util/testing/wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ func (w *WorkloadWrapper) RuntimeClass(name string) *WorkloadWrapper {
return w
}

func (w *WorkloadWrapper) Priority(priority *int32) *WorkloadWrapper {
w.Spec.Priority = priority
return w
}

// AdmissionWrapper wraps an Admission
type AdmissionWrapper struct{ kueue.Admission }

Expand Down
40 changes: 38 additions & 2 deletions test/integration/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,7 @@ var _ = ginkgo.Describe("Scheduler", func() {
devBEClusterQ := testing.MakeClusterQueue("dev-be-cq").
Cohort("be").
Resource(testing.MakeResource(corev1.ResourceCPU).
Flavor(testing.MakeFlavor(onDemandFlavor.Name,
"5").Max("5").Obj()).
Flavor(testing.MakeFlavor(onDemandFlavor.Name, "5").Max("5").Obj()).
Obj()).
Obj()
gomega.Expect(k8sClient.Create(ctx, devBEClusterQ)).Should(gomega.Succeed())
Expand Down Expand Up @@ -596,4 +595,41 @@ var _ = ginkgo.Describe("Scheduler", func() {
framework.ExpectWorkloadsToBeAdmitted(ctx, k8sClient, prodBEClusterQ.Name, wl1)
framework.ExpectWorkloadsToBeAdmitted(ctx, k8sClient, devBEClusterQ.Name, wl2)
})

ginkgo.It("Should schedule workloads by their priority strictly in StrictFIFO", func() {
strictFIFOClusterQ := testing.MakeClusterQueue("strict-fifo-cq").
QueueingStrategy(kueue.StrictFIFO).
Resource(testing.MakeResource(corev1.ResourceCPU).
Flavor(testing.MakeFlavor(onDemandFlavor.Name,
"5").Max("5").Obj()).
Obj()).
Obj()
gomega.Expect(k8sClient.Create(ctx, strictFIFOClusterQ)).Should(gomega.Succeed())
defer func() {
gomega.Expect(framework.DeleteClusterQueue(ctx, k8sClient, strictFIFOClusterQ)).Should(gomega.Succeed())
}()

strictFIFOQueue := testing.MakeQueue("strict-fifo-q", ns.Name).ClusterQueue(strictFIFOClusterQ.Name).Obj()
ginkgo.By("Creating workloads")
wl1 := testing.MakeWorkload("wl1", ns.Name).Queue(strictFIFOQueue.
Name).Request(corev1.ResourceCPU, "2").Priority(pointer.Int32(100)).Obj()
gomega.Expect(k8sClient.Create(ctx, wl1)).Should(gomega.Succeed())
wl2 := testing.MakeWorkload("wl2", ns.Name).Queue(strictFIFOQueue.
Name).Request(corev1.ResourceCPU, "5").Priority(pointer.Int32(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", ns.Name).Queue(strictFIFOQueue.
Name).Request(corev1.ResourceCPU, "1").Priority(pointer.Int32(1)).Obj()
gomega.Expect(k8sClient.Create(ctx, wl3)).Should(gomega.Succeed())

gomega.Expect(k8sClient.Create(ctx, strictFIFOQueue)).Should(gomega.Succeed())

framework.ExpectWorkloadsToBeAdmitted(ctx, k8sClient, strictFIFOClusterQ.Name, wl1)
framework.ExpectWorkloadsToBePending(ctx, k8sClient, wl2)
gomega.Consistently(func() bool {
lookupKey := types.NamespacedName{Name: wl3.Name, Namespace: wl3.Namespace}
gomega.Expect(k8sClient.Get(ctx, lookupKey, wl3)).Should(gomega.Succeed())
return wl3.Spec.Admission == nil
}, framework.ConsistentDuration, framework.Interval).Should(gomega.Equal(true))
})
})

0 comments on commit 214990a

Please sign in to comment.