Skip to content

Commit

Permalink
e2e: update slot resource
Browse files Browse the repository at this point in the history
    update slot resources

Signed-off-by: alcorj.mizar <[email protected]>
  • Loading branch information
alcorj-mizar committed Jul 3, 2020
1 parent 8d93ba2 commit ff65797
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 79 deletions.
77 changes: 0 additions & 77 deletions test/e2e/job_scheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,83 +261,6 @@ var _ = Describe("Job E2E Test", func() {

})

It("Reclaim: New queue with job created reclaim when lack of resource", func() {
q1 := "default"
q2 := "reclaim-q2"
ctx := initTestContext(options{
queues: []string{q2},
nodesNumLimit: 3,
nodesResourceLimit: v1.ResourceList{"cpu": resource.MustParse("1500m"), "memory": resource.MustParse("1224Mi")},
})

defer cleanupTestContext(ctx)

slot1 := v1.ResourceList{"cpu": resource.MustParse("1500m"), "memory": resource.MustParse("1224Mi")}
slot2 := v1.ResourceList{"cpu": resource.MustParse("750m"), "memory": resource.MustParse("612Mi")}
jobSpec1 := &jobSpec{
tasks: []taskSpec{
{
img: defaultNginxImage,
req: slot1,
min: 1,
rep: 1,
},
},
}
jobSpec2 := &jobSpec{
tasks: []taskSpec{
{
img: defaultNginxImage,
req: slot2,
min: 1,
rep: 1,
},
},
}

jobList := []*vcbatch.Job{}
jobSpec1.name = "reclaim-j1"
jobSpec1.queue = q1
jobList = append(jobList, createJob(ctx, jobSpec1))

jobSpec1.name = "reclaim-j2"
jobSpec1.queue = q1
jobList = append(jobList, createJob(ctx, jobSpec1))

jobSpec2.name = "reclaim-j3"
jobSpec2.queue = q2
jobList = append(jobList, createJob(ctx, jobSpec2))

jobSpec2.name = "reclaim-j4"
jobSpec2.queue = q2
jobList = append(jobList, createJob(ctx, jobSpec2))

for _, jobCreated := range jobList {
err := waitTasksReady(ctx, jobCreated, 1)
Expect(err).NotTo(HaveOccurred(), "Wait for job "+jobCreated.Name+" failed")
}

// Create queue3 & append to context queue list
q3 := "reclaim-q3"
ctx.queues = append(ctx.queues, q3)
createQueues(ctx)

jobSpec2.name = "reclaim-j5"
jobSpec2.queue = q3
createJob(ctx, jobSpec2)

time.Sleep(60 * time.Second)

// Ensure job is running in q3
err := waitQueueStatus(func() (bool, error) {
queue, err := ctx.vcclient.SchedulingV1beta1().Queues().Get(context.TODO(), q3, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred(), "Get queue %s failed", q3)
return queue.Status.Running == 1, nil
})
Expect(err).NotTo(HaveOccurred(), "Error waiting for queue running")

})

It("Multiple Preemption", func() {
ctx := initTestContext(options{
priorityClasses: map[string]int32{
Expand Down
7 changes: 5 additions & 2 deletions test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,10 @@ func setPlaceHolderForSchedulerTesting(ctx *testContext, req v1.ResourceList, re
minMemoryValue := float64(minMemory.Value())
currentAllocatable := schedulerapi.NewResource(node.Status.Allocatable)

fmt.Println(node.Name)
fmt.Println(node.Status.Allocatable.Cpu())
fmt.Println(node.Status.Allocatable.Memory())

if res, found := used[node.Name]; found {
currentAllocatable.Sub(res)
}
Expand All @@ -980,7 +984,6 @@ func setPlaceHolderForSchedulerTesting(ctx *testContext, req v1.ResourceList, re
if minCPUMilli <= currentAllocatable.MilliCPU && minMemoryValue <= currentAllocatable.Memory {
resourceRichNode = resourceRichNode + 1
if resourceRichNode <= reqNum {
fmt.Println(resourceRichNode)
phCPU = currentAllocatable.MilliCPU - minCPUMilli
phMemory = currentAllocatable.Memory - minMemoryValue
}
Expand Down Expand Up @@ -1014,7 +1017,7 @@ func createPlaceHolder(ctx *testContext, phr v1.ResourceList, nodeName string) e
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
corev1.Container{
{
Name: "placeholder",
Resources: corev1.ResourceRequirements{
Requests: phr,
Expand Down

0 comments on commit ff65797

Please sign in to comment.