Skip to content

Commit 3aca5b3

Browse files
authored
Merge pull request kubernetes-sigs#7969 from fabriziopandini/improve-quick-start-test
🌱 Improve quick-start test supporting scenarios with more than one infrastructure provider
2 parents ea506ae + 1cd2e94 commit 3aca5b3

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

test/e2e/quick_start.go

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,31 @@ type QuickStartSpecInput struct {
3939
BootstrapClusterProxy framework.ClusterProxy
4040
ArtifactFolder string
4141
SkipCleanup bool
42-
ControlPlaneWaiters clusterctl.ControlPlaneWaiters
42+
43+
// InfrastructureProvider allows to specify the infrastructure provider to be used when looking for
44+
// cluster templates.
45+
// If not set, clusterctl will look at the infrastructure provider installed in the management cluster;
46+
// if only one infrastructure provider exists, it will be used, otherwise the operation will fail if more than one exists.
47+
InfrastructureProvider *string
4348

4449
// Flavor, if specified is the template flavor used to create the cluster for testing.
45-
// If not specified, and the e2econfig variable IPFamily is IPV6, then "ipv6" is used,
46-
// otherwise the default flavor is used.
47-
Flavor *string
50+
// If not specified, the default flavor for the selected infrastructure provider is used.
51+
Flavor *string
52+
53+
// ControlPlaneMachineCount defines the number of control plane machines to be added to the workload cluster.
54+
// If not specified, 1 will be used.
55+
ControlPlaneMachineCount *int64
56+
57+
// WorkerMachineCount defines number of worker machines to be added to the workload cluster.
58+
// If not specified, 1 will be used.
59+
WorkerMachineCount *int64
60+
61+
// Allows to inject functions to be run while waiting for the control plane to be initialized,
62+
// which unblocks CNI installation, and for the control plane machines to be ready (after CNI installation).
63+
ControlPlaneWaiters clusterctl.ControlPlaneWaiters
64+
65+
// Allows to inject a function to be run after machines are provisioned.
66+
// If not specified, this is a no-op.
4867
PostMachinesProvisioned func(managementClusterProxy framework.ClusterProxy, workloadClusterNamespace, workloadClusterName string)
4968
}
5069

@@ -79,24 +98,40 @@ func QuickStartSpec(ctx context.Context, inputGetter func() QuickStartSpecInput)
7998
It("Should create a workload cluster", func() {
8099
By("Creating a workload cluster")
81100

101+
infrastructureProvider := clusterctl.DefaultInfrastructureProvider
102+
if input.InfrastructureProvider != nil {
103+
infrastructureProvider = *input.InfrastructureProvider
104+
}
105+
82106
flavor := clusterctl.DefaultFlavor
83107
if input.Flavor != nil {
84108
flavor = *input.Flavor
85109
}
110+
111+
controlPlaneMachineCount := pointer.Int64(1)
112+
if input.ControlPlaneMachineCount != nil {
113+
controlPlaneMachineCount = input.ControlPlaneMachineCount
114+
}
115+
116+
workerMachineCount := pointer.Int64(1)
117+
if input.WorkerMachineCount != nil {
118+
workerMachineCount = input.WorkerMachineCount
119+
}
120+
86121
clusterName := fmt.Sprintf("%s-%s", specName, util.RandomString(6))
87122
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
88123
ClusterProxy: input.BootstrapClusterProxy,
89124
ConfigCluster: clusterctl.ConfigClusterInput{
90125
LogFolder: filepath.Join(input.ArtifactFolder, "clusters", input.BootstrapClusterProxy.GetName()),
91126
ClusterctlConfigPath: input.ClusterctlConfigPath,
92127
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
93-
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
128+
InfrastructureProvider: infrastructureProvider,
94129
Flavor: flavor,
95130
Namespace: namespace.Name,
96131
ClusterName: clusterName,
97132
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
98-
ControlPlaneMachineCount: pointer.Int64(1),
99-
WorkerMachineCount: pointer.Int64(1),
133+
ControlPlaneMachineCount: controlPlaneMachineCount,
134+
WorkerMachineCount: workerMachineCount,
100135
},
101136
ControlPlaneWaiters: input.ControlPlaneWaiters,
102137
WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"),

0 commit comments

Comments
 (0)