Skip to content

Commit 63f22ec

Browse files
committed
Revert "Remove multi-az e2e test (it is no longer supported)"
This reverts commit 39f088b.
1 parent 391452a commit 63f22ec

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

test/e2e/data/e2e_conf.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ providers:
137137
- sourcePath: "./infrastructure-aws/withoutclusterclass/generated/cluster-template-limit-az.yaml"
138138
- sourcePath: "./infrastructure-aws/withoutclusterclass/generated/cluster-template-machine-pool.yaml"
139139
- sourcePath: "./infrastructure-aws/withoutclusterclass/generated/cluster-template-md-remediation.yaml"
140+
- sourcePath: "./infrastructure-aws/withoutclusterclass/generated/cluster-template-multi-az.yaml"
140141
- sourcePath: "./infrastructure-aws/withoutclusterclass/generated/cluster-template-nested-multitenancy.yaml"
141142
- sourcePath: "./infrastructure-aws/withoutclusterclass/generated/cluster-template-remote-management-cluster.yaml"
142143
- sourcePath: "./infrastructure-aws/withoutclusterclass/generated/cluster-template-simple-multitenancy.yaml"

test/e2e/shared/defaults.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const (
5050
AwsNodeMachineType = "AWS_NODE_MACHINE_TYPE"
5151
AwsAvailabilityZone1 = "AWS_AVAILABILITY_ZONE_1"
5252
AwsAvailabilityZone2 = "AWS_AVAILABILITY_ZONE_2"
53+
MultiAzFlavor = "multi-az"
5354
LimitAzFlavor = "limit-az"
5455
SpotInstancesFlavor = "spot-instances"
5556
SSMFlavor = "ssm"

test/e2e/suites/unmanaged/helpers_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,35 @@ func getEvents(namespace string) *corev1.EventList {
388388
return eventsList
389389
}
390390

391+
func getSubnetID(filterKey, filterValue, clusterName string) *string {
392+
var subnetOutput *ec2.DescribeSubnetsOutput
393+
var err error
394+
395+
ec2Client := ec2.New(e2eCtx.AWSSession)
396+
subnetInput := &ec2.DescribeSubnetsInput{
397+
Filters: []*ec2.Filter{
398+
{
399+
Name: aws.String(filterKey),
400+
Values: []*string{
401+
aws.String(filterValue),
402+
},
403+
},
404+
{
405+
Name: aws.String("tag-key"),
406+
Values: aws.StringSlice([]string{"sigs.k8s.io/cluster-api-provider-aws/cluster/" + clusterName}),
407+
},
408+
},
409+
}
410+
411+
Eventually(func() int {
412+
subnetOutput, err = ec2Client.DescribeSubnets(subnetInput)
413+
Expect(err).NotTo(HaveOccurred())
414+
return len(subnetOutput.Subnets)
415+
}, e2eCtx.E2EConfig.GetIntervals("", "wait-infra-subnets")...).Should(Equal(1))
416+
417+
return subnetOutput.Subnets[0].SubnetId
418+
}
419+
391420
func getVolumeIds(info statefulSetInfo, k8sclient crclient.Client) []*string {
392421
ginkgo.By("Retrieving IDs of dynamically provisioned volumes.")
393422
statefulset := &appsv1.StatefulSet{}

test/e2e/suites/unmanaged/unmanaged_functional_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package unmanaged
2222
import (
2323
"context"
2424
"fmt"
25+
"os"
2526
"path/filepath"
2627
"strings"
2728
"time"
@@ -583,6 +584,51 @@ var _ = ginkgo.Context("[unmanaged] [functional]", func() {
583584
})
584585
})
585586

587+
ginkgo.Describe("Workload cluster in multiple AZs", func() {
588+
ginkgo.It("It should be creatable and deletable", func() {
589+
specName := "functional-test-multi-az"
590+
requiredResources = &shared.TestResource{EC2Normal: 3 * e2eCtx.Settings.InstanceVCPU, IGW: 1, NGW: 1, VPC: 1, ClassicLB: 1, EIP: 3}
591+
requiredResources.WriteRequestedResources(e2eCtx, specName)
592+
Expect(shared.AcquireResources(requiredResources, ginkgo.GinkgoParallelProcess(), flock.New(shared.ResourceQuotaFilePath))).To(Succeed())
593+
defer shared.ReleaseResources(requiredResources, ginkgo.GinkgoParallelProcess(), flock.New(shared.ResourceQuotaFilePath))
594+
namespace := shared.SetupSpecNamespace(ctx, specName, e2eCtx)
595+
defer shared.DumpSpecResourcesAndCleanup(ctx, "", namespace, e2eCtx)
596+
ginkgo.By("Creating a cluster")
597+
clusterName := fmt.Sprintf("%s-%s", specName, util.RandomString(6))
598+
configCluster := defaultConfigCluster(clusterName, namespace.Name)
599+
configCluster.ControlPlaneMachineCount = pointer.Int64(3)
600+
configCluster.Flavor = shared.MultiAzFlavor
601+
cluster, _, _ := createCluster(ctx, configCluster, result)
602+
603+
ginkgo.By("Adding worker nodes to additional subnets")
604+
mdName1 := clusterName + "-md-1"
605+
mdName2 := clusterName + "-md-2"
606+
az1 := os.Getenv(shared.AwsAvailabilityZone1)
607+
az2 := os.Getenv(shared.AwsAvailabilityZone2)
608+
md1 := makeMachineDeployment(namespace.Name, mdName1, clusterName, &az1, 1)
609+
md2 := makeMachineDeployment(namespace.Name, mdName2, clusterName, &az2, 1)
610+
611+
// private CIDRs set in cluster-template-multi-az.yaml.
612+
framework.CreateMachineDeployment(ctx, framework.CreateMachineDeploymentInput{
613+
Creator: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
614+
MachineDeployment: md1,
615+
BootstrapConfigTemplate: makeJoinBootstrapConfigTemplate(namespace.Name, mdName1),
616+
InfraMachineTemplate: makeAWSMachineTemplate(namespace.Name, mdName1, e2eCtx.E2EConfig.GetVariable(shared.AwsNodeMachineType), getSubnetID("cidr-block", "10.0.0.0/24", clusterName)),
617+
})
618+
framework.CreateMachineDeployment(ctx, framework.CreateMachineDeploymentInput{
619+
Creator: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
620+
MachineDeployment: md2,
621+
BootstrapConfigTemplate: makeJoinBootstrapConfigTemplate(namespace.Name, mdName2),
622+
InfraMachineTemplate: makeAWSMachineTemplate(namespace.Name, mdName2, e2eCtx.E2EConfig.GetVariable(shared.AwsNodeMachineType), getSubnetID("cidr-block", "10.0.2.0/24", clusterName)),
623+
})
624+
625+
ginkgo.By("Waiting for new worker nodes to become ready")
626+
k8sClient := e2eCtx.Environment.BootstrapClusterProxy.GetClient()
627+
framework.WaitForMachineDeploymentNodesToExist(ctx, framework.WaitForMachineDeploymentNodesToExistInput{Lister: k8sClient, Cluster: cluster, MachineDeployment: md1}, e2eCtx.E2EConfig.GetIntervals("", "wait-worker-nodes")...)
628+
framework.WaitForMachineDeploymentNodesToExist(ctx, framework.WaitForMachineDeploymentNodesToExistInput{Lister: k8sClient, Cluster: cluster, MachineDeployment: md2}, e2eCtx.E2EConfig.GetIntervals("", "wait-worker-nodes")...)
629+
})
630+
})
631+
586632
// TODO @randomvariable: Await more resources
587633
ginkgo.PDescribe("Multiple workload clusters", func() {
588634
ginkgo.Context("in different namespaces with machine failures", func() {

0 commit comments

Comments
 (0)