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