@@ -49,8 +49,8 @@ func TestCatalogLoadingBetweenRestarts(t *testing.T) {
49
49
crc := newCRClient (t )
50
50
51
51
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 ()
54
54
55
55
// ensure the mock catalog exists and has been synced by the catalog operator
56
56
catalogSource , err := fetchCatalogSource (t , crc , catalogSourceName , operatorNamespace , catalogSourceRegistryPodSynced )
@@ -264,7 +264,7 @@ func TestConfigMapReplaceTriggersRegistryPodRollout(t *testing.T) {
264
264
}
265
265
266
266
// 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 })
268
268
269
269
// Attempt to get the catalog source before creating install plan
270
270
fetchedInitialCatalog , err := fetchCatalogSource (t , crc , mainCatalogName , testNamespace , catalogSourceRegistryPodSynced )
@@ -279,7 +279,7 @@ func TestConfigMapReplaceTriggersRegistryPodRollout(t *testing.T) {
279
279
require .Equal (t , 1 , len (initialPods .Items ))
280
280
281
281
// delete the first catalog
282
- cleanupCatalog ()
282
+ cleanupSource ()
283
283
284
284
// create a catalog with the same name
285
285
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) {
436
436
require .NoError (t , err )
437
437
}
438
438
439
- func TestDeleteRegistryPodTriggersRecreation (t * testing.T ) {
439
+ func TestDeleteInternalRegistryPodTriggersRecreation (t * testing.T ) {
440
440
// Create internal CatalogSource containing csv in package
441
441
// Wait for a registry pod to be created
442
442
// Create a Subscription for package
@@ -452,7 +452,7 @@ func TestDeleteRegistryPodTriggersRecreation(t *testing.T) {
452
452
packageStable := fmt .Sprintf ("%s-stable" , packageName )
453
453
stableChannel := "stable"
454
454
namedStrategy := newNginxInstallStrategy (genName ("dep-" ), nil , nil )
455
- catalogName := genName ("catsrc -" )
455
+ sourceName := genName ("catalog -" )
456
456
crd := newCRD (genName ("ins-" ))
457
457
csv := newCSV (packageStable , testNamespace , "" , * semver .New ("0.1.0" ), []apiextensions.CustomResourceDefinition {crd }, nil , namedStrategy )
458
458
manifests := []registry.PackageManifest {
@@ -467,11 +467,11 @@ func TestDeleteRegistryPodTriggersRecreation(t *testing.T) {
467
467
468
468
c := newKubeClient (t )
469
469
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 ()
472
472
473
473
// 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 })
475
475
singlePod := podCount (1 )
476
476
registryPods , err := awaitPods (t , c , testNamespace , selector .String (), singlePod )
477
477
require .NoError (t , err , "error awaiting registry pod" )
@@ -484,7 +484,7 @@ func TestDeleteRegistryPodTriggersRecreation(t *testing.T) {
484
484
485
485
// Create a Subscription for package
486
486
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 )
488
488
defer cleanupSubscription ()
489
489
490
490
// Wait for the Subscription to succeed
@@ -516,6 +516,90 @@ func TestDeleteRegistryPodTriggersRecreation(t *testing.T) {
516
516
require .Equal (t , 1 , len (registryPods .Items ), "unexpected number of replacement registry pods found" )
517
517
}
518
518
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
+
519
603
func getOperatorDeployment (c operatorclient.ClientInterface , namespace string , operatorLabels labels.Set ) (* appsv1.Deployment , error ) {
520
604
deployments , err := c .ListDeploymentsWithLabels (namespace , operatorLabels )
521
605
if err != nil || deployments == nil || len (deployments .Items ) != 1 {
0 commit comments