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

Commit

Permalink
Add e2e test for different task resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffwan committed Jan 13, 2019
1 parent b43b06a commit e0a3454
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
46 changes: 45 additions & 1 deletion test/e2e/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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())
})
})
6 changes: 6 additions & 0 deletions test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")}
Expand Down Expand Up @@ -259,6 +260,7 @@ type jobSpec struct {
namespace string
queue string
tasks []taskSpec
minMember *int32
}

func getNS(context *context, job *jobSpec) string {
Expand Down Expand Up @@ -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())

Expand Down

0 comments on commit e0a3454

Please sign in to comment.