Skip to content

Commit 433c7d7

Browse files
committed
Use helper function to create cluster template input
1 parent 9259e5b commit 433c7d7

File tree

5 files changed

+289
-301
lines changed

5 files changed

+289
-301
lines changed

test/e2e/azure_privatecluster.go

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import (
4242
"sigs.k8s.io/cluster-api-provider-azure/azure"
4343
azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure"
4444
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
45-
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
4645
"sigs.k8s.io/cluster-api/test/framework"
4746
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
4847
"sigs.k8s.io/cluster-api/util"
@@ -133,26 +132,20 @@ func AzurePrivateClusterSpec(ctx context.Context, inputGetter func() AzurePrivat
133132
Expect(os.Setenv(AzureNodeSubnetCidr, "10.255.1.0/24")).To(Succeed())
134133
Expect(os.Setenv(AzureBastionSubnetCidr, "10.255.255.224/27")).To(Succeed())
135134
result := &clusterctl.ApplyClusterTemplateAndWaitResult{}
136-
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
137-
ClusterProxy: publicClusterProxy,
138-
ConfigCluster: clusterctl.ConfigClusterInput{
139-
LogFolder: filepath.Join(input.ArtifactFolder, "clusters", publicClusterProxy.GetName()),
140-
ClusterctlConfigPath: input.ClusterctlConfigPath,
141-
KubeconfigPath: publicClusterProxy.GetKubeconfigPath(),
142-
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
143-
Flavor: "private",
144-
Namespace: input.Namespace.Name,
145-
ClusterName: clusterName,
146-
KubernetesVersion: input.E2EConfig.GetVariable(capi_e2e.KubernetesVersion),
147-
ControlPlaneMachineCount: pointer.Int64(3),
148-
WorkerMachineCount: pointer.Int64(1),
149-
},
150-
WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-private-cluster"),
151-
WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane-ha"),
152-
WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
153-
// NOTE: We don't add control plane waiters here because Helm install will fail since the apiserver is private and not reachable from the prow cluster.
154-
// As a workaround, we use still ClusterResourceSet to install CNI on the private cluster until a Helm integration is available.
155-
}, result)
135+
136+
// NOTE: We don't add control plane waiters here because Helm install will fail since the apiserver is private and not reachable from the prow cluster.
137+
// As a workaround, we use still ClusterResourceSet to install CNI on the private cluster until a Helm integration is available.
138+
clusterctl.ApplyClusterTemplateAndWait(ctx, createApplyClusterTemplateInput(
139+
specName,
140+
withClusterProxy(publicClusterProxy),
141+
withFlavor("private"),
142+
withNamespace(input.Namespace.Name),
143+
withClusterName(clusterName),
144+
withControlPlaneMachineCount(3),
145+
withWorkerMachineCount(1),
146+
withClusterInterval(specName, "wait-private-cluster"),
147+
withControlPlaneInterval(specName, "wait-control-plane-ha"),
148+
), result)
156149
cluster = result.Cluster
157150

158151
Expect(cluster).NotTo(BeNil())

test/e2e/azure_selfhosted.go

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
. "github.com/onsi/gomega"
3030
corev1 "k8s.io/api/core/v1"
3131
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
32-
"k8s.io/utils/pointer"
3332
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3433
clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
3534
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
@@ -107,25 +106,15 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
107106
// Tracking support for cert manager: https://github.com/jetstack/cert-manager/issues/3606
108107
It("Should pivot the bootstrap cluster to a self-hosted cluster", func() {
109108
By("Creating a workload cluster")
110-
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
111-
ClusterProxy: input.BootstrapClusterProxy,
112-
ConfigCluster: clusterctl.ConfigClusterInput{
113-
LogFolder: filepath.Join(input.ArtifactFolder, "clusters", input.BootstrapClusterProxy.GetName()),
114-
ClusterctlConfigPath: input.ClusterctlConfigPath,
115-
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
116-
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
117-
Flavor: "management",
118-
Namespace: namespace.Name,
119-
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
120-
KubernetesVersion: input.E2EConfig.GetVariable(capi_e2e.KubernetesVersion),
121-
ControlPlaneMachineCount: pointer.Int64(1),
122-
WorkerMachineCount: pointer.Int64(1),
123-
},
124-
WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"),
125-
WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"),
126-
WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
127-
ControlPlaneWaiters: input.ControlPlaneWaiters,
128-
}, clusterResources)
109+
clusterctl.ApplyClusterTemplateAndWait(ctx, createApplyClusterTemplateInput(
110+
specName,
111+
withFlavor("management"),
112+
withNamespace(namespace.Name),
113+
withClusterName(fmt.Sprintf("%s-%s", specName, util.RandomString(6))),
114+
withControlPlaneMachineCount(1),
115+
withWorkerMachineCount(1),
116+
withControlPlaneWaiters(input.ControlPlaneWaiters),
117+
), clusterResources)
129118

130119
By("Turning the workload cluster into a management cluster")
131120
cluster := clusterResources.Cluster

0 commit comments

Comments
 (0)