Skip to content

Commit ade957c

Browse files
committed
wip
1 parent b03d9ef commit ade957c

File tree

2 files changed

+71
-2
lines changed

2 files changed

+71
-2
lines changed

test/e2e/install_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var _ = Describe("Operator Install", func() {
3939
BeforeEach(func() {
4040
operator.Spec = operatorv1alpha1.OperatorSpec{
4141
PackageName: "prometheus",
42+
Version: "0.47.0",
4243
}
4344
})
4445
It("resolves the specified package with correct bundle path", func() {
@@ -167,6 +168,50 @@ var _ = Describe("Operator Install", func() {
167168
}).Should(Succeed())
168169
})
169170

171+
It("handles upgrade edges correctly", func() {
172+
By("creating a valid Operator resource")
173+
operator.Spec = operatorv1alpha1.OperatorSpec{
174+
PackageName: "prometheus",
175+
Version: "0.37.0",
176+
}
177+
Expect(c.Create(ctx, operator)).To(Succeed())
178+
By("eventually reporting a successful resolution")
179+
Eventually(func(g Gomega) {
180+
g.Expect(c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)).To(Succeed())
181+
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved)
182+
g.Expect(cond).ToNot(BeNil())
183+
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonSuccess))
184+
g.Expect(cond.Message).To(ContainSubstring("resolved to"))
185+
g.Expect(operator.Status.ResolvedBundleResource).ToNot(BeEmpty())
186+
}).Should(Succeed())
187+
188+
By("updating the Operator resource to an invalid version")
189+
operator.Spec.Version = "0.65.1" // the correct one should be 0.47.0
190+
Expect(c.Update(ctx, operator)).To(Succeed())
191+
By("eventually reporting a failed resolution")
192+
Eventually(func(g Gomega) {
193+
g.Expect(c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)).To(Succeed())
194+
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved)
195+
g.Expect(cond).ToNot(BeNil())
196+
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonResolutionFailed))
197+
g.Expect(cond.Message).To(ContainSubstring("entity for package \"prometheus\" not found in solutio"))
198+
g.Expect(operator.Status.ResolvedBundleResource).To(BeEmpty())
199+
}).Should(Succeed())
200+
201+
By("updating the Operator resource to a valid upgrade edge")
202+
operator.Spec.Version = "0.47.0"
203+
Expect(c.Update(ctx, operator)).To(Succeed())
204+
By("eventually reporting a successful resolution and bundle path")
205+
Eventually(func(g Gomega) {
206+
g.Expect(c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)).To(Succeed())
207+
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved)
208+
g.Expect(cond).ToNot(BeNil())
209+
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonSuccess))
210+
g.Expect(cond.Message).To(ContainSubstring("resolved to"))
211+
g.Expect(operator.Status.ResolvedBundleResource).ToNot(BeEmpty())
212+
}).Should(Succeed())
213+
})
214+
170215
AfterEach(func() {
171216
Expect(c.Delete(ctx, operator)).To(Succeed())
172217
Eventually(func(g Gomega) {

testdata/catalogs/test-catalog/catalog.yaml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,24 @@ schema: olm.channel
77
name: beta
88
package: prometheus
99
entries:
10-
- name: prometheus-operator.0.47.0
10+
- name: prometheus-operator.v0.37.0
11+
- name: prometheus-operator.v0.47.0
12+
replaces: prometheus-operator.v0.37.0
13+
- name: prometheus-operator.v0.65.1
14+
replaces: prometheus-operator.v0.47.0
1115
---
1216
schema: olm.bundle
13-
name: prometheus-operator.0.47.0
17+
name: prometheus-operator.v0.37.0
18+
package: prometheus
19+
image: localhost/testdata/bundles/registry-v1/prometheus-operator:v0.37.0
20+
properties:
21+
- type: olm.package
22+
value:
23+
packageName: prometheus
24+
version: 0.37.0
25+
---
26+
schema: olm.bundle
27+
name: prometheus-operator.v0.47.0
1428
package: prometheus
1529
image: localhost/testdata/bundles/registry-v1/prometheus-operator:v0.47.0
1630
properties:
@@ -19,6 +33,16 @@ properties:
1933
packageName: prometheus
2034
version: 0.47.0
2135
---
36+
schema: olm.bundle
37+
name: prometheus-operator.v0.65.1
38+
package: prometheus
39+
image: localhost/testdata/bundles/registry-v1/prometheus-operator:v0.65.1
40+
properties:
41+
- type: olm.package
42+
value:
43+
packageName: prometheus
44+
version: 0.65.1
45+
---
2246
schema: olm.package
2347
name: plain
2448
defaultChannel: beta

0 commit comments

Comments
 (0)