Skip to content

Commit b4d9c5b

Browse files
asm582openshift-merge-robot
authored andcommitted
address review
1 parent a6ddbdd commit b4d9c5b

File tree

2 files changed

+19
-89
lines changed

2 files changed

+19
-89
lines changed

test/e2e/queue.go

Lines changed: 6 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -581,25 +581,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
581581
aw := createGenericJobAWWithStatus(context, "aw-test-job-with-comp-1")
582582
err1 := waitAWPodsReady(context, aw)
583583
Expect(err1).NotTo(HaveOccurred())
584-
aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{})
585-
if err != nil {
586-
fmt.Fprintf(GinkgoWriter, "Error getting status, %v\n", err)
587-
}
588-
Expect(err).Should(Succeed())
589-
var pass = false
590-
for true {
591-
aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{})
592-
if err != nil {
593-
fmt.Fprintf(GinkgoWriter, "Error getting status, %v\n", err)
594-
}
595-
if aw1.Status.State == arbv1.AppWrapperStateCompleted {
596-
pass = true
597-
break
598-
}
599-
}
600-
601-
Expect(pass).To(Equal(true))
602-
fmt.Fprintf(GinkgoWriter, "[e2e] status of AW %v.\n", aw1.Status.State)
584+
Eventually(AppWrapper(context, aw.Namespace, aw.Name), 2*time.Minute).Should(WithTransform(AppWrapperState, Equal(arbv1.AppWrapperStateCompleted)))
603585
appwrappers = append(appwrappers, aw)
604586
fmt.Fprintf(os.Stdout, "[e2e] MCAD Job Completion Test - Completed.\n")
605587
})
@@ -614,23 +596,8 @@ var _ = Describe("AppWrapper E2E Test", func() {
614596
aw := createGenericJobAWWithMultipleStatus(context, "aw-test-job-with-comp-ms-21")
615597
err1 := waitAWPodsReady(context, aw)
616598
Expect(err1).NotTo(HaveOccurred(), "Expecting pods to be ready for app wrapper: 'aw-test-job-with-comp-ms-21'")
617-
aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{})
618-
Expect(err).NotTo(HaveOccurred(), "No error is expected when getting status")
619-
fmt.Fprintf(GinkgoWriter, "[e2e] MCAD Multi-Item Job Completion Test status of AW %v.\n", aw1.Status)
620-
var pass = false
621-
for true {
622-
aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{})
623-
if err != nil {
624-
fmt.Fprintf(GinkgoWriter, "Error getting status, %v\n", err)
625-
}
626-
if aw1.Status.State == arbv1.AppWrapperStateCompleted {
627-
pass = true
628-
break
629-
}
630-
}
631-
632-
Expect(pass).To(Equal(true))
633-
fmt.Fprintf(GinkgoWriter, "[e2e] status of AW %v.\n", aw1.Status.State)
599+
Eventually(AppWrapper(context, aw.Namespace, aw.Name), 2*time.Minute).Should(WithTransform(AppWrapperState, Equal(arbv1.AppWrapperStateCompleted)))
600+
appwrappers = append(appwrappers, aw)
634601
appwrappers = append(appwrappers, aw)
635602
fmt.Fprintf(os.Stdout, "[e2e] MCAD Multi-Item Job Completion Test - Completed.\n")
636603
})
@@ -684,24 +651,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
684651
aw := createGenericJobAWtWithLargeCompute(context, "aw-test-job-with-large-comp-1")
685652
err1 := waitAWPodsReady(context, aw)
686653
Expect(err1).NotTo(HaveOccurred())
687-
aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{})
688-
if err != nil {
689-
fmt.Fprintf(GinkgoWriter, "Error getting status, %v", err)
690-
}
691-
pass := false
692-
for true {
693-
aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{})
694-
if err != nil {
695-
fmt.Fprint(GinkgoWriter, "Error getting status")
696-
}
697-
if aw1.Status.State == arbv1.AppWrapperStateEnqueued {
698-
pass = true
699-
break
700-
}
701-
}
702-
703-
fmt.Fprintf(GinkgoWriter, "[e2e] status of AW %v.\n", aw1.Status.State)
704-
Expect(pass).To(BeTrue())
654+
Eventually(AppWrapper(context, aw.Namespace, aw.Name), 2*time.Minute).Should(WithTransform(AppWrapperState, Equal(arbv1.AppWrapperStateEnqueued)))
705655
appwrappers = append(appwrappers, aw)
706656
fmt.Fprintf(os.Stdout, "[e2e] MCAD Job Large Compute Requirement Test - Completed.\n")
707657

@@ -738,25 +688,9 @@ var _ = Describe("AppWrapper E2E Test", func() {
738688

739689
aw := createGenericDeploymentAWWithMultipleItems(context, "aw-deployment-rhc")
740690
appwrappers = append(appwrappers, aw)
741-
//time.Sleep(30 * time.Second)
742691
err1 := waitAWPodsReady(context, aw)
743692
Expect(err1).NotTo(HaveOccurred(), "Expecting pods to be ready for app wrapper: aw-deployment-rhc")
744-
aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{})
745-
Expect(err).NotTo(HaveOccurred(), "Expecting to get app wrapper status")
746-
pass := false
747-
for true {
748-
aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{})
749-
if err != nil {
750-
fmt.Fprint(GinkgoWriter, "Error getting status")
751-
}
752-
fmt.Fprintf(GinkgoWriter, "[e2e] status of AW %v.\n", aw1.Status.State)
753-
if aw1.Status.State == arbv1.AppWrapperStateRunningHoldCompletion {
754-
pass = true
755-
break
756-
}
757-
}
758-
fmt.Fprintf(GinkgoWriter, "[e2e] status of AW %v.\n", aw1.Status.State)
759-
Expect(pass).To(BeTrue())
693+
Eventually(AppWrapper(context, aw.Namespace, aw.Name), 2*time.Minute).Should(WithTransform(AppWrapperState, Equal(arbv1.AppWrapperStateRunningHoldCompletion)))
760694
fmt.Fprintf(os.Stdout, "[e2e] MCAD Deployment RuningHoldCompletion Test - Completed. Awaiting app wrapper cleanup.\n")
761695
})
762696

@@ -768,26 +702,9 @@ var _ = Describe("AppWrapper E2E Test", func() {
768702
defer cleanupTestObjectsPtr(context, appwrappersPtr)
769703

770704
aw := createGenericServiceAWWithNoStatus(context, appendRandomString("aw-deployment-2-status"))
771-
//ßtime.Sleep(1 * time.Minute)
772705
err1 := waitAWPodsReady(context, aw)
773706
Expect(err1).NotTo(HaveOccurred())
774-
aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{})
775-
if err != nil {
776-
fmt.Fprintf(GinkgoWriter, "Error getting status, %v", err)
777-
}
778-
pass := false
779-
for true {
780-
aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{})
781-
if err != nil {
782-
fmt.Fprintf(GinkgoWriter, "Error getting status, %v", err)
783-
}
784-
if aw1.Status.State == arbv1.AppWrapperStateActive {
785-
pass = true
786-
break
787-
}
788-
}
789-
fmt.Fprintf(GinkgoWriter, "[e2e] status of AW %v.\n", aw1.Status.State)
790-
Expect(pass).To(BeTrue())
707+
Eventually(AppWrapper(context, aw.Namespace, aw.Name), 2*time.Minute).Should(WithTransform(AppWrapperState, Equal(arbv1.AppWrapperStateActive)))
791708
appwrappers = append(appwrappers, aw)
792709
fmt.Fprintf(os.Stdout, "[e2e] MCAD Service no RuningHoldCompletion or Complete Test - Completed.\n")
793710

test/e2e/util.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"time"
2727

2828
. "github.com/onsi/ginkgo"
29+
"github.com/onsi/gomega"
2930
. "github.com/onsi/gomega"
3031

3132
v1 "k8s.io/api/core/v1"
@@ -2691,3 +2692,15 @@ func appendRandomString(value string) string {
26912692
}
26922693
return fmt.Sprintf("%s-%s", value, string(b))
26932694
}
2695+
2696+
func AppWrapper(context *context, namespace string, name string) func(g gomega.Gomega) *arbv1.AppWrapper {
2697+
return func(g gomega.Gomega) *arbv1.AppWrapper {
2698+
aw, err := context.karclient.McadV1beta1().AppWrappers(namespace).Get(context.ctx, name, metav1.GetOptions{})
2699+
g.Expect(err).NotTo(gomega.HaveOccurred())
2700+
return aw
2701+
}
2702+
}
2703+
2704+
func AppWrapperState(aw *arbv1.AppWrapper) arbv1.AppWrapperState {
2705+
return aw.Status.State
2706+
}

0 commit comments

Comments
 (0)