Skip to content

Commit

Permalink
skip cleaning up resources for debugging purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
nawazkh committed Dec 12, 2024
1 parent ce8d4b7 commit 394f093
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 23 deletions.
36 changes: 26 additions & 10 deletions test/e2e/azure_apiserver_ilb.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,13 @@ import (

// AzureAPIServerILBSpecInput is the input for AzureAPIServerILBSpec.
type AzureAPIServerILBSpecInput struct {
BootstrapClusterProxy framework.ClusterProxy
Cluster *clusterv1.Cluster
Namespace *corev1.Namespace
ClusterName string
ExpectedWorkerNodes int32
WaitIntervals []interface{}
BootstrapClusterProxy framework.ClusterProxy
Cluster *clusterv1.Cluster
Namespace *corev1.Namespace
ClusterName string
ExpectedWorkerNodes int32
WaitIntervals []interface{}
TemplateHasPrivateIPCustomDNSResolution bool
}

// AzureAPIServerILBSpec implements a test that verifies the Azure API server ILB is created.
Expand Down Expand Up @@ -205,16 +206,23 @@ func AzureAPIServerILBSpec(ctx context.Context, inputGetter func() AzureAPIServe
Expect(err).NotTo(HaveOccurred())

By("Getting the controlplane endpoint name")
controlPlaneEndpointName, apiServerILBPrivateIP := "", ""
controlPlaneEndpointDNSName, apiServerILBPrivateIP := "", ""
for _, frontendIP := range deployedAzureCluster.Spec.NetworkSpec.APIServerLB.FrontendIPs {
if frontendIP.PublicIP != nil && frontendIP.PublicIP.DNSName != "" {
controlPlaneEndpointName = frontendIP.PublicIP.DNSName
fmt.Fprintf(GinkgoWriter, "Control Plane Endpoint Name: %s\n", frontendIP.PublicIP.DNSName)
controlPlaneEndpointDNSName = frontendIP.PublicIP.DNSName
} else if frontendIP.PrivateIPAddress != "" {
fmt.Fprintf(GinkgoWriter, "API Server ILB Private IP: %s\n", frontendIP.PrivateIPAddress)
apiServerILBPrivateIP = frontendIP.PrivateIPAddress
}
}
Expect(controlPlaneEndpointName).NotTo(BeEmpty(), "controlPlaneEndpointName should be found at AzureCluster.Spec.NetworkSpec.APIServerLB.FrontendIPs with a valid DNS name")
Expect(controlPlaneEndpointName).To(Equal(fmt.Sprintf("%s-%s.%s.cloudapp.azure.com", input.ClusterName, os.Getenv("APISERVER_LB_DNS_SUFFIX"), os.Getenv("AZURE_LOCATION"))))

// skip checking the controlPlaneEndpointDNSName in case of default template
// TODO: remove this block when the underlying infra spec is also updated with private IP of the internal load balancer
if input.TemplateHasPrivateIPCustomDNSResolution {
Expect(controlPlaneEndpointDNSName).NotTo(BeEmpty(), "controlPlaneEndpointDNSName should be found at AzureCluster.Spec.NetworkSpec.APIServerLB.FrontendIPs with a valid DNS name")
Expect(controlPlaneEndpointDNSName).To(Equal(fmt.Sprintf("%s-%s.%s.cloudapp.azure.com", input.ClusterName, os.Getenv("APISERVER_LB_DNS_SUFFIX"), os.Getenv("AZURE_LOCATION"))))
}
Expect(apiServerILBPrivateIP).NotTo(BeEmpty(), "apiServerILBPrivateIP should be found at AzureCluster.Spec.NetworkSpec.APIServerLB.FrontendIPs when apiserver ilb feature flag is enabled")
// ------------------------ //

Expand Down Expand Up @@ -419,6 +427,14 @@ func AzureAPIServerILBSpec(ctx context.Context, inputGetter func() AzureAPIServe
if strings.Contains(output, expectedCmdOutput) {
testResult[expectedCmdOutput] = true
}

// TODO: remove this below block when the underlying infra spec is also updated with
// private IP of the internal load balancer
// For now, a default template will not have the private IP of the internal load balancer in its /etc/hosts
// So, we will skip the test for default templates.
if !input.TemplateHasPrivateIPCustomDNSResolution {
testResult[expectedCmdOutput] = true
}
}

if testResult[apiServerILBPrivateIP] && testResult["Hello from node-debug pod"] {
Expand Down
28 changes: 15 additions & 13 deletions test/e2e/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1189,12 +1189,13 @@ var _ = Describe("Workload cluster creation", func() {
By("Probing workload cluster with APIServerILB feature gate", func() {
AzureAPIServerILBSpec(ctx, func() AzureAPIServerILBSpecInput {
return AzureAPIServerILBSpecInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Cluster: result.Cluster,
Namespace: namespace,
ClusterName: clusterName,
ExpectedWorkerNodes: result.ExpectedWorkerNodes(),
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
BootstrapClusterProxy: bootstrapClusterProxy,
Cluster: result.Cluster,
Namespace: namespace,
ClusterName: clusterName,
ExpectedWorkerNodes: result.ExpectedWorkerNodes(),
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
TemplateHasPrivateIPCustomDNSResolution: false,
}
})
})
Expand All @@ -1203,7 +1204,7 @@ var _ = Describe("Workload cluster creation", func() {
})
})

Context("Creating a self-managed VM based cluster using API Server ILB feature gate and fully spec-ed out template [OPTIONAL][API-Server-ILB]", func() {
Context("Creating a self-managed VM based cluster using API Server ILB feature gate and fully spec-ed out APIServer ILB template [OPTIONAL][API-Server-ILB]", func() {
It("with three controlplane node and three worker nodes", func() {
clusterName = getClusterName(clusterNamePrefix, "apiserver-ilb")

Expand Down Expand Up @@ -1239,12 +1240,13 @@ var _ = Describe("Workload cluster creation", func() {
By("Probing workload cluster with APIServerILB feature gate", func() {
AzureAPIServerILBSpec(ctx, func() AzureAPIServerILBSpecInput {
return AzureAPIServerILBSpecInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Cluster: result.Cluster,
Namespace: namespace,
ClusterName: clusterName,
ExpectedWorkerNodes: result.ExpectedWorkerNodes(),
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
BootstrapClusterProxy: bootstrapClusterProxy,
Cluster: result.Cluster,
Namespace: namespace,
ClusterName: clusterName,
ExpectedWorkerNodes: result.ExpectedWorkerNodes(),
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
TemplateHasPrivateIPCustomDNSResolution: true,
}
})
})
Expand Down

0 comments on commit 394f093

Please sign in to comment.