Skip to content

Commit 6d3362b

Browse files
author
Josh Ferrell
committed
Modify internal ELB test to only use private subnet
1 parent 243429b commit 6d3362b

File tree

5 files changed

+98
-42
lines changed

5 files changed

+98
-42
lines changed

test/e2e/data/infrastructure-aws/kustomize_sources/internal-elb/patches/az-select.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,15 @@ spec:
66
template:
77
spec:
88
failureDomain: "us-west-2a"
9+
---
10+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
11+
kind: AWSMachineTemplate
12+
metadata:
13+
name: "${CLUSTER_NAME}-md-0"
14+
spec:
15+
template:
16+
spec:
17+
failureDomain: "us-west-2a"
18+
919

1020

test/e2e/data/infrastructure-aws/kustomize_sources/internal-elb/patches/internal-elb.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ spec:
99
vpc:
1010
id: "${WL_VPC_ID}"
1111
subnets:
12-
- id: "${WL_PUBLIC_SUBNET_ID}"
1312
- id: "${WL_PRIVATE_SUBNET_ID}"
1413

test/e2e/data/infrastructure-aws/kustomize_sources/peered-remote/patches/az-select.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,15 @@ spec:
66
template:
77
spec:
88
failureDomain: "us-west-2a"
9+
---
10+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
11+
kind: AWSMachineTemplate
12+
metadata:
13+
name: "${CLUSTER_NAME}-md-0"
14+
spec:
15+
template:
16+
spec:
17+
failureDomain: "us-west-2a"
18+
19+
920

test/e2e/shared/common.go

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,29 @@ func DumpMachines(ctx context.Context, e2eCtx *E2EContext, namespace *corev1.Nam
107107
if instanceID == "" {
108108
return
109109
}
110-
DumpMachine(ctx, e2eCtx, m, instanceID)
110+
DumpMachine(ctx, e2eCtx, m, instanceID, nil)
111+
}
112+
}
113+
114+
func DumpMachinesFromProxy(ctx context.Context, e2eCtx *E2EContext, namespace *corev1.Namespace, proxy framework.ClusterProxy) {
115+
machines := MachinesForSpec(ctx, proxy, namespace)
116+
instances, err := allMachines(ctx, e2eCtx)
117+
if err != nil {
118+
return
119+
}
120+
instanceID := ""
121+
for _, m := range machines.Items {
122+
for _, i := range instances {
123+
if i.name == m.Name {
124+
instanceID = i.instanceID
125+
break
126+
}
127+
}
128+
if instanceID == "" {
129+
return
130+
}
131+
clusterName := proxy.GetName()
132+
DumpMachine(ctx, e2eCtx, m, instanceID, &clusterName)
111133
}
112134
}
113135

@@ -121,8 +143,11 @@ func MachinesForSpec(ctx context.Context, clusterProxy framework.ClusterProxy, n
121143
return list
122144
}
123145

124-
func DumpMachine(ctx context.Context, e2eCtx *E2EContext, machine infrav1.AWSMachine, instanceID string) {
146+
func DumpMachine(ctx context.Context, e2eCtx *E2EContext, machine infrav1.AWSMachine, instanceID string, cluster *string) {
125147
logPath := filepath.Join(e2eCtx.Settings.ArtifactFolder, "clusters", e2eCtx.Environment.BootstrapClusterProxy.GetName())
148+
if cluster != nil {
149+
logPath = filepath.Join(e2eCtx.Settings.ArtifactFolder, "clusters", *cluster)
150+
}
126151
machineLogBase := path.Join(logPath, "instances", machine.Namespace, machine.Name)
127152
metaLog := path.Join(machineLogBase, "instance.log")
128153
if err := os.MkdirAll(filepath.Dir(metaLog), 0750); err != nil {
@@ -176,6 +201,14 @@ func DumpSpecResources(ctx context.Context, e2eCtx *E2EContext, namespace *corev
176201
})
177202
}
178203

204+
func DumpSpecResourcesFromProxy(ctx context.Context, e2eCtx *E2EContext, namespace *corev1.Namespace, proxy framework.ClusterProxy) {
205+
framework.DumpAllResources(ctx, framework.DumpAllResourcesInput{
206+
Lister: proxy.GetClient(),
207+
Namespace: namespace.Name,
208+
LogPath: filepath.Join(e2eCtx.Settings.ArtifactFolder, "clusters", proxy.GetName(), "resources"),
209+
})
210+
}
211+
179212
func Byf(format string, a ...interface{}) {
180213
By(fmt.Sprintf(format, a...))
181214
}

test/e2e/suites/unmanaged/unmanaged_functional_test.go

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,8 @@ var _ = ginkgo.Context("[unmanaged] [functional]", func() {
822822
})
823823
})
824824

825-
ginkgo.Describe("Peerings and internal ELB", func() {
826-
ginkgo.It("should create external clusters in peered VPC and with an internal ELB", func() {
825+
ginkgo.Describe("Peerings, internal ELB and private subnet", func() {
826+
ginkgo.It("should create external clusters in peered VPC and with an internal ELB and only utilize a private subnet", func() {
827827
specName := "functional-test-peered-internal-elb"
828828
requiredResources = &shared.TestResource{EC2Normal: 2 * e2eCtx.Settings.InstanceVCPU, IGW: 2, NGW: 2, VPC: 2, ClassicLB: 2, EIP: 5}
829829
requiredResources.WriteRequestedResources(e2eCtx, specName)
@@ -874,7 +874,6 @@ var _ = ginkgo.Context("[unmanaged] [functional]", func() {
874874
shared.SetEnvVar("WL_VPC_ID", *wlClusterInfra.VPC.VpcId, false)
875875
shared.SetEnvVar("MGMT_PUBLIC_SUBNET_ID", *mgmtClusterInfra.State.PublicSubnetID, false)
876876
shared.SetEnvVar("MGMT_PRIVATE_SUBNET_ID", *mgmtClusterInfra.State.PrivateSubnetID, false)
877-
shared.SetEnvVar("WL_PUBLIC_SUBNET_ID", *wlClusterInfra.State.PublicSubnetID, false)
878877
shared.SetEnvVar("WL_PRIVATE_SUBNET_ID", *wlClusterInfra.State.PrivateSubnetID, false)
879878

880879
ginkgo.By("Creating VPC peerings")
@@ -996,49 +995,53 @@ var _ = ginkgo.Context("[unmanaged] [functional]", func() {
996995
Expect(len(wlCPM)).To(Equal(1))
997996

998997
ginkgo.By("Deleting the workload cluster")
999-
framework.DeleteCluster(ctx, framework.DeleteClusterInput{
1000-
Deleter: mgmtClusterProxy.GetClient(),
1001-
Cluster: wlResult.Cluster,
1002-
})
1003-
1004-
framework.WaitForClusterDeleted(ctx, framework.WaitForClusterDeletedInput{
1005-
Getter: mgmtClusterProxy.GetClient(),
1006-
Cluster: wlResult.Cluster,
1007-
}, e2eCtx.E2EConfig.GetIntervals("", "wait-delete-cluster")...)
998+
shared.DumpSpecResourcesFromProxy(ctx, e2eCtx, wlNamespace, mgmtClusterProxy)
999+
shared.DumpMachinesFromProxy(ctx, e2eCtx, wlNamespace, mgmtClusterProxy)
1000+
if !e2eCtx.Settings.SkipCleanup {
1001+
framework.DeleteCluster(ctx, framework.DeleteClusterInput{
1002+
Deleter: mgmtClusterProxy.GetClient(),
1003+
Cluster: wlResult.Cluster,
1004+
})
10081005

1009-
ginkgo.By("Moving the management cluster back to bootstrap")
1010-
clusterctl.Move(ctx, clusterctl.MoveInput{
1011-
LogFolder: filepath.Join(e2eCtx.Settings.ArtifactFolder, "clusters", mgmtCluster.Name),
1012-
ClusterctlConfigPath: e2eCtx.Environment.ClusterctlConfigPath,
1013-
FromKubeconfigPath: mgmtClusterProxy.GetKubeconfigPath(),
1014-
ToKubeconfigPath: e2eCtx.Environment.BootstrapClusterProxy.GetKubeconfigPath(),
1015-
Namespace: namespace.Name,
1016-
})
1006+
framework.WaitForClusterDeleted(ctx, framework.WaitForClusterDeletedInput{
1007+
Getter: mgmtClusterProxy.GetClient(),
1008+
Cluster: wlResult.Cluster,
1009+
}, e2eCtx.E2EConfig.GetIntervals("", "wait-delete-cluster")...)
1010+
1011+
ginkgo.By("Moving the management cluster back to bootstrap")
1012+
clusterctl.Move(ctx, clusterctl.MoveInput{
1013+
LogFolder: filepath.Join(e2eCtx.Settings.ArtifactFolder, "clusters", mgmtCluster.Name),
1014+
ClusterctlConfigPath: e2eCtx.Environment.ClusterctlConfigPath,
1015+
FromKubeconfigPath: mgmtClusterProxy.GetKubeconfigPath(),
1016+
ToKubeconfigPath: e2eCtx.Environment.BootstrapClusterProxy.GetKubeconfigPath(),
1017+
Namespace: namespace.Name,
1018+
})
10171019

1018-
mgmtCluster = framework.DiscoveryAndWaitForCluster(ctx, framework.DiscoveryAndWaitForClusterInput{
1019-
Getter: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
1020-
Namespace: mgmtNamespace.Name,
1021-
Name: mgmtCluster.Name,
1022-
}, e2eCtx.E2EConfig.GetIntervals(specName, "wait-cluster")...)
1020+
mgmtCluster = framework.DiscoveryAndWaitForCluster(ctx, framework.DiscoveryAndWaitForClusterInput{
1021+
Getter: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
1022+
Namespace: mgmtNamespace.Name,
1023+
Name: mgmtCluster.Name,
1024+
}, e2eCtx.E2EConfig.GetIntervals(specName, "wait-cluster")...)
10231025

1024-
mgmtControlPlane = framework.GetKubeadmControlPlaneByCluster(ctx, framework.GetKubeadmControlPlaneByClusterInput{
1025-
Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
1026-
ClusterName: mgmtCluster.Name,
1027-
Namespace: mgmtCluster.Namespace,
1028-
})
1029-
Expect(mgmtControlPlane).ToNot(BeNil())
1026+
mgmtControlPlane = framework.GetKubeadmControlPlaneByCluster(ctx, framework.GetKubeadmControlPlaneByClusterInput{
1027+
Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
1028+
ClusterName: mgmtCluster.Name,
1029+
Namespace: mgmtCluster.Namespace,
1030+
})
1031+
Expect(mgmtControlPlane).ToNot(BeNil())
10301032

1031-
ginkgo.By("Deleting the management cluster")
1032-
deleteCluster(ctx, mgmtCluster)
1033+
ginkgo.By("Deleting the management cluster")
1034+
deleteCluster(ctx, mgmtCluster)
10331035

1034-
ginkgo.By("Deleting peering connection")
1035-
Expect(shared.DeletePeering(e2eCtx, *cPeering.VpcPeeringConnectionId)).To(BeTrue())
1036+
ginkgo.By("Deleting peering connection")
1037+
Expect(shared.DeletePeering(e2eCtx, *cPeering.VpcPeeringConnectionId)).To(BeTrue())
10361038

1037-
ginkgo.By("Deleting the workload cluster infrastructure")
1038-
wlClusterInfra.DeleteInfrastructure()
1039+
ginkgo.By("Deleting the workload cluster infrastructure")
1040+
wlClusterInfra.DeleteInfrastructure()
10391041

1040-
ginkgo.By("Deleting the management cluster infrastructure")
1041-
mgmtClusterInfra.DeleteInfrastructure()
1042+
ginkgo.By("Deleting the management cluster infrastructure")
1043+
mgmtClusterInfra.DeleteInfrastructure()
1044+
}
10421045
})
10431046
})
10441047
})

0 commit comments

Comments
 (0)