Skip to content

Commit

Permalink
GCP: Update unit tests when UserProvisionedDNS is enabled
Browse files Browse the repository at this point in the history
Also add test_data containing ControllerConfig for GCP when
DNStype is `ClusterHosted` and all the LB IP values are available.
  • Loading branch information
sadasu committed Feb 8, 2025
1 parent 77abc39 commit 0060c15
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
44 changes: 44 additions & 0 deletions pkg/controller/template/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ var (
"nutanix": "./test_data/controller_config_nutanix.yaml",
"network-forwarding-sdn": "./test_data/controller_config_forwarding_sdn.yaml",
"network-forwarding-ovn": "./test_data/controller_config_forwarding_ovn.yaml",
"gcp-custom-dns": "./test_data/controller_config_gcp_custom_dns.yaml",
"gcp-default-dns": "./test_data/controller_config_gcp_default_dns.yaml",
}
)

Expand Down Expand Up @@ -359,6 +361,11 @@ func TestGenerateMachineConfigs(t *testing.T) {
}

func TestGetPaths(t *testing.T) {
APIIntLBIP := configv1.IP("10.10.10.4")
APILBIP := configv1.IP("196.78.125.4")
IngressLBIP1 := configv1.IP("196.78.125.5")
IngressLBIP2 := configv1.IP("10.10.10.5")

cases := []struct {
platform configv1.PlatformType
topology configv1.TopologyMode
Expand All @@ -372,6 +379,11 @@ func TestGetPaths(t *testing.T) {
res: []string{strings.ToLower(string(configv1.BareMetalPlatformType)), "on-prem"},
topology: configv1.HighlyAvailableTopologyMode,
}, {
platform: configv1.GCPPlatformType,
res: []string{strings.ToLower(string(configv1.GCPPlatformType))},
topology: configv1.HighlyAvailableTopologyMode,
}, {

platform: configv1.NonePlatformType,
res: []string{strings.ToLower(string(configv1.NonePlatformType)), sno},
topology: configv1.SingleReplicaTopologyMode,
Expand All @@ -392,6 +404,38 @@ func TestGetPaths(t *testing.T) {
},
},
}
if c.platform == configv1.GCPPlatformType {
config = &mcfgv1.ControllerConfig{
Spec: mcfgv1.ControllerConfigSpec{
Infra: &configv1.Infrastructure{
Status: configv1.InfrastructureStatus{
Platform: c.platform,
PlatformStatus: &configv1.PlatformStatus{
Type: c.platform,
GCP: &configv1.GCPPlatformStatus{
CloudLoadBalancerConfig: &configv1.CloudLoadBalancerConfig{
DNSType: configv1.ClusterHostedDNSType,
ClusterHosted: &configv1.CloudLoadBalancerIPs{
APIIntLoadBalancerIPs: []configv1.IP{
APIIntLBIP,
},
APILoadBalancerIPs: []configv1.IP{
APILBIP,
},
IngressLoadBalancerIPs: []configv1.IP{
IngressLBIP1,
IngressLBIP2,
},
},
},
},
},
ControlPlaneTopology: c.topology,
},
},
},
}
}
c.res = append(c.res, platformBase)

got := getPaths(&RenderConfig{&config.Spec, `{"dummy":"dummy"}`, "dummy", nil, nil}, config.Spec.Platform)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: "machineconfigurations.openshift.io/v1"
kind: "ControllerConfig"
spec:
clusterDNSIP: "10.3.0.10"
cloudProviderConfig: ""
etcdInitialCount: 3
etcdCAData: ZHVtbXkgZXRjZC1jYQo=
rootCAData: ZHVtbXkgcm9vdC1jYQo=
pullSecret:
data: ZHVtbXkgZXRjZC1jYQo=
images:
etcd: image/etcd:1
setupEtcdEnv: image/setupEtcdEnv:1
infraImage: image/infraImage:1
kubeClientAgentImage: image/kubeClientAgentImage:1
infra:
apiVersion: config.openshift.io/v1
kind: Infrastructure
status:
apiServerInternalURI: https://api-int.my-test-cluster.installer.team.coreos.systems:6443
apiServerURL: https://api.my-test-cluster.installer.team.coreos.systems:6443
etcdDiscoveryDomain: my-test-cluster.installer.team.coreos.systems
infrastructureName: my-test-cluster
platformStatus:
type: "GCP"
gcp:
cloudLoadBalancerConfig:
dnsType: "ClusterHosted"
clusterHosted:
apiLoadBalancerIPs:
- 20.20.20.20
apiIntLoadBalancerIPs:
- 10.10.10.10
dns:
spec:
baseDomain: my-test-cluster.installer.team.coreos.systems
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: "machineconfigurations.openshift.io/v1"
kind: "ControllerConfig"
spec:
clusterDNSIP: "10.3.0.10"
cloudProviderConfig: ""
etcdInitialCount: 3
etcdCAData: ZHVtbXkgZXRjZC1jYQo=
rootCAData: ZHVtbXkgcm9vdC1jYQo=
pullSecret:
data: ZHVtbXkgZXRjZC1jYQo=
images:
etcd: image/etcd:1
setupEtcdEnv: image/setupEtcdEnv:1
infraImage: image/infraImage:1
kubeClientAgentImage: image/kubeClientAgentImage:1
infra:
apiVersion: config.openshift.io/v1
kind: Infrastructure
status:
apiServerInternalURI: https://api-int.my-test-cluster.installer.team.coreos.systems:6443
apiServerURL: https://api.my-test-cluster.installer.team.coreos.systems:6443
etcdDiscoveryDomain: my-test-cluster.installer.team.coreos.systems
infrastructureName: my-test-cluster
platformStatus:
type: "GCP"
gcp:
cloudLoadBalancerConfig:
dnsType: "PlatformDefault"

0 comments on commit 0060c15

Please sign in to comment.