Skip to content

Commit aab17f5

Browse files
committed
Updated testing for new requeuing mechanism
1 parent a1f0d3e commit aab17f5

File tree

2 files changed

+41
-19
lines changed

2 files changed

+41
-19
lines changed

test/e2e/queue.go

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ package e2e
3636
import (
3737
"fmt"
3838
"os"
39-
4039
"time"
4140

4241
. "github.com/onsi/ginkgo"
@@ -140,7 +139,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
140139
Expect(err).NotTo(HaveOccurred())
141140
})
142141

143-
It("MCAD CPU Requeuing Test", func() {
142+
It("MCAD CPU Requeuing - Completion After enough Requeuing Times Test", func() {
144143
fmt.Fprintf(os.Stdout, "[e2e] MCAD CPU Requeuing Test - Started.\n")
145144

146145
context := initTestContext()
@@ -153,13 +152,31 @@ var _ = Describe("AppWrapper E2E Test", func() {
153152
// The job should be requeued 3 times before it finishes since the wait time is doubled each time the job is requeued (i.e., initially it waits
154153
// for 1 minutes before requeuing, then 2 minutes, and then 4 minutes). Since the init containers take 3 minutes
155154
// and 20 seconds to finish, a 4 minute wait should be long enough to finish the job successfully
156-
aw := createJobAWWithInitContainer(context, "aw-job-3-init-container")
155+
aw := createJobAWWithInitContainer(context, "aw-job-3-init-container", 60, "exponential", 0)
157156
appwrappers = append(appwrappers, aw)
158157

159-
err := waitAWPodsCompleted(context, aw) // This test waits for 10 minutes to make sure all PODs complete
158+
err := waitAWPodsCompleted(context, aw, 600 * time.Second) // This test waits for 10 minutes to make sure all PODs complete
160159
Expect(err).NotTo(HaveOccurred())
161160
})
162161

162+
It("MCAD CPU Requeuing - Deletion After Maximum Requeuing Times Test", func() {
163+
fmt.Fprintf(os.Stdout, "[e2e] MCAD CPU Requeuing Test - Started.\n")
164+
165+
context := initTestContext()
166+
var appwrappers []*arbv1.AppWrapper
167+
appwrappersPtr := &appwrappers
168+
defer cleanupTestObjectsPtr(context, appwrappersPtr)
169+
170+
// Create a job with init containers that need 200 seconds to be ready before the container starts.
171+
// The requeuing mechanism is set to fire after 1 second (plus the 60 seconds time interval of the background thread)
172+
// Within 5 minutes, the AppWrapper will be requeued up to 3 times at which point it will be deleted
173+
aw := createJobAWWithInitContainer(context, "aw-job-3-init-container", 1, "none", 3)
174+
appwrappers = append(appwrappers, aw)
175+
176+
err := waitAWPodsCompleted(context, aw, 300 * time.Second)
177+
Expect(err).To(HaveOccurred())
178+
})
179+
163180
It("Create AppWrapper - StatefulSet Only - 2 Pods", func() {
164181
fmt.Fprintf(os.Stdout, "[e2e] Create AppWrapper - StatefulSet Only - 2 Pods - Started.\n")
165182

@@ -371,7 +388,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
371388

372389
// This should fit on cluster with customPodResources matching deployment resource demands so AW pods are created
373390
aw := createGenericDeploymentCustomPodResourcesWithCPUAW(
374-
context, "aw-deployment-2-550-vs-550-cpu", "550m", "550m", 2, 1)
391+
context, "aw-deployment-2-550-vs-550-cpu", "550m", "550m", 2, 60)
375392

376393
appwrappers = append(appwrappers, aw)
377394

@@ -399,7 +416,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
399416

400417
// This should not fit on any node but should dispatch because there is enough aggregated resources.
401418
aw2 := createGenericDeploymentCustomPodResourcesWithCPUAW(
402-
context, "aw-ff-deployment-1-700-cpu", "700m", "700m", 1, 1)
419+
context, "aw-ff-deployment-1-700-cpu", "700m", "700m", 1, 60)
403420

404421
appwrappers = append(appwrappers, aw2)
405422

@@ -412,7 +429,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
412429
// This should fit on cluster after AW aw-deployment-1-700-cpu above is automatically preempted on
413430
// scheduling failure
414431
aw3 := createGenericDeploymentCustomPodResourcesWithCPUAW(
415-
context, "aw-ff-deployment-2-340-cpu", "340m", "340m", 2, 1)
432+
context, "aw-ff-deployment-2-340-cpu", "340m", "340m", 2, 60)
416433

417434
appwrappers = append(appwrappers, aw3)
418435

@@ -445,7 +462,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
445462

446463
// This should not fit on cluster but customPodResources is incorrect so AW pods are created
447464
aw2 := createGenericDeploymentCustomPodResourcesWithCPUAW(
448-
context, "aw-deployment-2-425-vs-426-cpu", "425m", "426m", 2, 1)
465+
context, "aw-deployment-2-425-vs-426-cpu", "425m", "426m", 2, 60)
449466

450467
appwrappers = append(appwrappers, aw2)
451468

@@ -472,7 +489,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
472489

473490
// This should fit on cluster but customPodResources is incorrect so AW pods are not created
474491
aw2 := createGenericDeploymentCustomPodResourcesWithCPUAW(
475-
context, "aw-deployment-2-426-vs-425-cpu", "426m", "425m", 2, 1)
492+
context, "aw-deployment-2-426-vs-425-cpu", "426m", "425m", 2, 60)
476493

477494
appwrappers = append(appwrappers, aw2)
478495

@@ -517,7 +534,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
517534
aw := createGenericJobAWWithScheduleSpec(context, "aw-test-job-with-scheduling-spec")
518535
err1 := waitAWPodsReady(context, aw)
519536
Expect(err1).NotTo(HaveOccurred())
520-
err2 := waitAWPodsCompleted(context, aw)
537+
err2 := waitAWPodsCompleted(context, aw, 90 * time.Second)
521538
Expect(err2).NotTo(HaveOccurred())
522539

523540
// Once pods are completed, we wait for them to see if they change their status to anything BUT "Completed"

test/e2e/util.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,8 @@ func waitAWPodsReady(ctx *context, aw *arbv1.AppWrapper) error {
612612
return waitAWPodsReadyEx(ctx, aw, int(aw.Spec.SchedSpec.MinAvailable), false)
613613
}
614614

615-
func waitAWPodsCompleted(ctx *context, aw *arbv1.AppWrapper) error {
616-
return waitAWPodsCompletedEx(ctx, aw, int(aw.Spec.SchedSpec.MinAvailable), false)
615+
func waitAWPodsCompleted(ctx *context, aw *arbv1.AppWrapper, timeout time.Duration) error {
616+
return waitAWPodsCompletedEx(ctx, aw, int(aw.Spec.SchedSpec.MinAvailable), false, timeout)
617617
}
618618

619619
func waitAWPodsNotCompleted(ctx *context, aw *arbv1.AppWrapper) error {
@@ -654,8 +654,8 @@ func waitAWPodsReadyEx(ctx *context, aw *arbv1.AppWrapper, taskNum int, quite bo
654654
[]v1.PodPhase{v1.PodRunning, v1.PodSucceeded}, taskNum, quite))
655655
}
656656

657-
func waitAWPodsCompletedEx(ctx *context, aw *arbv1.AppWrapper, taskNum int, quite bool) error {
658-
return wait.Poll(100*time.Millisecond, tenMinutes, awPodPhase(ctx, aw,
657+
func waitAWPodsCompletedEx(ctx *context, aw *arbv1.AppWrapper, taskNum int, quite bool, timeout time.Duration ) error {
658+
return wait.Poll(100*time.Millisecond, timeout, awPodPhase(ctx, aw,
659659
[]v1.PodPhase{v1.PodSucceeded}, taskNum, quite))
660660
}
661661

@@ -745,7 +745,7 @@ func createReplicaSet(context *context, name string, rep int32, img string, req
745745
return deployment
746746
}
747747

748-
func createJobAWWithInitContainer(context *context, name string) *arbv1.AppWrapper {
748+
func createJobAWWithInitContainer(context *context, name string, requeuingTimeInSeconds int, requeuingGrowthType string, requeuingMaxNumRequeuings int ) *arbv1.AppWrapper {
749749
rb := []byte(`{"apiVersion": "batch/v1",
750750
"kind": "Job",
751751
"metadata": {
@@ -798,7 +798,6 @@ func createJobAWWithInitContainer(context *context, name string) *arbv1.AppWrapp
798798
}} `)
799799

800800
var minAvailable int = 3
801-
var requeuingTimeMinutes int = 1
802801

803802
aw := &arbv1.AppWrapper{
804803
ObjectMeta: metav1.ObjectMeta{
@@ -808,7 +807,11 @@ func createJobAWWithInitContainer(context *context, name string) *arbv1.AppWrapp
808807
Spec: arbv1.AppWrapperSpec{
809808
SchedSpec: arbv1.SchedulingSpecTemplate{
810809
MinAvailable: minAvailable,
811-
RequeuingTimeMinutes: requeuingTimeMinutes,
810+
Requeuing: arbv1.RequeuingTemplate{
811+
TimeInSeconds: requeuingTimeInSeconds,
812+
GrowthType: requeuingGrowthType,
813+
MaxNumRequeuings: requeuingMaxNumRequeuings,
814+
},
812815
},
813816
AggrResources: arbv1.AppWrapperResourceList{
814817
GenericItems: []arbv1.AppWrapperGenericResource{
@@ -2291,7 +2294,7 @@ func createGenericDeploymentWithCPUAW(context *context, name string, cpuDemand s
22912294
return appwrapper
22922295
}
22932296

2294-
func createGenericDeploymentCustomPodResourcesWithCPUAW(context *context, name string, customPodCpuDemand string, cpuDemand string, replicas int, requeuingTimeMinutes int) *arbv1.AppWrapper {
2297+
func createGenericDeploymentCustomPodResourcesWithCPUAW(context *context, name string, customPodCpuDemand string, cpuDemand string, replicas int, requeuingTimeInSeconds int) *arbv1.AppWrapper {
22952298
rb := []byte(fmt.Sprintf(`{
22962299
"apiVersion": "apps/v1",
22972300
"kind": "Deployment",
@@ -2350,7 +2353,9 @@ func createGenericDeploymentCustomPodResourcesWithCPUAW(context *context, name s
23502353
Spec: arbv1.AppWrapperSpec{
23512354
SchedSpec: arbv1.SchedulingSpecTemplate{
23522355
MinAvailable: schedSpecMin,
2353-
RequeuingTimeMinutes: requeuingTimeMinutes,
2356+
Requeuing: arbv1.RequeuingTemplate{
2357+
TimeInSeconds: requeuingTimeInSeconds,
2358+
},
23542359
},
23552360
AggrResources: arbv1.AppWrapperResourceList{
23562361
GenericItems: []arbv1.AppWrapperGenericResource{

0 commit comments

Comments
 (0)