Skip to content

Commit 1bc3766

Browse files
committed
Move CatalogSource tests to use e2e client
Signed-off-by: perdasilva <[email protected]>
1 parent 15d61cc commit 1bc3766

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Diff for: test/e2e/catalog_e2e_test.go

+14-9
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
4141
crc versioned.Interface
4242
ns corev1.Namespace
4343
)
44+
4445
BeforeEach(func() {
4546
c = newKubeClient()
4647
crc = newCRClient()
48+
// Create a new e2e kube client session tracking and tagging created resources
49+
ctx.Ctx().NewClientSession()
50+
4751
namespaceName := genName("catsrc-e2e-")
4852
og := operatorsv1.OperatorGroup{
4953
ObjectMeta: metav1.ObjectMeta{
@@ -56,6 +60,9 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
5660

5761
AfterEach(func() {
5862
TeardownNamespace(ns.GetName())
63+
64+
// Tear down e2e client and thereby any test resources created with it
65+
Expect(ctx.Ctx().EndClientSession()).To(Succeed())
5966
})
6067

6168
It("loading between restarts", func() {
@@ -496,7 +503,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
496503
},
497504
}
498505

499-
addressSource, err = crc.OperatorsV1alpha1().CatalogSources(ns.GetName()).Create(context.Background(), addressSource, metav1.CreateOptions{})
506+
err = ctx.Ctx().E2EClient().Create(context.TODO(), addressSource)
500507
Expect(err).ShouldNot(HaveOccurred())
501508
defer func() {
502509
err := crc.OperatorsV1alpha1().CatalogSources(ns.GetName()).Delete(context.Background(), addressSourceName, metav1.DeleteOptions{})
@@ -622,7 +629,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
622629
},
623630
}
624631

625-
source, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.Background(), source, metav1.CreateOptions{})
632+
err := ctx.Ctx().E2EClient().Create(context.TODO(), source)
626633
Expect(err).ShouldNot(HaveOccurred())
627634

628635
// Wait for a new registry pod to be created
@@ -757,7 +764,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
757764
},
758765
}
759766

760-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.Background(), source, metav1.CreateOptions{})
767+
err = ctx.Ctx().E2EClient().Create(context.TODO(), source)
761768
Expect(err).ShouldNot(HaveOccurred())
762769
defer func() {
763770
err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Delete(context.Background(), source.GetName(), metav1.DeleteOptions{})
@@ -914,7 +921,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
914921
},
915922
}
916923

917-
source, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.Background(), source, metav1.CreateOptions{})
924+
err := ctx.Ctx().E2EClient().Create(context.TODO(), source)
918925
Expect(err).ShouldNot(HaveOccurred())
919926
defer func() {
920927
err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Delete(context.Background(), source.GetName(), metav1.DeleteOptions{})
@@ -1004,9 +1011,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
10041011
// a) the new update pod is spun up roughly in line with the registry polling interval
10051012
// b) the update pod is removed quickly when the image is found to not have changed
10061013
// This is more of a behavioral test that ensures the feature is working as designed.
1007-
10081014
c := newKubeClient()
1009-
crc := newCRClient()
10101015

10111016
sourceName := genName("catalog-")
10121017
source := &v1alpha1.CatalogSource{
@@ -1030,7 +1035,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
10301035
},
10311036
}
10321037

1033-
source, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.Background(), source, metav1.CreateOptions{})
1038+
err := ctx.Ctx().E2EClient().Create(context.TODO(), source)
10341039
Expect(err).ToNot(HaveOccurred())
10351040

10361041
// wait for new catalog source pod to be created and report ready
@@ -1095,7 +1100,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
10951100

10961101
var err error
10971102
Eventually(func() error {
1098-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.Background(), source, metav1.CreateOptions{})
1103+
err := ctx.Ctx().E2EClient().Create(context.TODO(), source)
10991104
return err
11001105
}).Should(Succeed())
11011106

@@ -1221,7 +1226,7 @@ func replicateCatalogPod(c operatorclient.ClientInterface, catalog *v1alpha1.Cat
12211226
Spec: pod.Spec,
12221227
}
12231228

1224-
copied, err = c.KubernetesInterface().CoreV1().Pods(catalog.GetNamespace()).Create(context.Background(), copied, metav1.CreateOptions{})
1229+
err = ctx.Ctx().E2EClient().Create(context.TODO(), copied)
12251230
Expect(err).ToNot(HaveOccurred())
12261231

12271232
return copied

0 commit comments

Comments
 (0)