@@ -357,6 +357,82 @@ func TestClusterExtensionInstallRegistry(t *testing.T) {
357357	}
358358}
359359
360+ func  TestClusterExtensionInstallRegistryDynamic (t  * testing.T ) {
361+ 	// NOTE: Like 'TestClusterExtensionInstallRegistry', this test also requires extra configuration in /etc/containers/registries.conf 
362+ 	packageName  :=  "dynamic" 
363+ 
364+ 	t .Log ("When a cluster extension is installed from a catalog" )
365+ 	t .Log ("When the extension bundle format is registry+v1" )
366+ 
367+ 	clusterExtension , extensionCatalog , sa , ns  :=  testInit (t )
368+ 	defer  testCleanup (t , extensionCatalog , clusterExtension , sa , ns )
369+ 	defer  getArtifactsOutput (t )
370+ 
371+ 	clusterExtension .Spec  =  ocv1.ClusterExtensionSpec {
372+ 		Source : ocv1.SourceConfig {
373+ 			SourceType : "Catalog" ,
374+ 			Catalog : & ocv1.CatalogSource {
375+ 				PackageName : packageName ,
376+ 				Selector : & metav1.LabelSelector {
377+ 					MatchLabels : map [string ]string {"olm.operatorframework.io/metadata.name" : extensionCatalog .Name },
378+ 				},
379+ 			},
380+ 		},
381+ 		Namespace : ns .Name ,
382+ 		ServiceAccount : ocv1.ServiceAccountReference {
383+ 			Name : sa .Name ,
384+ 		},
385+ 	}
386+ 	t .Log ("It updates the registries.conf file contents" )
387+ 	cm  :=  corev1.ConfigMap {
388+ 		ObjectMeta : metav1.ObjectMeta {
389+ 			Name :      "e2e-registries-conf" ,
390+ 			Namespace : "olmv1-system" ,
391+ 		},
392+ 		Data : map [string ]string {
393+ 			"registries.conf" : `[[registry]] 
394+ prefix = "dynamic-registry.operator-controller-e2e.svc.cluster.local:5000" 
395+ location = "docker-registry.operator-controller-e2e.svc.cluster.local:5000"` ,
396+ 		},
397+ 	}
398+ 	require .NoError (t , c .Update (context .Background (), & cm ))
399+ 
400+ 	t .Log ("It resolves the specified package with correct bundle path" )
401+ 	t .Log ("By creating the ClusterExtension resource" )
402+ 	require .NoError (t , c .Create (context .Background (), clusterExtension ))
403+ 
404+ 	t .Log ("By eventually reporting a successful resolution and bundle path" )
405+ 	require .EventuallyWithT (t , func (ct  * assert.CollectT ) {
406+ 		assert .NoError (ct , c .Get (context .Background (), types.NamespacedName {Name : clusterExtension .Name }, clusterExtension ))
407+ 	}, 2 * time .Minute , pollInterval )
408+ 
409+ 	// Give the check 2 minutes instead of the typical 1 for the pod's 
410+ 	// files to update from the configmap change. 
411+ 	// The theoretical max time is the kubelet sync period of 1 minute + 
412+ 	// ConfigMap cache TTL of 1 minute = 2 minutes 
413+ 	t .Log ("By eventually reporting progressing as True" )
414+ 	require .EventuallyWithT (t , func (ct  * assert.CollectT ) {
415+ 		assert .NoError (ct , c .Get (context .Background (), types.NamespacedName {Name : clusterExtension .Name }, clusterExtension ))
416+ 		cond  :=  apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1 .TypeProgressing )
417+ 		if  assert .NotNil (ct , cond ) {
418+ 			assert .Equal (ct , metav1 .ConditionTrue , cond .Status )
419+ 			assert .Equal (ct , ocv1 .ReasonSucceeded , cond .Reason )
420+ 		}
421+ 	}, 2 * time .Minute , pollInterval )
422+ 
423+ 	t .Log ("By eventually installing the package successfully" )
424+ 	require .EventuallyWithT (t , func (ct  * assert.CollectT ) {
425+ 		assert .NoError (ct , c .Get (context .Background (), types.NamespacedName {Name : clusterExtension .Name }, clusterExtension ))
426+ 		cond  :=  apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1 .TypeInstalled )
427+ 		if  assert .NotNil (ct , cond ) {
428+ 			assert .Equal (ct , metav1 .ConditionTrue , cond .Status )
429+ 			assert .Equal (ct , ocv1 .ReasonSucceeded , cond .Reason )
430+ 			assert .Contains (ct , cond .Message , "Installed bundle" )
431+ 			assert .NotEmpty (ct , clusterExtension .Status .Install .Bundle )
432+ 		}
433+ 	}, pollDuration , pollInterval )
434+ }
435+ 
360436func  TestClusterExtensionInstallRegistryMultipleBundles (t  * testing.T ) {
361437	t .Log ("When a cluster extension is installed from a catalog" )
362438
0 commit comments