diff --git a/test/e2e/job.go b/test/e2e/job.go index 19dc82499..375937613 100644 --- a/test/e2e/job.go +++ b/test/e2e/job.go @@ -105,7 +105,7 @@ var _ = Describe("Job E2E Test", func() { err = waitPodGroupPending(context, pg) Expect(err).NotTo(HaveOccurred()) - waitPodGroupUnschedulable(context, pg) + err = waitPodGroupUnschedulable(context, pg) Expect(err).NotTo(HaveOccurred()) err = deleteReplicaSet(context, replicaset.Name) @@ -325,4 +325,48 @@ var _ = Describe("Job E2E Test", func() { err = waitTasksReadyEx(context, pg, expteced) Expect(err).NotTo(HaveOccurred()) }) + + It("Try to fit unassigned task with different resource requests in one loop", func() { + context := initTestContext() + defer cleanupTestContext(context) + + slot := oneCPU + rep := clusterSize(context, slot) + minMemberOverride := int32(1) + + replicaset := createReplicaSet(context, "rs-1", rep-1, "nginx", slot) + err := waitReplicaSetReady(context, replicaset.Name) + Expect(err).NotTo(HaveOccurred()) + + _, pg := createJobEx(context, &jobSpec{ + name: "multi-task-diff-resource-job", + tasks: []taskSpec{ + { + img: "nginx", + pri: masterPriority, + min: 1, + rep: 1, + req: twoCPU, + }, + { + img: "nginx", + pri: workerPriority, + min: 1, + rep: 1, + req: halfCPU, + }, + }, + minMember: &minMemberOverride, + }) + + err = waitPodGroupPending(context, pg) + Expect(err).NotTo(HaveOccurred()) + + err = waitPodGroupUnschedulable(context, pg) + Expect(err).NotTo(HaveOccurred()) + + // task_1 has been scheduled + err = waitTasksReady(context, pg, int(minMemberOverride)) + Expect(err).NotTo(HaveOccurred()) + }) }) diff --git a/test/e2e/util.go b/test/e2e/util.go index 5ab7c03e3..13340cc7c 100644 --- a/test/e2e/util.go +++ b/test/e2e/util.go @@ -47,6 +47,7 @@ import ( var oneMinute = 1 * time.Minute +var halfCPU = v1.ResourceList{"cpu": resource.MustParse("500m")} var oneCPU = v1.ResourceList{"cpu": resource.MustParse("1000m")} var twoCPU = v1.ResourceList{"cpu": resource.MustParse("2000m")} var threeCPU = v1.ResourceList{"cpu": resource.MustParse("3000m")} @@ -259,6 +260,7 @@ type jobSpec struct { namespace string queue string tasks []taskSpec + minMember *int32 } func getNS(context *context, job *jobSpec) string { @@ -328,6 +330,10 @@ func createJobEx(context *context, job *jobSpec) ([]*batchv1.Job, *arbv1.PodGrou }, } + if job.minMember != nil { + pg.Spec.MinMember = *job.minMember + } + podgroup, err := context.karclient.Scheduling().PodGroups(pg.Namespace).Create(pg) Expect(err).NotTo(HaveOccurred())