Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Commit 9e6933f

Browse files
committed
Add e2e test for different task resources
1 parent 3caebf5 commit 9e6933f

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

test/e2e/job.go

+56-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ var _ = Describe("Job E2E Test", func() {
105105
err = waitPodGroupPending(context, pg)
106106
Expect(err).NotTo(HaveOccurred())
107107

108-
waitPodGroupUnschedulable(context, pg)
108+
err = waitPodGroupUnschedulable(context, pg)
109109
Expect(err).NotTo(HaveOccurred())
110110

111111
err = deleteReplicaSet(context, replicaset.Name)
@@ -325,4 +325,59 @@ var _ = Describe("Job E2E Test", func() {
325325
err = waitTasksReadyEx(context, pg, expteced)
326326
Expect(err).NotTo(HaveOccurred())
327327
})
328+
329+
It("Try to fit unassigned task with different resource requests in one loop", func() {
330+
context := initTestContext()
331+
defer cleanupTestContext(context)
332+
333+
slot := oneCPU
334+
rep := clusterSize(context, slot)
335+
// Make sure podGroup are unschedulable not matter rep is odd or even
336+
if rep%2 == 1 {
337+
rep = rep + 1
338+
}
339+
340+
replicaset := createReplicaSet(context, "rs-1", rep/2, "nginx", slot)
341+
err := waitReplicaSetReady(context, replicaset.Name)
342+
Expect(err).NotTo(HaveOccurred())
343+
344+
_, pg := createJobEx(context, &jobSpec{
345+
name: "multi-task-diff-resource-job",
346+
tasks: []taskSpec{
347+
{
348+
img: "nginx",
349+
pri: masterPriority,
350+
min: rep / 2,
351+
rep: rep / 2,
352+
req: oneCPU,
353+
},
354+
{
355+
img: "nginx",
356+
pri: workerPriority,
357+
min: 1,
358+
rep: 1,
359+
req: LessThanOneCPU,
360+
},
361+
{
362+
img: "nginx",
363+
pri: workerPriority,
364+
min: 1,
365+
rep: 1,
366+
req: minMilliCPU,
367+
},
368+
},
369+
})
370+
371+
err = waitPodGroupPending(context, pg)
372+
Expect(err).NotTo(HaveOccurred())
373+
374+
err = waitPodGroupUnschedulable(context, pg)
375+
Expect(err).NotTo(HaveOccurred())
376+
377+
err = deleteReplicaSet(context, replicaset.Name)
378+
Expect(err).NotTo(HaveOccurred())
379+
380+
err = waitPodGroupReady(context, pg)
381+
Expect(err).NotTo(HaveOccurred())
382+
})
328383
})

test/e2e/util.go

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ import (
4747

4848
var oneMinute = 1 * time.Minute
4949

50+
// Task with resource lower than minMilliCPU will be considered as BestEffort and skipped in allocate action
51+
var minMilliCPU = v1.ResourceList{"cpu": resource.MustParse("10m")}
52+
var LessThanOneCPU = v1.ResourceList{"cpu": resource.MustParse("990m")}
5053
var oneCPU = v1.ResourceList{"cpu": resource.MustParse("1000m")}
5154
var twoCPU = v1.ResourceList{"cpu": resource.MustParse("2000m")}
5255
var threeCPU = v1.ResourceList{"cpu": resource.MustParse("3000m")}

0 commit comments

Comments
 (0)