Skip to content

Commit ce48991

Browse files
committed
e2e tests for catalog watch
Signed-off-by: Ankita Thomas <ankithom@redhat.com>
1 parent 36e39bf commit ce48991

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

test/e2e/install_test.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,75 @@ var _ = Describe("Operator Install", func() {
9696
g.Expect(bd.Status.Conditions[0].Reason).To(Equal("UnpackSuccessful"))
9797
g.Expect(bd.Status.Conditions[1].Reason).To(Equal("InstallationSucceeded"))
9898
}).WithTimeout(defaultTimeout).WithPolling(defaultPoll).Should(Succeed())
99+
})
100+
AfterEach(func() {
101+
err := c.Delete(ctx, operatorCatalog)
102+
Expect(err).ToNot(HaveOccurred())
103+
err = c.Delete(ctx, operator)
104+
Expect(err).ToNot(HaveOccurred())
105+
})
106+
})
107+
When("resolving for an unavailable operator package", func() {
108+
BeforeEach(func() {
109+
ctx = context.Background()
110+
pkgName = "argocd-operator"
111+
operatorName = fmt.Sprintf("operator-%s", rand.String(8))
112+
operator = &operatorv1alpha1.Operator{
113+
ObjectMeta: metav1.ObjectMeta{
114+
Name: operatorName,
115+
},
116+
Spec: operatorv1alpha1.OperatorSpec{
117+
PackageName: pkgName,
118+
},
119+
}
120+
operatorCatalog = &catalogd.CatalogSource{
121+
ObjectMeta: metav1.ObjectMeta{
122+
Name: "test-catalog",
123+
},
124+
Spec: catalogd.CatalogSourceSpec{
125+
// (TODO): Set up a local image registry, and build and store a test catalog in it
126+
// to use in the test suite
127+
Image: "quay.io/operatorhubio/catalog:latest",
128+
},
129+
}
130+
})
131+
132+
It("resolves again when a new catalog is available", func() {
133+
By("creating the Operator resource")
134+
err := c.Create(ctx, operator)
135+
Expect(err).ToNot(HaveOccurred())
136+
137+
By("failing to find Operator during resolution")
138+
Eventually(func(g Gomega) {
139+
err = c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)
140+
g.Expect(err).ToNot(HaveOccurred())
141+
g.Expect(len(operator.Status.Conditions)).To(Equal(2))
142+
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved)
143+
g.Expect(cond).ToNot(BeNil())
144+
g.Expect(cond.Status).To(Equal(metav1.ConditionFalse))
145+
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonResolutionFailed))
146+
g.Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' not found", pkgName)))
147+
}).WithTimeout(defaultTimeout).WithPolling(defaultPoll).Should(Succeed())
148+
149+
By("creating an Operator catalog with the desired package")
150+
err = c.Create(ctx, operatorCatalog)
151+
Expect(err).ToNot(HaveOccurred())
152+
Eventually(func(g Gomega) {
153+
err = c.Get(ctx, types.NamespacedName{Name: "test-catalog"}, operatorCatalog)
154+
g.Expect(err).ToNot(HaveOccurred())
155+
g.Expect(len(operatorCatalog.Status.Conditions)).To(Equal(1))
156+
g.Expect(operatorCatalog.Status.Conditions[0].Message).To(Equal("catalog contents have been unpacked and are available on cluster"))
157+
}).WithTimeout(5 * time.Minute).WithPolling(defaultPoll).Should(Succeed())
99158

159+
By("eventually installing the package successfully")
160+
Eventually(func(g Gomega) {
161+
bd := rukpakv1alpha1.BundleDeployment{}
162+
err = c.Get(ctx, types.NamespacedName{Name: operatorName}, &bd)
163+
g.Expect(err).ToNot(HaveOccurred())
164+
g.Expect(len(bd.Status.Conditions)).To(Equal(2))
165+
g.Expect(bd.Status.Conditions[0].Reason).To(Equal("UnpackSuccessful"))
166+
g.Expect(bd.Status.Conditions[1].Reason).To(Equal("InstallationSucceeded"))
167+
}).WithTimeout(defaultTimeout).WithPolling(defaultPoll).Should(Succeed())
100168
})
101169
AfterEach(func() {
102170
err := c.Delete(ctx, operatorCatalog)

0 commit comments

Comments
 (0)