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