Skip to content

Commit f5f6915

Browse files
Merge pull request #1636 from exdx/fix/check-installplan-e2e
fix: add installplan status check after subscription status check for gc e2e tests
2 parents 5dc2e63 + ab73318 commit f5f6915

File tree

1 file changed

+50
-20
lines changed

1 file changed

+50
-20
lines changed

test/e2e/gc_e2e_test.go

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ var _ = Describe("Garbage collection for dependent resources", func() {
298298
sourceName = "test-catalog"
299299
imageName = "quay.io/olmtest/single-bundle-index:objects"
300300
)
301+
var installPlanRef string
302+
301303
// create catalog source
302304
source := &v1alpha1.CatalogSource{
303305
TypeMeta: metav1.TypeMeta{
@@ -322,10 +324,16 @@ var _ = Describe("Garbage collection for dependent resources", func() {
322324
_ = createSubscriptionForCatalog(operatorClient, source.GetNamespace(), subName, source.GetName(), packageName, channelName, "", v1alpha1.ApprovalAutomatic)
323325

324326
// Wait for the Subscription to succeed
325-
Eventually(func() error {
326-
_, err = fetchSubscription(operatorClient, testNamespace, subName, subscriptionStateAtLatestChecker)
327-
return err
328-
}).Should(BeNil())
327+
sub, err := fetchSubscription(operatorClient, testNamespace, subName, subscriptionStateAtLatestChecker)
328+
Expect(err).ToNot(HaveOccurred(), "could not get subscription at latest status")
329+
330+
installPlanRef = sub.Status.InstallPlanRef.Name
331+
332+
// Wait for the installplan to complete (5 minute timeout)
333+
_, err = fetchInstallPlan(GinkgoT(), operatorClient, installPlanRef, buildInstallPlanPhaseCheckFunc(v1alpha1.InstallPlanPhaseComplete))
334+
Expect(err).ToNot(HaveOccurred(), "could not get installplan at complete phase")
335+
336+
ctx.Ctx().Logf("install plan %s completed", installPlanRef)
329337

330338
// confirm extra bundle objects (secret and configmap) are installed
331339
Eventually(func() error {
@@ -393,6 +401,8 @@ var _ = Describe("Garbage collection for dependent resources", func() {
393401
sourceName = "test-catalog"
394402
imageName = "quay.io/olmtest/single-bundle-index:objects-upgrade-samename"
395403
)
404+
405+
var installPlanRef string
396406
// create catalog source
397407
source := &v1alpha1.CatalogSource{
398408
TypeMeta: metav1.TypeMeta{
@@ -417,10 +427,14 @@ var _ = Describe("Garbage collection for dependent resources", func() {
417427
_ = createSubscriptionForCatalog(operatorClient, source.GetNamespace(), subName, source.GetName(), packageName, channelName, "", v1alpha1.ApprovalAutomatic)
418428

419429
// Wait for the Subscription to succeed
420-
Eventually(func() error {
421-
_, err = fetchSubscription(operatorClient, testNamespace, subName, subscriptionStateAtLatestChecker)
422-
return err
423-
}).Should(BeNil())
430+
sub, err := fetchSubscription(operatorClient, testNamespace, subName, subscriptionStateAtLatestChecker)
431+
Expect(err).ToNot(HaveOccurred(), "could not get subscription at latest status")
432+
433+
installPlanRef = sub.Status.InstallPlanRef.Name
434+
435+
// Wait for the installplan to complete (5 minute timeout)
436+
_, err = fetchInstallPlan(GinkgoT(), operatorClient, installPlanRef, buildInstallPlanPhaseCheckFunc(v1alpha1.InstallPlanPhaseComplete))
437+
Expect(err).ToNot(HaveOccurred(), "could not get installplan at complete phase")
424438

425439
Eventually(func() error {
426440
_, err := kubeClient.GetConfigMap(testNamespace, configmapName)
@@ -433,6 +447,7 @@ var _ = Describe("Garbage collection for dependent resources", func() {
433447
upgradeChannelName = "beta"
434448
newCSVname = "busybox.v3.0.0"
435449
)
450+
var installPlanRef string
436451

437452
BeforeEach(func() {
438453
// update subscription first
@@ -445,10 +460,14 @@ var _ = Describe("Garbage collection for dependent resources", func() {
445460
Expect(err).ToNot(HaveOccurred(), "could not update subscription")
446461

447462
// Wait for the Subscription to succeed
448-
Eventually(func() error {
449-
_, err = fetchSubscription(operatorClient, testNamespace, subName, subscriptionStateAtLatestChecker)
450-
return err
451-
}).Should(BeNil())
463+
sub, err = fetchSubscription(operatorClient, testNamespace, subName, subscriptionStateAtLatestChecker)
464+
Expect(err).ToNot(HaveOccurred(), "could not get subscription at latest status")
465+
466+
installPlanRef = sub.Status.InstallPlanRef.Name
467+
468+
// Wait for the installplan to complete (5 minute timeout)
469+
_, err = fetchInstallPlan(GinkgoT(), operatorClient, installPlanRef, buildInstallPlanPhaseCheckFunc(v1alpha1.InstallPlanPhaseComplete))
470+
Expect(err).ToNot(HaveOccurred(), "could not get installplan at complete phase")
452471

453472
// Ensure the new csv is installed
454473
Eventually(func() error {
@@ -485,6 +504,8 @@ var _ = Describe("Garbage collection for dependent resources", func() {
485504
sourceName = "test-catalog"
486505
imageName = "quay.io/olmtest/single-bundle-index:objects-upgrade-diffname"
487506
)
507+
508+
var installPlanRef string
488509
// create catalog source
489510
source := &v1alpha1.CatalogSource{
490511
TypeMeta: metav1.TypeMeta{
@@ -509,10 +530,14 @@ var _ = Describe("Garbage collection for dependent resources", func() {
509530
_ = createSubscriptionForCatalog(operatorClient, source.GetNamespace(), subName, source.GetName(), packageName, channelName, "", v1alpha1.ApprovalAutomatic)
510531

511532
// Wait for the Subscription to succeed
512-
Eventually(func() error {
513-
_, err = fetchSubscription(operatorClient, testNamespace, subName, subscriptionStateAtLatestChecker)
514-
return err
515-
}).Should(BeNil())
533+
sub, err := fetchSubscription(operatorClient, testNamespace, subName, subscriptionStateAtLatestChecker)
534+
Expect(err).ToNot(HaveOccurred(), "could not get subscription at latest status")
535+
536+
installPlanRef = sub.Status.InstallPlanRef.Name
537+
538+
// Wait for the installplan to complete (5 minute timeout)
539+
_, err = fetchInstallPlan(GinkgoT(), operatorClient, installPlanRef, buildInstallPlanPhaseCheckFunc(v1alpha1.InstallPlanPhaseComplete))
540+
Expect(err).ToNot(HaveOccurred(), "could not get installplan at complete phase")
516541

517542
Eventually(func() error {
518543
_, err := kubeClient.GetConfigMap(testNamespace, configmapName)
@@ -526,6 +551,7 @@ var _ = Describe("Garbage collection for dependent resources", func() {
526551
upgradedConfigMapName = "not-special-config"
527552
newCSVname = "busybox.v3.0.0"
528553
)
554+
var installPlanRef string
529555

530556
BeforeEach(func() {
531557
// update subscription first
@@ -538,10 +564,14 @@ var _ = Describe("Garbage collection for dependent resources", func() {
538564
Expect(err).ToNot(HaveOccurred(), "could not update subscription")
539565

540566
// Wait for the Subscription to succeed
541-
Eventually(func() error {
542-
_, err = fetchSubscription(operatorClient, testNamespace, subName, subscriptionStateAtLatestChecker)
543-
return err
544-
}).Should(BeNil())
567+
sub, err = fetchSubscription(operatorClient, testNamespace, subName, subscriptionStateAtLatestChecker)
568+
Expect(err).ToNot(HaveOccurred(), "could not get subscription at latest status")
569+
570+
installPlanRef = sub.Status.InstallPlanRef.Name
571+
572+
// Wait for the installplan to complete (5 minute timeout)
573+
_, err = fetchInstallPlan(GinkgoT(), operatorClient, installPlanRef, buildInstallPlanPhaseCheckFunc(v1alpha1.InstallPlanPhaseComplete))
574+
Expect(err).ToNot(HaveOccurred(), "could not get installplan at complete phase")
545575

546576
// Ensure the new csv is installed
547577
Eventually(func() error {

0 commit comments

Comments
 (0)