Skip to content

Commit 700d282

Browse files
authored
Improve reliability of e2e tests that include GRPC CatalogSources (#2419)
This commit introduces a change to the e2e tests that rely on a grpc catalogSource that is stored in an off cluster registry. These tests originally required that the following happen within a minute: 1. The catalogSource is installed and ready to serve. 2. The contents of the bundle are unpacked and placed in an installPlan. 3. The CSV is installed and in the ready state. The tests will now wait for the catalogSource to be ready to serve before moving onto steps 2 and 3. Signed-off-by: Alexander Greene <[email protected]>
1 parent 4c3c8f1 commit 700d282

8 files changed

+48
-1
lines changed

test/e2e/bundle_e2e_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ var _ = Describe("Installing bundles with new object types", func() {
106106
return err
107107
}).Should(Succeed())
108108

109+
// Wait for the CatalogSource to be ready
110+
_, err = fetchCatalogSourceOnStatus(operatorClient, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced)
111+
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
112+
109113
// Create a Subscription for package
110114
_ = createSubscriptionForCatalog(operatorClient, source.GetNamespace(), subName, source.GetName(), packageName, channelName, "", v1alpha1.ApprovalAutomatic)
111115

test/e2e/catalog_e2e_test.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,10 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
482482
Expect(err).ShouldNot(HaveOccurred())
483483
}()
484484

485+
// Wait for the CatalogSource to be ready
486+
_, err = fetchCatalogSourceOnStatus(crc, addressSource.GetName(), addressSource.GetNamespace(), catalogSourceRegistryPodSynced)
487+
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
488+
485489
// Delete CatalogSources
486490
err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Delete(context.TODO(), mainSourceName, metav1.DeleteOptions{})
487491
Expect(err).ShouldNot(HaveOccurred())
@@ -892,6 +896,10 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
892896
Expect(err).ShouldNot(HaveOccurred())
893897
}()
894898

899+
// Wait for the CatalogSource to be ready
900+
_, err = fetchCatalogSourceOnStatus(crc, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced)
901+
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
902+
895903
// Create a Subscription for busybox
896904
subscriptionName := genName("sub-")
897905
cleanupSubscription := createSubscriptionForCatalog(crc, source.GetNamespace(), subscriptionName, source.GetName(), packageName, channelName, "", v1alpha1.ApprovalAutomatic)
@@ -935,6 +943,10 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
935943
return false, nil
936944
}).Should(BeTrue())
937945

946+
// Wait for the CatalogSource to be ready
947+
_, err = fetchCatalogSourceOnStatus(crc, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced)
948+
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
949+
938950
// Wait for the busybox v2 Subscription to succeed
939951
subChecker := func(sub *v1alpha1.Subscription) bool {
940952
return sub.Status.InstalledCSV == "busybox.v2.0.0"
@@ -1065,7 +1077,6 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
10651077
Expect(err).ShouldNot(HaveOccurred(), "error getting catalog source")
10661078

10671079
// create an annotation using the kube templates
1068-
10691080
source.SetAnnotations(map[string]string{catalogsource.CatalogImageTemplateAnnotation: fmt.Sprintf("quay.io/olmtest/catsrc-update-test:%s.%s.%s", catalogsource.TemplKubeMajorV, catalogsource.TemplKubeMinorV, catalogsource.TemplKubePatchV)})
10701081

10711082
// Update the catalog image

test/e2e/gc_e2e_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ var _ = Describe("Garbage collection for dependent resources", func() {
358358
return nil
359359
}).Should(Succeed(), "could not create catalog source")
360360

361+
// Wait for the CatalogSource to be ready
362+
_, err := fetchCatalogSourceOnStatus(operatorClient, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced)
363+
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
364+
361365
// Create a Subscription for package
362366
_ = createSubscriptionForCatalog(operatorClient, source.GetNamespace(), subName, source.GetName(), packageName, channelName, "", v1alpha1.ApprovalAutomatic)
363367

@@ -468,6 +472,10 @@ var _ = Describe("Garbage collection for dependent resources", func() {
468472
return err
469473
}).Should(Succeed(), "could not create catalog source")
470474

475+
// Wait for the CatalogSource to be ready
476+
_, err = fetchCatalogSourceOnStatus(operatorClient, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced)
477+
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
478+
471479
// Create a Subscription for package
472480
_ = createSubscriptionForCatalog(operatorClient, source.GetNamespace(), subName, source.GetName(), packageName, channelName, "", v1alpha1.ApprovalAutomatic)
473481

@@ -577,6 +585,10 @@ var _ = Describe("Garbage collection for dependent resources", func() {
577585
return err
578586
}).Should(Succeed())
579587

588+
// Wait for the CatalogSource to be ready
589+
_, err = fetchCatalogSourceOnStatus(operatorClient, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced)
590+
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
591+
580592
// Create a Subscription for package
581593
_ = createSubscriptionForCatalog(operatorClient, source.GetNamespace(), subName, source.GetName(), packageName, channelName, "", v1alpha1.ApprovalAutomatic)
582594

test/e2e/operator_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ var _ = Describe("Operator API", func() {
274274
return client.Create(clientCtx, cs)
275275
}).Should(Succeed())
276276

277+
// Wait for the CatalogSource to be ready
278+
_, err := fetchCatalogSourceOnStatus(newCRClient(), cs.GetName(), cs.GetNamespace(), catalogSourceRegistryPodSynced)
279+
Expect(err).ToNot(HaveOccurred())
280+
277281
sub = &operatorsv1alpha1.Subscription{
278282
Spec: &operatorsv1alpha1.SubscriptionSpec{
279283
CatalogSource: cs.GetName(),

test/e2e/packagemanifest_e2e_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ var _ = Describe("Package Manifest API lists available Operators from Catalog So
217217
var err error
218218
catalogSource, err = crc.OperatorsV1alpha1().CatalogSources(catalogSource.GetNamespace()).Create(context.TODO(), catalogSource, metav1.CreateOptions{})
219219
Expect(err).NotTo(HaveOccurred())
220+
221+
// Wait for the CatalogSource to be ready
222+
_, err = fetchCatalogSourceOnStatus(crc, catalogSource.GetName(), catalogSource.GetNamespace(), catalogSourceRegistryPodSynced)
223+
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
220224
})
221225

222226
AfterEach(func() {

test/e2e/subscription_e2e_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,10 @@ var _ = Describe("Subscription", func() {
847847
Expect(err).ToNot(HaveOccurred())
848848
}()
849849

850+
// Wait for the CatalogSource status to be updated to reflect its invalid spec
851+
_, err = fetchCatalogSourceOnStatus(crc, cs.GetName(), cs.GetNamespace(), catalogSourceInvalidSpec)
852+
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
853+
850854
subName := genName("sub-")
851855
cleanup := createSubscriptionForCatalog(
852856
crc,

test/e2e/util_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ func catalogSourceRegistryPodSynced(catalog *v1alpha1.CatalogSource) bool {
325325
return false
326326
}
327327

328+
func catalogSourceInvalidSpec(catalog *v1alpha1.CatalogSource) bool {
329+
return catalog.Status.Reason == v1alpha1.CatalogSourceSpecInvalidError
330+
}
331+
328332
func fetchCatalogSourceOnStatus(crc versioned.Interface, name, namespace string, check catalogSourceCheckFunc) (*v1alpha1.CatalogSource, error) {
329333
var fetched *v1alpha1.CatalogSource
330334
var err error

test/e2e/webhook_e2e_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,10 @@ var _ = Describe("CSVs with a Webhook", func() {
673673
require.NoError(GinkgoT(), crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Delete(context.TODO(), source.GetName(), metav1.DeleteOptions{}))
674674
}
675675

676+
// Wait for the CatalogSource to be ready
677+
_, err = fetchCatalogSourceOnStatus(crc, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced)
678+
require.NoError(GinkgoT(), err)
679+
676680
// Create a Subscription for the webhook-operator
677681
subscriptionName := genName("sub-")
678682
cleanupSubscription := createSubscriptionForCatalog(crc, testNamespace, subscriptionName, source.GetName(), packageName, channelName, "", operatorsv1alpha1.ApprovalAutomatic)

0 commit comments

Comments
 (0)