Skip to content

Commit f4188c8

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 0648506 commit f4188c8

File tree

3 files changed

+142
-44
lines changed

3 files changed

+142
-44
lines changed

Makefile

Lines changed: 11 additions & 3 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
@@ -104,7 +104,7 @@ test: manifests generate fmt vet test-unit test-e2e #HELP Run all tests.
104104

105105
.PHONY: e2e
106106
FOCUS := $(if $(TEST),-v -focus "$(TEST)")
107-
E2E_FLAGS ?= ""
107+
E2E_FLAGS ?= --label-filter="!ForceSemverUpgradeConstraints=false"
108108
e2e: $(GINKGO) #EXHELP Run the e2e tests.
109109
$(GINKGO) --tags $(GO_BUILD_TAGS) $(E2E_FLAGS) -trace -progress $(FOCUS) test/e2e
110110

@@ -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) build $(TESTDATA_DIR)/bundles/registry-v1/prometheus-operator.v0.65.1 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0
160+
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/bundles/registry-v1/prometheus-operator.v0.65.1 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.1
161+
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/bundles/registry-v1/prometheus-operator.v0.65.1 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v1.2.0
162+
$(CONTAINER_RUNTIME) build $(TESTDATA_DIR)/bundles/registry-v1/prometheus-operator.v0.65.1 -t 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: 83 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")
@@ -174,48 +174,90 @@ var _ = Describe("Operator Install", func() {
174174
}).Should(Succeed())
175175
})
176176

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

194-
By("updating the Operator resource to a non-successor version")
195-
operator.Spec.Version = "0.65.1" // current (0.37.0) and successor (0.47.0) are the only values that would be SAT.
196-
Expect(c.Update(ctx, operator)).To(Succeed())
197-
By("eventually reporting an unsatisfiable resolution")
198-
Eventually(func(g Gomega) {
199-
g.Expect(c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)).To(Succeed())
200-
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved)
201-
g.Expect(cond).ToNot(BeNil())
202-
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonResolutionFailed))
203-
g.Expect(cond.Message).To(MatchRegexp(`^constraints not satisfiable:.*; installed package prometheus requires at least one of.*0.47.0[^,]*,[^,]*0.37.0[^;]*;.*`))
204-
g.Expect(operator.Status.ResolvedBundleResource).To(BeEmpty())
205-
}).Should(Succeed())
196+
When("using legacy upgrade edge constraints from OLMv0", Label("ForceSemverUpgradeConstraints=false"), func() {
197+
It("does not allow to upgrade the Operator to a non-successor version", func() {
198+
By("updating the Operator resource to a non-successor version")
199+
operator.Spec.Version = "1.2.0" // current (1.0.0) and successor (1.0.1) are the only values that would be SAT.
200+
Expect(c.Update(ctx, operator)).To(Succeed())
201+
By("eventually reporting an unsatisfiable resolution")
202+
Eventually(func(g Gomega) {
203+
g.Expect(c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)).To(Succeed())
204+
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved)
205+
g.Expect(cond).ToNot(BeNil())
206+
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonResolutionFailed))
207+
g.Expect(cond.Message).To(MatchRegexp(`^constraints not satisfiable:.*; installed package prometheus requires at least one of.*1.0.1[^,]*,[^,]*1.0.0[^;]*;.*`))
208+
g.Expect(operator.Status.ResolvedBundleResource).To(BeEmpty())
209+
}).Should(Succeed())
210+
})
211+
212+
It("does allow to upgrade the Operator to a successor version", func() {
213+
By("updating the Operator resource to a valid upgrade edge")
214+
operator.Spec.Version = "1.0.1"
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).To(Equal("localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.1"))
224+
}).Should(Succeed())
225+
})
226+
})
206227

207-
By("updating the Operator resource to a valid upgrade edge")
208-
operator.Spec.Version = "0.47.0"
209-
Expect(c.Update(ctx, operator)).To(Succeed())
210-
By("eventually reporting a successful resolution and bundle path")
211-
Eventually(func(g Gomega) {
212-
g.Expect(c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)).To(Succeed())
213-
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved)
214-
g.Expect(cond).ToNot(BeNil())
215-
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonSuccess))
216-
g.Expect(cond.Message).To(ContainSubstring("resolved to"))
217-
g.Expect(operator.Status.ResolvedBundleResource).ToNot(BeEmpty())
218-
}).Should(Succeed())
228+
When("using semver upgrade edge constraints", Label("ForceSemverUpgradeConstraints=true"), func() {
229+
It("does not allow to upgrade the Operator to a non-successor version", func() {
230+
By("updating the Operator resource to a non-successor version")
231+
// Semver only allows upgrades within major version at the moment.
232+
operator.Spec.Version = "2.0.0"
233+
Expect(c.Update(ctx, operator)).To(Succeed())
234+
By("eventually reporting an unsatisfiable resolution")
235+
Eventually(func(g Gomega) {
236+
g.Expect(c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)).To(Succeed())
237+
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved)
238+
g.Expect(cond).ToNot(BeNil())
239+
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonResolutionFailed))
240+
g.Expect(cond.Message).To(MatchRegexp(`^constraints not satisfiable:.*; installed package prometheus requires at least one of.*1.2.0[^;]*;.*`))
241+
g.Expect(operator.Status.ResolvedBundleResource).To(BeEmpty())
242+
}).Should(Succeed())
243+
})
244+
245+
It("does allow to upgrade the Operator to any of the successor versions within non-zero major version", func() {
246+
By("updating the Operator resource by skipping versions")
247+
// Test catalog has versions between the initial version and new version
248+
operator.Spec.Version = "1.2.0"
249+
Expect(c.Update(ctx, operator)).To(Succeed())
250+
By("eventually reporting a successful resolution and bundle path")
251+
Eventually(func(g Gomega) {
252+
g.Expect(c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator)).To(Succeed())
253+
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorv1alpha1.TypeResolved)
254+
g.Expect(cond).ToNot(BeNil())
255+
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonSuccess))
256+
g.Expect(cond.Message).To(ContainSubstring("resolved to"))
257+
g.Expect(operator.Status.ResolvedBundleResource).To(Equal("localhost/testdata/bundles/registry-v1/prometheus-operator:v1.2.0"))
258+
}).Should(Succeed())
259+
})
260+
})
219261
})
220262

221263
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)