@@ -330,11 +330,13 @@ func Test_majorUpgradeRequested(t *testing.T) {
330
330
331
331
func TestVersionMeta (t * testing.T ) {
332
332
tests := []struct {
333
- name string
334
- cr api.PerconaServerMongoDB
335
- want VersionMeta
336
- clusterWide bool
337
- helmDeploy bool
333
+ name string
334
+ cr api.PerconaServerMongoDB
335
+ want VersionMeta
336
+ clusterWide bool
337
+ helmDeploy bool
338
+ namespace string
339
+ watchNamespaces string
338
340
}{
339
341
{
340
342
name : "Minimal CR" ,
@@ -361,6 +363,7 @@ func TestVersionMeta(t *testing.T) {
361
363
Version : version .Version ,
362
364
ClusterSize : 3 ,
363
365
},
366
+ namespace : "test-namespace" ,
364
367
},
365
368
{
366
369
name : "Full CR with old Version deployed with Helm" ,
@@ -433,9 +436,11 @@ func TestVersionMeta(t *testing.T) {
433
436
PITREnabled : true ,
434
437
HelmDeployCR : true ,
435
438
PhysicalBackupScheduled : true ,
439
+ ClusterWideEnabled : false ,
436
440
},
437
441
clusterWide : false ,
438
442
helmDeploy : false ,
443
+ namespace : "test-namespace" ,
439
444
},
440
445
{
441
446
name : "Disabled Backup with storage" ,
@@ -469,6 +474,39 @@ func TestVersionMeta(t *testing.T) {
469
474
ClusterSize : 3 ,
470
475
BackupsEnabled : false ,
471
476
},
477
+ namespace : "test-namespace" ,
478
+ },
479
+ {
480
+ name : "Cluster-wide with specified namespaces and operator helm deploy" ,
481
+ cr : api.PerconaServerMongoDB {
482
+ ObjectMeta : metav1.ObjectMeta {
483
+ Name : "some-name" ,
484
+ },
485
+ Spec : api.PerconaServerMongoDBSpec {
486
+ Image : "percona/percona-server-mongodb:5.0.11-10" ,
487
+ Replsets : []* api.ReplsetSpec {
488
+ {
489
+ Name : "rs0" ,
490
+ Size : 3 ,
491
+ VolumeSpec : fakeVolumeSpec (t ),
492
+ },
493
+ },
494
+ },
495
+ Status : api.PerconaServerMongoDBStatus {
496
+ Size : 4 ,
497
+ },
498
+ },
499
+ want : VersionMeta {
500
+ Apply : "disabled" ,
501
+ Version : version .Version ,
502
+ HelmDeployOperator : true ,
503
+ ClusterWideEnabled : true ,
504
+ ClusterSize : 4 ,
505
+ },
506
+ clusterWide : true ,
507
+ helmDeploy : true ,
508
+ namespace : "test-namespace" ,
509
+ watchNamespaces : "test-namespace,another-namespace" ,
472
510
},
473
511
{
474
512
name : "Cluster-wide and operator helm deploy" ,
@@ -497,17 +535,18 @@ func TestVersionMeta(t *testing.T) {
497
535
ClusterWideEnabled : true ,
498
536
ClusterSize : 4 ,
499
537
},
500
- clusterWide : true ,
501
- helmDeploy : true ,
538
+ clusterWide : true ,
539
+ helmDeploy : true ,
540
+ namespace : "test-namespace" ,
541
+ watchNamespaces : "" ,
502
542
},
503
543
}
504
- currentNs := "test-namespace"
505
544
size := int32 (1 )
506
545
operatorName := "percona-server-mongodb-operator"
507
546
operatorDepl := appsv1.Deployment {
508
547
ObjectMeta : metav1.ObjectMeta {
509
548
Name : operatorName ,
510
- Namespace : currentNs ,
549
+ Namespace : "" ,
511
550
Labels : make (map [string ]string ),
512
551
},
513
552
Spec : appsv1.DeploymentSpec {
@@ -537,9 +576,9 @@ func TestVersionMeta(t *testing.T) {
537
576
538
577
for _ , tt := range tests {
539
578
t .Run (tt .name , func (t * testing.T ) {
540
- t .Setenv (k8s .WatchNamespaceEnvVar , currentNs )
579
+ t .Setenv (k8s .WatchNamespaceEnvVar , tt . namespace )
541
580
if tt .clusterWide {
542
- t .Setenv (k8s .WatchNamespaceEnvVar , "" )
581
+ t .Setenv (k8s .WatchNamespaceEnvVar , tt . watchNamespaces )
543
582
}
544
583
if tt .helmDeploy {
545
584
operatorDepl .Labels ["helm.sh/chart" ] = operatorName
0 commit comments