@@ -269,6 +269,68 @@ func TestClusterExtensionInstallSuccessorVersion(t *testing.T) {
269
269
}, pollDuration , pollInterval )
270
270
}
271
271
272
+ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched (t * testing.T ) {
273
+ t .Log ("When a cluster extension is installed from a catalog" )
274
+ t .Log ("It resolves again when a catalog is patched with new ImageRef" )
275
+ clusterExtension , extensionCatalog := testInit (t )
276
+ defer testCleanup (t , extensionCatalog , clusterExtension )
277
+ defer getArtifactsOutput (t )
278
+
279
+ clusterExtension .Spec = ocv1alpha1.ClusterExtensionSpec {
280
+ PackageName : "prometheus" ,
281
+ InstallNamespace : "default" ,
282
+ ServiceAccount : ocv1alpha1.ServiceAccountReference {
283
+ Name : "default" ,
284
+ },
285
+ }
286
+ t .Log ("It resolves the specified package with correct bundle path" )
287
+ t .Log ("By creating the ClusterExtension resource" )
288
+ require .NoError (t , c .Create (context .Background (), clusterExtension ))
289
+
290
+ t .Log ("By reporting a successful resolution and bundle path" )
291
+ require .EventuallyWithT (t , func (ct * assert.CollectT ) {
292
+ assert .NoError (ct , c .Get (context .Background (), types.NamespacedName {Name : clusterExtension .Name }, clusterExtension ))
293
+ assert .Len (ct , clusterExtension .Status .Conditions , len (conditionsets .ConditionTypes ))
294
+ cond := apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeResolved )
295
+ if ! assert .NotNil (ct , cond ) {
296
+ return
297
+ }
298
+ assert .Equal (ct , metav1 .ConditionTrue , cond .Status )
299
+ assert .Equal (ct , ocv1alpha1 .ReasonSuccess , cond .Reason )
300
+ assert .Contains (ct , cond .Message , "resolved to" )
301
+ assert .Equal (ct , & ocv1alpha1.BundleMetadata {Name : "prometheus-operator.1.2.0" , Version : "1.2.0" }, clusterExtension .Status .ResolvedBundle )
302
+ }, pollDuration , pollInterval )
303
+
304
+ // patch imageRef tag on test-catalog image with v2 image
305
+ t .Log ("By patching the catalog ImageRef to point to the v2 catalog" )
306
+ updatedCatalogImage := fmt .Sprintf ("%s/e2e/test-catalog:v2" , os .Getenv ("LOCAL_REGISTRY_HOST" ))
307
+ err := patchTestCatalog (context .Background (), testCatalogName , updatedCatalogImage )
308
+ require .NoError (t , err )
309
+ require .EventuallyWithT (t , func (ct * assert.CollectT ) {
310
+ assert .NoError (ct , c .Get (context .Background (), types.NamespacedName {Name : extensionCatalog .Name }, extensionCatalog ))
311
+ cond := apimeta .FindStatusCondition (extensionCatalog .Status .Conditions , catalogd .TypeUnpacked )
312
+ if ! assert .NotNil (ct , cond ) {
313
+ return
314
+ }
315
+ assert .Equal (ct , metav1 .ConditionTrue , cond .Status )
316
+ assert .Equal (ct , catalogd .ReasonUnpackSuccessful , cond .Reason )
317
+ }, pollDuration , pollInterval )
318
+
319
+ t .Log ("By eventually reporting a successful resolution and bundle path" )
320
+ require .EventuallyWithT (t , func (ct * assert.CollectT ) {
321
+ assert .NoError (ct , c .Get (context .Background (), types.NamespacedName {Name : clusterExtension .Name }, clusterExtension ))
322
+ assert .Len (ct , clusterExtension .Status .Conditions , len (conditionsets .ConditionTypes ))
323
+ cond := apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeResolved )
324
+ if ! assert .NotNil (ct , cond ) {
325
+ return
326
+ }
327
+ assert .Equal (ct , metav1 .ConditionTrue , cond .Status )
328
+ assert .Equal (ct , ocv1alpha1 .ReasonSuccess , cond .Reason )
329
+ assert .Contains (ct , cond .Message , "resolved to" )
330
+ assert .Equal (ct , & ocv1alpha1.BundleMetadata {Name : "prometheus-operator.2.0.0" , Version : "2.0.0" }, clusterExtension .Status .ResolvedBundle )
331
+ }, pollDuration , pollInterval )
332
+ }
333
+
272
334
func TestClusterExtensionInstallReResolvesWhenNewCatalog (t * testing.T ) {
273
335
t .Log ("When a cluster extension is installed from a catalog" )
274
336
t .Log ("It resolves again when a new catalog is available" )
0 commit comments