@@ -128,65 +128,6 @@ func TestClusterExtensionNonExistentVersion(t *testing.T) {
128
128
require .NoError (t , cl .DeleteAllOf (ctx , & ocv1alpha1.ClusterExtension {}))
129
129
}
130
130
131
- func TestClusterExtensionBundleDeploymentDoesNotExist (t * testing.T ) {
132
- t .Skip ("Skip and replace with e2e for BundleDeployment" )
133
- cl , reconciler := newClientAndReconciler (t )
134
- ctx := context .Background ()
135
- extKey := types.NamespacedName {Name : fmt .Sprintf ("cluster-extension-test-%s" , rand .String (8 ))}
136
- const pkgName = "prometheus"
137
- installNamespace := fmt .Sprintf ("test-ns-%s" , rand .String (8 ))
138
-
139
- t .Log ("When the cluster extension specifies a valid available package" )
140
- t .Log ("By initializing cluster state" )
141
- clusterExtension := & ocv1alpha1.ClusterExtension {
142
- ObjectMeta : metav1.ObjectMeta {Name : extKey .Name },
143
- Spec : ocv1alpha1.ClusterExtensionSpec {
144
- PackageName : pkgName ,
145
- InstallNamespace : installNamespace ,
146
- },
147
- }
148
- require .NoError (t , cl .Create (ctx , clusterExtension ))
149
-
150
- t .Log ("When the BundleDeployment does not exist" )
151
- t .Log ("By running reconcile" )
152
- res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : extKey })
153
- require .Equal (t , ctrl.Result {}, res )
154
- require .NoError (t , err )
155
-
156
- t .Log ("By fetching updated cluster extension after reconcile" )
157
- require .NoError (t , cl .Get (ctx , extKey , clusterExtension ))
158
-
159
- t .Log ("It results in the expected BundleDeployment" )
160
- bd := & rukpakv1alpha2.BundleDeployment {}
161
- require .NoError (t , cl .Get (ctx , types.NamespacedName {Name : extKey .Name }, bd ))
162
- require .Equal (t , "core-rukpak-io-registry" , bd .Spec .ProvisionerClassName )
163
- require .Equal (t , installNamespace , bd .Spec .InstallNamespace )
164
- require .NotNil (t , bd .Spec .Source .Image )
165
- require .
Equal (
t ,
"quay.io/operatorhubio/[email protected] " ,
bd .
Spec .
Source .
Image .
Ref )
166
-
167
- t .Log ("It sets the ResolvedBundle status field" )
168
- require .Equal (t , & ocv1alpha1.BundleMetadata {Name : "operatorhub/prometheus/beta/2.0.0" , Version : "2.0.0" }, clusterExtension .Status .ResolvedBundle )
169
-
170
- t .Log ("It sets the InstalledBundle status field" )
171
- require .Empty (t , clusterExtension .Status .InstalledBundle )
172
-
173
- t .Log ("It sets the status on the cluster extension" )
174
- cond := apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeResolved )
175
- require .NotNil (t , cond )
176
- require .Equal (t , metav1 .ConditionTrue , cond .Status )
177
- require .Equal (t , ocv1alpha1 .ReasonSuccess , cond .Reason )
178
- require .
Equal (
t ,
"resolved to \" quay.io/operatorhubio/[email protected] \" " ,
cond .
Message )
179
-
180
- cond = apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeInstalled )
181
- require .NotNil (t , cond )
182
- require .Equal (t , metav1 .ConditionUnknown , cond .Status )
183
- require .Equal (t , ocv1alpha1 .ReasonInstallationStatusUnknown , cond .Reason )
184
- require .Equal (t , "bundledeployment status is unknown" , cond .Message )
185
-
186
- verifyInvariants (ctx , t , reconciler .Client , clusterExtension )
187
- require .NoError (t , cl .DeleteAllOf (ctx , & ocv1alpha1.ClusterExtension {}))
188
- }
189
-
190
131
func TestClusterExtensionChannelVersionExists (t * testing.T ) {
191
132
cl , reconciler := newClientAndReconciler (t )
192
133
mockUnpacker := unpacker .(* MockUnpacker )
@@ -221,7 +162,7 @@ func TestClusterExtensionChannelVersionExists(t *testing.T) {
221
162
t .Log ("By running reconcile" )
222
163
res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : extKey })
223
164
require .Equal (t , ctrl.Result {}, res )
224
- require .NoError (t , err , nil )
165
+ require .NoError (t , err )
225
166
226
167
t .Log ("By fetching updated cluster extension after reconcile" )
227
168
require .NoError (t , cl .Get (ctx , extKey , clusterExtension ))
@@ -247,8 +188,13 @@ func TestClusterExtensionChannelVersionExists(t *testing.T) {
247
188
}
248
189
249
190
func TestClusterExtensionChannelExistsNoVersion (t * testing.T ) {
250
- t .Skip ("Skip and replace with e2e for BundleDeployment" )
251
191
cl , reconciler := newClientAndReconciler (t )
192
+ mockUnpacker := unpacker .(* MockUnpacker )
193
+ // Set up the Unpack method to return a result with StateUnpacked
194
+ mockUnpacker .On ("Unpack" , mock .Anything , mock .AnythingOfType ("*v1alpha2.BundleDeployment" )).Return (& source.Result {
195
+ State : source .StatePending ,
196
+ }, nil )
197
+
252
198
ctx := context .Background ()
253
199
extKey := types.NamespacedName {Name : fmt .Sprintf ("cluster-extension-test-%s" , rand .String (8 ))}
254
200
@@ -267,13 +213,15 @@ func TestClusterExtensionChannelExistsNoVersion(t *testing.T) {
267
213
InstallNamespace : installNamespace ,
268
214
},
269
215
}
270
- require .NoError (t , cl .Create (ctx , clusterExtension ))
216
+ err := cl .Create (ctx , clusterExtension )
217
+ require .NoError (t , err )
271
218
272
219
t .Log ("It sets resolution success status" )
273
220
t .Log ("By running reconcile" )
274
221
res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : extKey })
275
222
require .Equal (t , ctrl.Result {}, res )
276
223
require .NoError (t , err )
224
+
277
225
t .Log ("By fetching updated cluster extension after reconcile" )
278
226
require .NoError (t , cl .Get (ctx , extKey , clusterExtension ))
279
227
@@ -282,27 +230,18 @@ func TestClusterExtensionChannelExistsNoVersion(t *testing.T) {
282
230
require .Empty (t , clusterExtension .Status .InstalledBundle )
283
231
284
232
t .Log ("By checking the expected conditions" )
285
- cond := apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeResolved )
286
- require .NotNil (t , cond )
287
- require .Equal (t , metav1 .ConditionTrue , cond .Status )
288
- require .Equal (t , ocv1alpha1 .ReasonSuccess , cond .Reason )
289
- require .
Equal (
t ,
"resolved to \" quay.io/operatorhubio/[email protected] \" " ,
cond .
Message )
290
- cond = apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeInstalled )
291
- require .NotNil (t , cond )
292
- require .Equal (t , metav1 .ConditionUnknown , cond .Status )
293
- require .Equal (t , ocv1alpha1 .ReasonInstallationStatusUnknown , cond .Reason )
294
- require .Equal (t , "bundledeployment status is unknown" , cond .Message )
233
+ resolvedCond := apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeResolved )
234
+ require .NotNil (t , resolvedCond )
235
+ require .Equal (t , metav1 .ConditionTrue , resolvedCond .Status )
236
+ require .Equal (t , ocv1alpha1 .ReasonSuccess , resolvedCond .Reason )
237
+ require .
Equal (
t ,
"resolved to \" quay.io/operatorhubio/[email protected] \" " ,
resolvedCond .
Message )
295
238
296
- t .Log ("By fetching the bundledeployment" )
297
- bd := & rukpakv1alpha2.BundleDeployment {}
298
- require .NoError (t , cl .Get (ctx , types.NamespacedName {Name : extKey .Name }, bd ))
299
- require .Equal (t , "core-rukpak-io-registry" , bd .Spec .ProvisionerClassName )
300
- require .Equal (t , installNamespace , bd .Spec .InstallNamespace )
301
- require .Equal (t , rukpakv1alpha2 .SourceTypeImage , bd .Spec .Source .Type )
302
- require .NotNil (t , bd .Spec .Source .Image )
303
- require .
Equal (
t ,
"quay.io/operatorhubio/[email protected] " ,
bd .
Spec .
Source .
Image .
Ref )
239
+ t .Log ("By checking the expected unpacked conditions" )
240
+ unpackedCond := apimeta .FindStatusCondition (clusterExtension .Status .Conditions , rukpakv1alpha2 .TypeUnpacked )
241
+ require .NotNil (t , unpackedCond )
242
+ require .Equal (t , metav1 .ConditionFalse , unpackedCond .Status )
243
+ require .Equal (t , rukpakv1alpha2 .ReasonUnpackPending , unpackedCond .Reason )
304
244
305
- verifyInvariants (ctx , t , reconciler .Client , clusterExtension )
306
245
require .NoError (t , cl .DeleteAllOf (ctx , & ocv1alpha1.ClusterExtension {}))
307
246
}
308
247
@@ -476,10 +415,14 @@ func verifyConditionsInvariants(t *testing.T, ext *ocv1alpha1.ClusterExtension)
476
415
477
416
func TestClusterExtensionUpgrade (t * testing.T ) {
478
417
cl , reconciler := newClientAndReconciler (t )
418
+ mockUnpacker := unpacker .(* MockUnpacker )
419
+ // Set up the Unpack method to return a result with StateUnpacked
420
+ mockUnpacker .On ("Unpack" , mock .Anything , mock .AnythingOfType ("*v1alpha2.BundleDeployment" )).Return (& source.Result {
421
+ State : source .StatePending ,
422
+ }, nil )
479
423
ctx := context .Background ()
480
424
481
425
t .Run ("semver upgrade constraints enforcement of upgrades within major version" , func (t * testing.T ) {
482
- t .Skip ("Skip and replace with e2e for BundleDeployment" )
483
426
defer featuregatetesting .SetFeatureGateDuringTest (t , features .OperatorControllerFeatureGate , features .ForceSemverUpgradeConstraints , true )()
484
427
defer func () {
485
428
require .NoError (t , cl .DeleteAllOf (ctx , & ocv1alpha1.ClusterExtension {}))
@@ -573,7 +516,6 @@ func TestClusterExtensionUpgrade(t *testing.T) {
573
516
})
574
517
575
518
t .Run ("legacy semantics upgrade constraints enforcement" , func (t * testing.T ) {
576
- t .Skip ("Skip and replace with e2e for BundleDeployment" )
577
519
defer featuregatetesting .SetFeatureGateDuringTest (t , features .OperatorControllerFeatureGate , features .ForceSemverUpgradeConstraints , false )()
578
520
defer func () {
579
521
require .NoError (t , cl .DeleteAllOf (ctx , & ocv1alpha1.ClusterExtension {}))
@@ -667,7 +609,6 @@ func TestClusterExtensionUpgrade(t *testing.T) {
667
609
})
668
610
669
611
t .Run ("ignore upgrade constraints" , func (t * testing.T ) {
670
- t .Skip ("Skip and replace with e2e for BundleDeployment" )
671
612
for _ , tt := range []struct {
672
613
name string
673
614
flagState bool
@@ -754,10 +695,14 @@ func TestClusterExtensionUpgrade(t *testing.T) {
754
695
755
696
func TestClusterExtensionDowngrade (t * testing.T ) {
756
697
cl , reconciler := newClientAndReconciler (t )
698
+ mockUnpacker := unpacker .(* MockUnpacker )
699
+ // Set up the Unpack method to return a result with StateUnpacked
700
+ mockUnpacker .On ("Unpack" , mock .Anything , mock .AnythingOfType ("*v1alpha2.BundleDeployment" )).Return (& source.Result {
701
+ State : source .StatePending ,
702
+ }, nil )
757
703
ctx := context .Background ()
758
704
759
705
t .Run ("enforce upgrade constraints" , func (t * testing.T ) {
760
- t .Skip ("Skip and replace with e2e for BundleDeployment" )
761
706
for _ , tt := range []struct {
762
707
name string
763
708
flagState bool
@@ -840,7 +785,6 @@ func TestClusterExtensionDowngrade(t *testing.T) {
840
785
})
841
786
842
787
t .Run ("ignore upgrade constraints" , func (t * testing.T ) {
843
- t .Skip ("Skip and replace with e2e for BundleDeployment" )
844
788
for _ , tt := range []struct {
845
789
name string
846
790
flagState bool
0 commit comments