@@ -184,14 +184,15 @@ func TestConfigMapUpdateTriggersRegistryPodRollout(t *testing.T) {
184
184
require .Equal (t , updatedConfigMap .GetResourceVersion (), fetchedUpdatedCatalog .Status .ConfigMapResource .ResourceVersion )
185
185
186
186
// Await 1 CatalogSource registry pod matching the updated labels
187
+ singlePod := podCount (1 )
187
188
selector := labels .SelectorFromSet (map [string ]string {"olm.catalogSource" : mainCatalogName , "olm.configMapResourceVersion" : updatedConfigMap .GetResourceVersion ()})
188
- podList , err := awaitPods (t , c , selector .String (), 1 )
189
+ podList , err := awaitPods (t , c , testNamespace , selector .String (), singlePod )
189
190
require .NoError (t , err )
190
191
require .Equal (t , 1 , len (podList .Items ), "expected pod list not of length 1" )
191
192
192
193
// Await 1 CatalogSource registry pod matching the updated labels
193
194
selector = labels .SelectorFromSet (map [string ]string {"olm.catalogSource" : mainCatalogName })
194
- podList , err = awaitPods (t , c , selector .String (), 1 )
195
+ podList , err = awaitPods (t , c , testNamespace , selector .String (), singlePod )
195
196
require .NoError (t , err )
196
197
require .Equal (t , 1 , len (podList .Items ), "expected pod list not of length 1" )
197
198
@@ -377,9 +378,9 @@ func TestGrpcAddressCatalogSource(t *testing.T) {
377
378
378
379
// Replicate catalog pods with no OwnerReferences
379
380
mainCopy := replicateCatalogPod (t , c , crc , mainSource )
380
- mainCopy = awaitPod (t , c , mainCopy .GetNamespace (), mainCopy .GetName (), HasPodIP )
381
+ mainCopy = awaitPod (t , c , mainCopy .GetNamespace (), mainCopy .GetName (), hasPodIP )
381
382
replacementCopy := replicateCatalogPod (t , c , crc , replacementSource )
382
- replacementCopy = awaitPod (t , c , replacementCopy .GetNamespace (), replacementCopy .GetName (), HasPodIP )
383
+ replacementCopy = awaitPod (t , c , replacementCopy .GetNamespace (), replacementCopy .GetName (), hasPodIP )
383
384
384
385
addressSourceName := genName ("address-catalog-" )
385
386
@@ -435,6 +436,86 @@ func TestGrpcAddressCatalogSource(t *testing.T) {
435
436
require .NoError (t , err )
436
437
}
437
438
439
+ func TestDeleteRegistryPodTriggersRecreation (t * testing.T ) {
440
+ // Create internal CatalogSource containing csv in package
441
+ // Wait for a registry pod to be created
442
+ // Create a Subscription for package
443
+ // Wait for the Subscription to succeed
444
+ // Wait for csv to succeed
445
+ // Delete the registry pod
446
+ // Wait for a new registry pod to be created
447
+
448
+ defer cleaner .NotifyTestComplete (t , true )
449
+
450
+ // Create internal CatalogSource containing csv in package
451
+ packageName := genName ("nginx-" )
452
+ packageStable := fmt .Sprintf ("%s-stable" , packageName )
453
+ stableChannel := "stable"
454
+ namedStrategy := newNginxInstallStrategy (genName ("dep-" ), nil , nil )
455
+ catalogName := genName ("catsrc-" )
456
+ crd := newCRD (genName ("ins-" ))
457
+ csv := newCSV (packageStable , testNamespace , "" , * semver .New ("0.1.0" ), []apiextensions.CustomResourceDefinition {crd }, nil , namedStrategy )
458
+ manifests := []registry.PackageManifest {
459
+ {
460
+ PackageName : packageName ,
461
+ Channels : []registry.PackageChannel {
462
+ {Name : stableChannel , CurrentCSVName : packageStable },
463
+ },
464
+ DefaultChannelName : stableChannel ,
465
+ },
466
+ }
467
+
468
+ c := newKubeClient (t )
469
+ crc := newCRClient (t )
470
+ _ , cleanupCatalog := createInternalCatalogSource (t , c , crc , catalogName , testNamespace , manifests , []apiextensions.CustomResourceDefinition {crd }, []v1alpha1.ClusterServiceVersion {csv })
471
+ defer cleanupCatalog ()
472
+
473
+ // Wait for a new registry pod to be created
474
+ selector := labels .SelectorFromSet (map [string ]string {"olm.catalogSource" : catalogName })
475
+ singlePod := podCount (1 )
476
+ registryPods , err := awaitPods (t , c , testNamespace , selector .String (), singlePod )
477
+ require .NoError (t , err , "error awaiting registry pod" )
478
+ require .NotNil (t , registryPods , "nil registry pods" )
479
+ require .Equal (t , 1 , len (registryPods .Items ), "unexpected number of registry pods found" )
480
+
481
+ // Store the UID for later comparison
482
+ uid := registryPods .Items [0 ].GetUID ()
483
+ name := registryPods .Items [0 ].GetName ()
484
+
485
+ // Create a Subscription for package
486
+ subscriptionName := genName ("sub-" )
487
+ cleanupSubscription := createSubscriptionForCatalog (t , crc , testNamespace , subscriptionName , catalogName , packageName , stableChannel , "" , v1alpha1 .ApprovalAutomatic )
488
+ defer cleanupSubscription ()
489
+
490
+ // Wait for the Subscription to succeed
491
+ subscription , err := fetchSubscription (t , crc , testNamespace , subscriptionName , subscriptionStateAtLatestChecker )
492
+ require .NoError (t , err )
493
+ require .NotNil (t , subscription )
494
+
495
+ // Wait for csv to succeed
496
+ _ , err = fetchCSV (t , crc , subscription .Status .CurrentCSV , testNamespace , csvSucceededChecker )
497
+ require .NoError (t , err )
498
+
499
+ // Delete the registry pod
500
+ err = c .KubernetesInterface ().CoreV1 ().Pods (testNamespace ).Delete (name , & metav1.DeleteOptions {})
501
+ require .NoError (t , err )
502
+
503
+ // Wait for a new registry pod to be created
504
+ notUID := func (pods * corev1.PodList ) bool {
505
+ for _ , pod := range pods .Items {
506
+ if pod .GetUID () == uid {
507
+ return false
508
+ }
509
+ }
510
+
511
+ return true
512
+ }
513
+ registryPods , err = awaitPods (t , c , testNamespace , selector .String (), unionPodsCheck (singlePod , notUID ))
514
+ require .NoError (t , err , "error waiting for replacement registry pod" )
515
+ require .NotNil (t , registryPods , "nil replacement registry pods" )
516
+ require .Equal (t , 1 , len (registryPods .Items ), "unexpected number of replacement registry pods found" )
517
+ }
518
+
438
519
func getOperatorDeployment (c operatorclient.ClientInterface , namespace string , operatorLabels labels.Set ) (* appsv1.Deployment , error ) {
439
520
deployments , err := c .ListDeploymentsWithLabels (namespace , operatorLabels )
440
521
if err != nil || deployments == nil || len (deployments .Items ) != 1 {
0 commit comments