Skip to content

Commit 1e8ed0a

Browse files
author
Mikalai Radchuk
committed
Update E2E
* Add tests for semver upgrades * Label semver and legacy tests so it is possible to filter one or the other out * Update Makefile to no run legacy tests by default to match default deployment of operator-controller Signed-off-by: Mikalai Radchuk <[email protected]>
1 parent c885b70 commit 1e8ed0a

File tree

3 files changed

+107
-43
lines changed

3 files changed

+107
-43
lines changed

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export XDG_DATA_HOME ?= /tmp/.local/share
2020
include .bingo/Variables.mk
2121

2222
# ARTIFACT_PATH is the absolute path to the directory where the operator-controller e2e tests will store the artifacts
23-
# for example: ARTIFACT_PATH=/tmp/artifacts make test
24-
export ARTIFACT_PATH ?=
23+
# for example: ARTIFACT_PATH=/tmp/artifacts make test
24+
export ARTIFACT_PATH ?=
2525

2626
OPERATOR_CONTROLLER_NAMESPACE ?= operator-controller-system
2727
KIND_CLUSTER_NAME ?= operator-controller
@@ -156,11 +156,19 @@ kind-load-test-artifacts: $(KIND) #EXHELP Load the e2e testdata container images
156156
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/bundles/registry-v1/prometheus-operator.v0.37.0 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v0.37.0
157157
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/bundles/registry-v1/prometheus-operator.v0.47.0 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v0.47.0
158158
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/bundles/registry-v1/prometheus-operator.v0.65.1 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v0.65.1
159+
$(CONTAINER_RUNTIME) tag localhost/testdata/bundles/registry-v1/prometheus-operator:v0.65.1 localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0
160+
$(CONTAINER_RUNTIME) tag localhost/testdata/bundles/registry-v1/prometheus-operator:v0.65.1 localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.1
161+
$(CONTAINER_RUNTIME) tag localhost/testdata/bundles/registry-v1/prometheus-operator:v0.65.1 localhost/testdata/bundles/registry-v1/prometheus-operator:v1.2.0
162+
$(CONTAINER_RUNTIME) tag localhost/testdata/bundles/registry-v1/prometheus-operator:v0.65.1 localhost/testdata/bundles/registry-v1/prometheus-operator:v2.0.0
159163
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/bundles/plain-v0/plain.v0.1.0 -t localhost/testdata/bundles/plain-v0/plain:v0.1.0
160164
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/catalogs -f $(TESTDATA_DIR)/catalogs/test-catalog.Dockerfile -t localhost/testdata/catalogs/test-catalog:e2e
161165
$(KIND) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v0.37.0 --name $(KIND_CLUSTER_NAME)
162166
$(KIND) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v0.47.0 --name $(KIND_CLUSTER_NAME)
163167
$(KIND) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v0.65.1 --name $(KIND_CLUSTER_NAME)
168+
$(KIND) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0 --name $(KIND_CLUSTER_NAME)
169+
$(KIND) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.1 --name $(KIND_CLUSTER_NAME)
170+
$(KIND) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v1.2.0 --name $(KIND_CLUSTER_NAME)
171+
$(KIND) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v2.0.0 --name $(KIND_CLUSTER_NAME)
164172
$(KIND) load docker-image localhost/testdata/bundles/plain-v0/plain:v0.1.0 --name $(KIND_CLUSTER_NAME)
165173
$(KIND) load docker-image localhost/testdata/catalogs/test-catalog:e2e --name $(KIND_CLUSTER_NAME)
166174

test/e2e/install_test.go

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ var _ = Describe("Operator Install", func() {
6767
g.Expect(cond.Status).To(Equal(metav1.ConditionTrue))
6868
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonSuccess))
6969
g.Expect(cond.Message).To(ContainSubstring("resolved to"))
70-
g.Expect(operator.Status.ResolvedBundleResource).To(Equal("localhost/testdata/bundles/registry-v1/prometheus-operator:v0.65.1"))
70+
g.Expect(operator.Status.ResolvedBundleResource).To(Equal("localhost/testdata/bundles/registry-v1/prometheus-operator:v2.0.0"))
7171
}).Should(Succeed())
7272

7373
By("eventually installing the package successfully")
@@ -180,48 +180,56 @@ var _ = Describe("Operator Install", func() {
180180
}).Should(Succeed())
181181
})
182182

183-
It("handles upgrade edges correctly", func() {
184-
By("creating a valid Operator resource")
185-
operator.Spec = operatorv1alpha1.OperatorSpec{
186-
PackageName: "prometheus",
187-
Version: "0.37.0",
188-
}
189-
Expect(c.Create(ctx, operator)).To(Succeed())
190-
By("eventually reporting a successful resolution")
191-
Eventually(func(g Gomega) {
192-
g.Expect(c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)).To(Succeed())
193-
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved)
194-
g.Expect(cond).ToNot(BeNil())
195-
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonSuccess))
196-
g.Expect(cond.Message).To(ContainSubstring("resolved to"))
197-
g.Expect(operator.Status.ResolvedBundleResource).ToNot(BeEmpty())
198-
}).Should(Succeed())
183+
When("resolving upgrade edges", func() {
184+
BeforeEach(func() {
185+
By("creating an Operator at a specified version")
186+
operator.Spec = operatorv1alpha1.OperatorSpec{
187+
PackageName: "prometheus",
188+
Version: "1.0.0",
189+
}
190+
Expect(c.Create(ctx, operator)).To(Succeed())
191+
By("eventually reporting a successful 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.ReasonSuccess))
197+
g.Expect(cond.Message).To(ContainSubstring("resolved to"))
198+
g.Expect(operator.Status.ResolvedBundleResource).To(Equal("localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0"))
199+
}).Should(Succeed())
200+
})
199201

200-
By("updating the Operator resource to a non-successor version")
201-
operator.Spec.Version = "0.65.1" // current (0.37.0) and successor (0.47.0) are the only values that would be SAT.
202-
Expect(c.Update(ctx, operator)).To(Succeed())
203-
By("eventually reporting an unsatisfiable resolution")
204-
Eventually(func(g Gomega) {
205-
g.Expect(c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)).To(Succeed())
206-
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved)
207-
g.Expect(cond).ToNot(BeNil())
208-
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonResolutionFailed))
209-
g.Expect(cond.Message).To(MatchRegexp(`^constraints not satisfiable:.*; installed package prometheus requires at least one of.*0.47.0[^,]*,[^,]*0.37.0[^;]*;.*`))
210-
g.Expect(operator.Status.ResolvedBundleResource).To(BeEmpty())
211-
}).Should(Succeed())
202+
It("does not allow to upgrade the Operator to a non-successor version", func() {
203+
By("updating the Operator resource to a non-successor version")
204+
// Semver only allows upgrades within major version at the moment.
205+
operator.Spec.Version = "2.0.0"
206+
Expect(c.Update(ctx, operator)).To(Succeed())
207+
By("eventually reporting an unsatisfiable resolution")
208+
Eventually(func(g Gomega) {
209+
g.Expect(c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)).To(Succeed())
210+
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved)
211+
g.Expect(cond).ToNot(BeNil())
212+
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonResolutionFailed))
213+
g.Expect(cond.Message).To(MatchRegexp(`^constraints not satisfiable:.*; installed package prometheus requires at least one of.*1.2.0[^;]*;.*`))
214+
g.Expect(operator.Status.ResolvedBundleResource).To(BeEmpty())
215+
}).Should(Succeed())
216+
})
212217

213-
By("updating the Operator resource to a valid upgrade edge")
214-
operator.Spec.Version = "0.47.0"
215-
Expect(c.Update(ctx, operator)).To(Succeed())
216-
By("eventually reporting a successful resolution and bundle path")
217-
Eventually(func(g Gomega) {
218-
g.Expect(c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)).To(Succeed())
219-
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved)
220-
g.Expect(cond).ToNot(BeNil())
221-
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonSuccess))
222-
g.Expect(cond.Message).To(ContainSubstring("resolved to"))
223-
g.Expect(operator.Status.ResolvedBundleResource).ToNot(BeEmpty())
224-
}).Should(Succeed())
218+
It("does allow to upgrade the Operator to any of the successor versions within non-zero major version", func() {
219+
By("updating the Operator resource by skipping versions")
220+
// Test catalog has versions between the initial version and new version
221+
operator.Spec.Version = "1.2.0"
222+
Expect(c.Update(ctx, operator)).To(Succeed())
223+
By("eventually reporting a successful resolution and bundle path")
224+
Eventually(func(g Gomega) {
225+
g.Expect(c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)).To(Succeed())
226+
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved)
227+
g.Expect(cond).ToNot(BeNil())
228+
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonSuccess))
229+
g.Expect(cond.Message).To(ContainSubstring("resolved to"))
230+
g.Expect(operator.Status.ResolvedBundleResource).To(Equal("localhost/testdata/bundles/registry-v1/prometheus-operator:v1.2.0"))
231+
}).Should(Succeed())
232+
})
225233
})
226234

227235
AfterEach(func() {

testdata/catalogs/test-catalog/catalog.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ entries:
1818
replaces: prometheus-operator.0.37.0
1919
- name: prometheus-operator.0.65.1
2020
replaces: prometheus-operator.0.47.0
21+
- name: prometheus-operator.1.0.0
22+
replaces: prometheus-operator.0.65.1
23+
- name: prometheus-operator.1.0.1
24+
replaces: prometheus-operator.1.0.0
25+
- name: prometheus-operator.1.2.0
26+
replaces: prometheus-operator.1.0.1
27+
- name: prometheus-operator.2.0.0
28+
replaces: prometheus-operator.1.2.0
2129
---
2230
schema: olm.bundle
2331
name: prometheus-operator.0.37.0
@@ -49,6 +57,46 @@ properties:
4957
packageName: prometheus
5058
version: 0.65.1
5159
---
60+
schema: olm.bundle
61+
name: prometheus-operator.1.0.0
62+
package: prometheus
63+
image: localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0
64+
properties:
65+
- type: olm.package
66+
value:
67+
packageName: prometheus
68+
version: 1.0.0
69+
---
70+
schema: olm.bundle
71+
name: prometheus-operator.1.0.1
72+
package: prometheus
73+
image: localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.1
74+
properties:
75+
- type: olm.package
76+
value:
77+
packageName: prometheus
78+
version: 1.0.1
79+
---
80+
schema: olm.bundle
81+
name: prometheus-operator.1.2.0
82+
package: prometheus
83+
image: localhost/testdata/bundles/registry-v1/prometheus-operator:v1.2.0
84+
properties:
85+
- type: olm.package
86+
value:
87+
packageName: prometheus
88+
version: 1.2.0
89+
---
90+
schema: olm.bundle
91+
name: prometheus-operator.2.0.0
92+
package: prometheus
93+
image: localhost/testdata/bundles/registry-v1/prometheus-operator:v2.0.0
94+
properties:
95+
- type: olm.package
96+
value:
97+
packageName: prometheus
98+
version: 2.0.0
99+
---
52100
schema: olm.package
53101
name: plain
54102
defaultChannel: beta

0 commit comments

Comments
 (0)