@@ -49,8 +49,8 @@ func TestCatalogLoadingBetweenRestarts(t *testing.T) {
4949 crc := newCRClient (t )
5050
5151 catalogSourceName := genName ("mock-ocs-" )
52- _ , cleanupCatalogSource := createInternalCatalogSource (t , c , crc , catalogSourceName , operatorNamespace , manifests , []apiextensions.CustomResourceDefinition {crd }, []v1alpha1.ClusterServiceVersion {csv })
53- defer cleanupCatalogSource ()
52+ _ , cleanupSource := createInternalCatalogSource (t , c , crc , catalogSourceName , operatorNamespace , manifests , []apiextensions.CustomResourceDefinition {crd }, []v1alpha1.ClusterServiceVersion {csv })
53+ defer cleanupSource ()
5454
5555 // ensure the mock catalog exists and has been synced by the catalog operator
5656 catalogSource , err := fetchCatalogSource (t , crc , catalogSourceName , operatorNamespace , catalogSourceRegistryPodSynced )
@@ -264,7 +264,7 @@ func TestConfigMapReplaceTriggersRegistryPodRollout(t *testing.T) {
264264 }
265265
266266 // Create the initial catalogsource
267- _ , cleanupCatalog := createInternalCatalogSource (t , c , crc , mainCatalogName , testNamespace , mainManifests , nil , []v1alpha1.ClusterServiceVersion {mainCSV })
267+ _ , cleanupSource := createInternalCatalogSource (t , c , crc , mainCatalogName , testNamespace , mainManifests , nil , []v1alpha1.ClusterServiceVersion {mainCSV })
268268
269269 // Attempt to get the catalog source before creating install plan
270270 fetchedInitialCatalog , err := fetchCatalogSource (t , crc , mainCatalogName , testNamespace , catalogSourceRegistryPodSynced )
@@ -279,7 +279,7 @@ func TestConfigMapReplaceTriggersRegistryPodRollout(t *testing.T) {
279279 require .Equal (t , 1 , len (initialPods .Items ))
280280
281281 // delete the first catalog
282- cleanupCatalog ()
282+ cleanupSource ()
283283
284284 // create a catalog with the same name
285285 createInternalCatalogSource (t , c , crc , mainCatalogName , testNamespace , append (mainManifests , dependentManifests ... ), []apiextensions.CustomResourceDefinition {dependentCRD }, []v1alpha1.ClusterServiceVersion {mainCSV , dependentCSV })
@@ -436,7 +436,7 @@ func TestGrpcAddressCatalogSource(t *testing.T) {
436436 require .NoError (t , err )
437437}
438438
439- func TestDeleteRegistryPodTriggersRecreation (t * testing.T ) {
439+ func TestDeleteInternalRegistryPodTriggersRecreation (t * testing.T ) {
440440 // Create internal CatalogSource containing csv in package
441441 // Wait for a registry pod to be created
442442 // Create a Subscription for package
@@ -452,7 +452,7 @@ func TestDeleteRegistryPodTriggersRecreation(t *testing.T) {
452452 packageStable := fmt .Sprintf ("%s-stable" , packageName )
453453 stableChannel := "stable"
454454 namedStrategy := newNginxInstallStrategy (genName ("dep-" ), nil , nil )
455- catalogName := genName ("catsrc -" )
455+ sourceName := genName ("catalog -" )
456456 crd := newCRD (genName ("ins-" ))
457457 csv := newCSV (packageStable , testNamespace , "" , * semver .New ("0.1.0" ), []apiextensions.CustomResourceDefinition {crd }, nil , namedStrategy )
458458 manifests := []registry.PackageManifest {
@@ -467,11 +467,11 @@ func TestDeleteRegistryPodTriggersRecreation(t *testing.T) {
467467
468468 c := newKubeClient (t )
469469 crc := newCRClient (t )
470- _ , cleanupCatalog := createInternalCatalogSource (t , c , crc , catalogName , testNamespace , manifests , []apiextensions.CustomResourceDefinition {crd }, []v1alpha1.ClusterServiceVersion {csv })
471- defer cleanupCatalog ()
470+ _ , cleanupSource := createInternalCatalogSource (t , c , crc , sourceName , testNamespace , manifests , []apiextensions.CustomResourceDefinition {crd }, []v1alpha1.ClusterServiceVersion {csv })
471+ defer cleanupSource ()
472472
473473 // Wait for a new registry pod to be created
474- selector := labels .SelectorFromSet (map [string ]string {"olm.catalogSource" : catalogName })
474+ selector := labels .SelectorFromSet (map [string ]string {"olm.catalogSource" : sourceName })
475475 singlePod := podCount (1 )
476476 registryPods , err := awaitPods (t , c , testNamespace , selector .String (), singlePod )
477477 require .NoError (t , err , "error awaiting registry pod" )
@@ -484,7 +484,7 @@ func TestDeleteRegistryPodTriggersRecreation(t *testing.T) {
484484
485485 // Create a Subscription for package
486486 subscriptionName := genName ("sub-" )
487- cleanupSubscription := createSubscriptionForCatalog (t , crc , testNamespace , subscriptionName , catalogName , packageName , stableChannel , "" , v1alpha1 .ApprovalAutomatic )
487+ cleanupSubscription := createSubscriptionForCatalog (t , crc , testNamespace , subscriptionName , sourceName , packageName , stableChannel , "" , v1alpha1 .ApprovalAutomatic )
488488 defer cleanupSubscription ()
489489
490490 // Wait for the Subscription to succeed
@@ -516,6 +516,90 @@ func TestDeleteRegistryPodTriggersRecreation(t *testing.T) {
516516 require .Equal (t , 1 , len (registryPods .Items ), "unexpected number of replacement registry pods found" )
517517}
518518
519+ func TestDeleteGRPCRegistryPodTriggersRecreation (t * testing.T ) {
520+ // Create gRPC CatalogSource using an external registry image (community-operators)
521+ // Wait for a registry pod to be created
522+ // Create a Subscription for package
523+ // Wait for the Subscription to succeed
524+ // Wait for csv to succeed
525+ // Delete the registry pod
526+ // Wait for a new registry pod to be created
527+
528+ defer cleaner .NotifyTestComplete (t , true )
529+
530+ sourceName := genName ("catalog-" )
531+ packageName := "etcd"
532+ channelName := "clusterwide-alpha"
533+
534+ // Create gRPC CatalogSource using an external registry image (community-operators)
535+ source := & v1alpha1.CatalogSource {
536+ TypeMeta : metav1.TypeMeta {
537+ Kind : v1alpha1 .CatalogSourceKind ,
538+ APIVersion : v1alpha1 .CatalogSourceCRDAPIVersion ,
539+ },
540+ ObjectMeta : metav1.ObjectMeta {
541+ Name : sourceName ,
542+ Namespace : testNamespace ,
543+ },
544+ Spec : v1alpha1.CatalogSourceSpec {
545+ SourceType : v1alpha1 .SourceTypeGrpc ,
546+ Image : communityOperatorsImage ,
547+ },
548+ }
549+
550+ crc := newCRClient (t )
551+ source , err := crc .OperatorsV1alpha1 ().CatalogSources (source .GetNamespace ()).Create (source )
552+ require .NoError (t , err )
553+ defer func () {
554+ require .NoError (t , crc .OperatorsV1alpha1 ().CatalogSources (source .GetNamespace ()).Delete (source .GetName (), & metav1.DeleteOptions {}))
555+ }()
556+
557+ // Wait for a new registry pod to be created
558+ c := newKubeClient (t )
559+ selector := labels .SelectorFromSet (map [string ]string {"olm.catalogSource" : source .GetName ()})
560+ singlePod := podCount (1 )
561+ registryPods , err := awaitPods (t , c , source .GetNamespace (), selector .String (), singlePod )
562+ require .NoError (t , err , "error awaiting registry pod" )
563+ require .NotNil (t , registryPods , "nil registry pods" )
564+ require .Equal (t , 1 , len (registryPods .Items ), "unexpected number of registry pods found" )
565+
566+ // Store the UID for later comparison
567+ uid := registryPods .Items [0 ].GetUID ()
568+ name := registryPods .Items [0 ].GetName ()
569+
570+ // Create a Subscription for package
571+ subscriptionName := genName ("sub-" )
572+ cleanupSubscription := createSubscriptionForCatalog (t , crc , source .GetNamespace (), subscriptionName , source .GetName (), packageName , channelName , "" , v1alpha1 .ApprovalAutomatic )
573+ defer cleanupSubscription ()
574+
575+ // Wait for the Subscription to succeed
576+ subscription , err := fetchSubscription (t , crc , testNamespace , subscriptionName , subscriptionStateAtLatestChecker )
577+ require .NoError (t , err )
578+ require .NotNil (t , subscription )
579+
580+ // Wait for csv to succeed
581+ _ , err = fetchCSV (t , crc , subscription .Status .CurrentCSV , subscription .GetNamespace (), csvSucceededChecker )
582+ require .NoError (t , err )
583+
584+ // Delete the registry pod
585+ require .NoError (t , c .KubernetesInterface ().CoreV1 ().Pods (testNamespace ).Delete (name , & metav1.DeleteOptions {}))
586+
587+ // Wait for a new registry pod to be created
588+ notUID := func (pods * corev1.PodList ) bool {
589+ for _ , pod := range pods .Items {
590+ if pod .GetUID () == uid {
591+ return false
592+ }
593+ }
594+
595+ return true
596+ }
597+ registryPods , err = awaitPods (t , c , testNamespace , selector .String (), unionPodsCheck (singlePod , notUID ))
598+ require .NoError (t , err , "error waiting for replacement registry pod" )
599+ require .NotNil (t , registryPods , "nil replacement registry pods" )
600+ require .Equal (t , 1 , len (registryPods .Items ), "unexpected number of replacement registry pods found" )
601+ }
602+
519603func getOperatorDeployment (c operatorclient.ClientInterface , namespace string , operatorLabels labels.Set ) (* appsv1.Deployment , error ) {
520604 deployments , err := c .ListDeploymentsWithLabels (namespace , operatorLabels )
521605 if err != nil || deployments == nil || len (deployments .Items ) != 1 {
0 commit comments