@@ -166,9 +166,12 @@ func TestDefaultDeployment(t *testing.T) {
166
166
},
167
167
}
168
168
169
- infrastructureConfigHighlyAvailable := infrastructureConfigWithTopology (configv1 .HighlyAvailableTopologyMode )
170
- infrastructureConfigSingleReplica := infrastructureConfigWithTopology (configv1 .SingleReplicaTopologyMode )
171
- infrastructureConfigExternalTopologyMode := infrastructureConfigWithTopology (configv1 .ExternalTopologyMode )
169
+ infrastructureConfigHighlyAvailable := infrastructureConfigWithTopology (configv1 .HighlyAvailableTopologyMode ,
170
+ configv1 .HighlyAvailableTopologyMode )
171
+ infrastructureConfigSingleReplica := infrastructureConfigWithTopology (configv1 .SingleReplicaTopologyMode ,
172
+ configv1 .SingleReplicaTopologyMode )
173
+ infrastructureConfigExternalTopologyMode := infrastructureConfigWithTopology (configv1 .ExternalTopologyMode ,
174
+ configv1 .HighlyAvailableTopologyMode )
172
175
consoleDeploymentTemplate := resourceread .ReadDeploymentV1OrDie (bindata .MustAsset ("assets/deployments/console-deployment.yaml" ))
173
176
withConsoleContainerImage (consoleDeploymentTemplate , consoleOperatorConfig , proxyConfig )
174
177
withConsoleVolumes (consoleDeploymentTemplate , & corev1.ConfigMap {
@@ -669,8 +672,14 @@ func TestWithReplicas(t *testing.T) {
669
672
infrastructureConfig * configv1.Infrastructure
670
673
}
671
674
672
- infrastructureConfigHighlyAvailable := infrastructureConfigWithTopology (configv1 .HighlyAvailableTopologyMode )
673
- infrastructureConfigSingleReplica := infrastructureConfigWithTopology (configv1 .SingleReplicaTopologyMode )
675
+ infrastructureConfigHighlyAvailable := infrastructureConfigWithTopology (configv1 .HighlyAvailableTopologyMode ,
676
+ configv1 .HighlyAvailableTopologyMode )
677
+ infrastructureConfigSingleReplica := infrastructureConfigWithTopology (configv1 .SingleReplicaTopologyMode ,
678
+ configv1 .SingleReplicaTopologyMode )
679
+ infrastructureConfigExternalCPSingleReplica := infrastructureConfigWithTopology (configv1 .ExternalTopologyMode ,
680
+ configv1 .SingleReplicaTopologyMode )
681
+ infrastructureConfigExternalCPHighlyAvailable := infrastructureConfigWithTopology (configv1 .ExternalTopologyMode ,
682
+ configv1 .HighlyAvailableTopologyMode )
674
683
675
684
tests := []struct {
676
685
name string
@@ -705,6 +714,34 @@ func TestWithReplicas(t *testing.T) {
705
714
},
706
715
},
707
716
},
717
+ {
718
+ name : "Test External CP with Single Replica workers" ,
719
+ args : args {
720
+ deployment : & appsv1.Deployment {
721
+ Spec : appsv1.DeploymentSpec {},
722
+ },
723
+ infrastructureConfig : infrastructureConfigExternalCPSingleReplica ,
724
+ },
725
+ want : & appsv1.Deployment {
726
+ Spec : appsv1.DeploymentSpec {
727
+ Replicas : & singleNodeReplicaCount ,
728
+ },
729
+ },
730
+ },
731
+ {
732
+ name : "Test External CP with Highly Available workers" ,
733
+ args : args {
734
+ deployment : & appsv1.Deployment {
735
+ Spec : appsv1.DeploymentSpec {},
736
+ },
737
+ infrastructureConfig : infrastructureConfigExternalCPHighlyAvailable ,
738
+ },
739
+ want : & appsv1.Deployment {
740
+ Spec : appsv1.DeploymentSpec {
741
+ Replicas : & defaultReplicaCount ,
742
+ },
743
+ },
744
+ },
708
745
}
709
746
for _ , tt := range tests {
710
747
t .Run (tt .name , func (t * testing.T ) {
@@ -723,8 +760,12 @@ func TestWithAffinity(t *testing.T) {
723
760
component string
724
761
}
725
762
726
- infrastructureConfigHighlyAvailable := infrastructureConfigWithTopology (configv1 .HighlyAvailableTopologyMode )
727
- infrastructureConfigSingleReplica := infrastructureConfigWithTopology (configv1 .SingleReplicaTopologyMode )
763
+ infrastructureConfigHighlyAvailable := infrastructureConfigWithTopology (configv1 .HighlyAvailableTopologyMode , configv1 .HighlyAvailableTopologyMode )
764
+ infrastructureConfigSingleReplica := infrastructureConfigWithTopology (configv1 .SingleReplicaTopologyMode , configv1 .SingleReplicaTopologyMode )
765
+ infrastructureConfigExternalCPSingleReplica := infrastructureConfigWithTopology (configv1 .ExternalTopologyMode ,
766
+ configv1 .SingleReplicaTopologyMode )
767
+ infrastructureConfigExternalCPHighlyAvailable := infrastructureConfigWithTopology (configv1 .ExternalTopologyMode ,
768
+ configv1 .HighlyAvailableTopologyMode )
728
769
729
770
tests := []struct {
730
771
name string
@@ -784,6 +825,59 @@ func TestWithAffinity(t *testing.T) {
784
825
},
785
826
},
786
827
},
828
+ {
829
+ name : "Test Single Replica Affinity in externalized control plane with Single Replica workers" ,
830
+ args : args {
831
+ deployment : & appsv1.Deployment {
832
+ Spec : appsv1.DeploymentSpec {},
833
+ },
834
+ infrastructureConfig : infrastructureConfigExternalCPSingleReplica ,
835
+ component : "ui" ,
836
+ },
837
+ want : & appsv1.Deployment {
838
+ Spec : appsv1.DeploymentSpec {
839
+ Template : corev1.PodTemplateSpec {
840
+ Spec : corev1.PodSpec {
841
+ Affinity : & corev1.Affinity {},
842
+ },
843
+ },
844
+ },
845
+ },
846
+ },
847
+ {
848
+ name : "Test Highly Available Affinity in externalized control plane with Highly Available workers" ,
849
+ args : args {
850
+ deployment : & appsv1.Deployment {
851
+ Spec : appsv1.DeploymentSpec {},
852
+ },
853
+ infrastructureConfig : infrastructureConfigExternalCPHighlyAvailable ,
854
+ component : "foobar" ,
855
+ },
856
+ want : & appsv1.Deployment {
857
+ Spec : appsv1.DeploymentSpec {
858
+ Template : corev1.PodTemplateSpec {
859
+ Spec : corev1.PodSpec {
860
+ Affinity : & corev1.Affinity {
861
+ PodAntiAffinity : & corev1.PodAntiAffinity {
862
+ RequiredDuringSchedulingIgnoredDuringExecution : []corev1.PodAffinityTerm {{
863
+ LabelSelector : & metav1.LabelSelector {
864
+ MatchExpressions : []metav1.LabelSelectorRequirement {
865
+ {
866
+ Key : "component" ,
867
+ Operator : metav1 .LabelSelectorOpIn ,
868
+ Values : []string {"foobar" },
869
+ },
870
+ },
871
+ },
872
+ TopologyKey : "kubernetes.io/hostname" ,
873
+ }},
874
+ },
875
+ },
876
+ },
877
+ },
878
+ },
879
+ },
880
+ },
787
881
}
788
882
for _ , tt := range tests {
789
883
t .Run (tt .name , func (t * testing.T ) {
@@ -1181,8 +1275,10 @@ func TestWithStrategy(t *testing.T) {
1181
1275
infrastructureConfig * configv1.Infrastructure
1182
1276
}
1183
1277
1184
- infrastructureConfigHighlyAvailable := infrastructureConfigWithTopology (configv1 .HighlyAvailableTopologyMode )
1185
- infrastructureConfigSingleReplica := infrastructureConfigWithTopology (configv1 .SingleReplicaTopologyMode )
1278
+ infrastructureConfigHighlyAvailable := infrastructureConfigWithTopology (configv1 .HighlyAvailableTopologyMode , configv1 .HighlyAvailableTopologyMode )
1279
+ infrastructureConfigSingleReplica := infrastructureConfigWithTopology (configv1 .SingleReplicaTopologyMode , configv1 .SingleReplicaTopologyMode )
1280
+ infrastructureConfigExternalTopologyHighlyAvailable := infrastructureConfigWithTopology (configv1 .ExternalTopologyMode , configv1 .HighlyAvailableTopologyMode )
1281
+ infrastructureConfigExternalTopologySingleReplica := infrastructureConfigWithTopology (configv1 .ExternalTopologyMode , configv1 .SingleReplicaTopologyMode )
1186
1282
1187
1283
singleReplicaStrategy := appsv1.RollingUpdateDeployment {}
1188
1284
highAvailStrategy := appsv1.RollingUpdateDeployment {
@@ -1227,6 +1323,34 @@ func TestWithStrategy(t *testing.T) {
1227
1323
},
1228
1324
},
1229
1325
},
1326
+ {
1327
+ name : "Test Single Replica Strategy in externalized control plane with Single Replica workers" ,
1328
+ args : args {
1329
+ deployment : & appsv1.Deployment {},
1330
+ infrastructureConfig : infrastructureConfigExternalTopologySingleReplica ,
1331
+ },
1332
+ want : & appsv1.Deployment {
1333
+ Spec : appsv1.DeploymentSpec {
1334
+ Strategy : appsv1.DeploymentStrategy {
1335
+ RollingUpdate : & singleReplicaStrategy ,
1336
+ },
1337
+ },
1338
+ },
1339
+ },
1340
+ {
1341
+ name : "Test Highly Available Strategy in externalized control plane with Highly Available workers" ,
1342
+ args : args {
1343
+ deployment : & appsv1.Deployment {},
1344
+ infrastructureConfig : infrastructureConfigExternalTopologyHighlyAvailable ,
1345
+ },
1346
+ want : & appsv1.Deployment {
1347
+ Spec : appsv1.DeploymentSpec {
1348
+ Strategy : appsv1.DeploymentStrategy {
1349
+ RollingUpdate : & highAvailStrategy ,
1350
+ },
1351
+ },
1352
+ },
1353
+ },
1230
1354
}
1231
1355
for _ , tt := range tests {
1232
1356
t .Run (tt .name , func (t * testing.T ) {
@@ -1244,9 +1368,10 @@ func TestWithConsoleNodeSelector(t *testing.T) {
1244
1368
infrastructureConfig * configv1.Infrastructure
1245
1369
}
1246
1370
1247
- infrastructureConfigSingleReplica := infrastructureConfigWithTopology (configv1 .SingleReplicaTopologyMode )
1248
- infrastructureConfigExternalTopology := infrastructureConfigSingleReplica
1249
- infrastructureConfigExternalTopology .Status .ControlPlaneTopology = configv1 .ExternalTopologyMode
1371
+ infrastructureConfigSingleReplica := infrastructureConfigWithTopology (configv1 .SingleReplicaTopologyMode ,
1372
+ configv1 .SingleReplicaTopologyMode )
1373
+ infrastructureConfigExternalTopology := infrastructureConfigWithTopology (configv1 .ExternalTopologyMode ,
1374
+ configv1 .SingleReplicaTopologyMode )
1250
1375
defaultDeployment := appsv1.Deployment {
1251
1376
Spec : appsv1.DeploymentSpec {
1252
1377
Template : corev1.PodTemplateSpec {
@@ -1343,8 +1468,10 @@ func TestDefaultDownloadsDeployment(t *testing.T) {
1343
1468
Finalizers : nil ,
1344
1469
}
1345
1470
1346
- infrastructureConfigHighlyAvailable := infrastructureConfigWithTopology (configv1 .HighlyAvailableTopologyMode )
1347
- infrastructureConfigSingleReplica := infrastructureConfigWithTopology (configv1 .SingleReplicaTopologyMode )
1471
+ infrastructureConfigHighlyAvailable := infrastructureConfigWithTopology (configv1 .HighlyAvailableTopologyMode ,
1472
+ configv1 .HighlyAvailableTopologyMode )
1473
+ infrastructureConfigSingleReplica := infrastructureConfigWithTopology (configv1 .SingleReplicaTopologyMode ,
1474
+ configv1 .SingleReplicaTopologyMode )
1348
1475
1349
1476
downloadsDeploymentPodSpecSingleReplica := corev1.PodSpec {
1350
1477
NodeSelector : map [string ]string {
@@ -1790,13 +1917,13 @@ func TestIsAvailableAndUpdated(t *testing.T) {
1790
1917
1791
1918
}
1792
1919
1793
- func infrastructureConfigWithTopology (topologyMode configv1.TopologyMode ) * configv1.Infrastructure {
1920
+ func infrastructureConfigWithTopology (controlPlaneTopologyMode , infrastructureTopologyMode configv1.TopologyMode ) * configv1.Infrastructure {
1794
1921
return & configv1.Infrastructure {
1795
1922
TypeMeta : metav1.TypeMeta {},
1796
1923
ObjectMeta : metav1.ObjectMeta {},
1797
1924
Status : configv1.InfrastructureStatus {
1798
- InfrastructureTopology : topologyMode ,
1799
- ControlPlaneTopology : topologyMode ,
1925
+ InfrastructureTopology : infrastructureTopologyMode ,
1926
+ ControlPlaneTopology : controlPlaneTopologyMode ,
1800
1927
},
1801
1928
}
1802
1929
}
0 commit comments