Skip to content

Commit

Permalink
test: add test for dual-stack clusters
Browse files Browse the repository at this point in the history
Signed-off-by: Anish Ramasekar <[email protected]>
  • Loading branch information
aramase committed Mar 11, 2022
1 parent a3d408b commit 2562d2b
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 5 deletions.
5 changes: 3 additions & 2 deletions test/e2e/azure_lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type AzureLBSpecInput struct {
SkipCleanup bool
IPv6 bool
Windows bool
IPFamilies []corev1.IPFamily
}

// AzureLBSpec implements a test that verifies Azure internal and external load balancers can
Expand Down Expand Up @@ -125,7 +126,7 @@ func AzureLBSpec(ctx context.Context, inputGetter func() AzureLBSpecInput) {
if !input.IPv6 {
By("creating an internal Load Balancer service")

ilbService := webDeployment.CreateServiceResourceSpec(ports, deploymentBuilder.InternalLoadbalancer)
ilbService := webDeployment.CreateServiceResourceSpec(ports, deploymentBuilder.InternalLoadbalancer, input.IPFamilies)
Log("starting to create an internal Load Balancer service")
Eventually(func() error {
_, err := servicesClient.Create(ctx, ilbService, metav1.CreateOptions{})
Expand Down Expand Up @@ -202,7 +203,7 @@ func AzureLBSpec(ctx context.Context, inputGetter func() AzureLBSpecInput) {
}

By("creating an external Load Balancer service")
elbService := webDeployment.CreateServiceResourceSpec(ports, deploymentBuilder.ExternalLoadbalancer)
elbService := webDeployment.CreateServiceResourceSpec(ports, deploymentBuilder.ExternalLoadbalancer, input.IPFamilies)
Log("starting to create an external Load Balancer service")
Eventually(func() error {
_, err := servicesClient.Create(ctx, elbService, metav1.CreateOptions{})
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/azure_machinepool_drain.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build e2e
// +build e2e

/*
Expand Down Expand Up @@ -62,6 +63,7 @@ type (
ClusterName string
SkipCleanup bool
IPv6 bool
IPFamilies []corev1.IPFamily
}

deployCustomizerOption func(builder *deployments.Builder, service *corev1.Service)
Expand Down Expand Up @@ -116,7 +118,7 @@ func testMachinePoolCordonAndDrain(ctx context.Context, mgmtClusterProxy, worklo
}()

customizers = []deployCustomizerOption{
func(builder *deployments.Builder, _ *corev1.Service) {
func(builder *deployments.Builder, service *corev1.Service) {
antiAffinity := corev1.PodAntiAffinity{
PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{
{
Expand Down Expand Up @@ -288,7 +290,7 @@ func deployHttpService(ctx context.Context, clientset *kubernetes.Clientset, isW
webDeploymentBuilder.AddWindowsSelectors()
}

elbService := webDeploymentBuilder.CreateServiceResourceSpec(ports, deployments.ExternalLoadbalancer)
elbService := webDeploymentBuilder.CreateServiceResourceSpec(ports, deployments.ExternalLoadbalancer, nil)

for _, opt := range opts {
opt(webDeploymentBuilder, elbService)
Expand Down
52 changes: 52 additions & 0 deletions test/e2e/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,4 +540,56 @@ var _ = Describe("Workload cluster creation", func() {
})
})
})

Context("Creating a dual-stack cluster [REQUIRED]", func() {
It("With dual-stack worker node", func() {
clusterName = getClusterName(clusterNamePrefix, "dual-stack")
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
ClusterProxy: bootstrapClusterProxy,
ConfigCluster: clusterctl.ConfigClusterInput{
LogFolder: filepath.Join(artifactFolder, "clusters", bootstrapClusterProxy.GetName()),
ClusterctlConfigPath: clusterctlConfigPath,
KubeconfigPath: bootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
Flavor: "dual-stack",
Namespace: namespace.Name,
ClusterName: clusterName,
KubernetesVersion: e2eConfig.GetVariable(capi_e2e.KubernetesVersion),
ControlPlaneMachineCount: pointer.Int64Ptr(3),
WorkerMachineCount: pointer.Int64Ptr(1),
},
WaitForClusterIntervals: e2eConfig.GetIntervals(specName, "wait-cluster"),
WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"),
WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
}, result)

// dual-stack external IP for dual-stack clusters is not yet supported
// first ip family in ipFamilies is used for the primary clusterIP and cloud-provider
// determines the elb/ilb ip family based on the primary clusterIP
Context("Creating an accessible ipv4 load balancer", func() {
AzureLBSpec(ctx, func() AzureLBSpecInput {
return AzureLBSpecInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Namespace: namespace,
ClusterName: clusterName,
SkipCleanup: skipCleanup,
IPFamilies: []corev1.IPFamily{corev1.IPv4Protocol},
}
})
})

Context("Creating an accessible ipv6 load balancer", func() {
AzureLBSpec(ctx, func() AzureLBSpecInput {
return AzureLBSpecInput{
BootstrapClusterProxy: bootstrapClusterProxy,
Namespace: namespace,
ClusterName: clusterName,
SkipCleanup: skipCleanup,
IPv6: true,
IPFamilies: []corev1.IPFamily{corev1.IPv6Protocol},
}
})
})
})
})
})
2 changes: 2 additions & 0 deletions test/e2e/config/azure-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ providers:
targetName: "cluster-template-aks.yaml"
- sourcePath: "${PWD}/templates/test/ci/cluster-template-prow-custom-vnet.yaml"
targetName: "cluster-template-custom-vnet.yaml"
- sourcePath: "${PWD}/templates/test/ci/cluster-template-prow-dual-stack.yaml"
targetName: "cluster-template-dual-stack.yaml"
replacements:
- old: "--v=0"
new: "--v=2"
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/kubernetes/deployment/deployment.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build e2e
// +build e2e

/*
Expand Down Expand Up @@ -168,7 +169,7 @@ func (d *Builder) GetPodsFromDeployment(ctx context.Context, clientset *kubernet
return pods.Items, nil
}

func (d *Builder) CreateServiceResourceSpec(ports []corev1.ServicePort, lbtype LoadbalancerType) *corev1.Service {
func (d *Builder) CreateServiceResourceSpec(ports []corev1.ServicePort, lbtype LoadbalancerType, ipFamilies []corev1.IPFamily) *corev1.Service {
suffix := "elb"
annotations := map[string]string{}
if lbtype == InternalLoadbalancer {
Expand All @@ -188,6 +189,7 @@ func (d *Builder) CreateServiceResourceSpec(ports []corev1.ServicePort, lbtype L
Selector: map[string]string{
"app": d.deployment.Name,
},
IPFamilies: ipFamilies,
},
}
}
Expand Down

0 comments on commit 2562d2b

Please sign in to comment.