@@ -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 () {
0 commit comments