Skip to content

Commit

Permalink
Improve quick-start test
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Jan 22, 2023
1 parent 7527262 commit 6a8d983
Showing 1 changed file with 42 additions and 7 deletions.
49 changes: 42 additions & 7 deletions test/e2e/quick_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,31 @@ type QuickStartSpecInput struct {
BootstrapClusterProxy framework.ClusterProxy
ArtifactFolder string
SkipCleanup bool
ControlPlaneWaiters clusterctl.ControlPlaneWaiters

// InfrastructureProvider allows to specify the infrastructure provider to be used when looking for
// cluster templates.
// If not set, clusterctl will look at the infrastructure provider installed in the management cluster;
// if only one infrastructure provide exists, it will be used, other wise the operation will fail if more than one exists.
InfrastructureProvider *string

// Flavor, if specified is the template flavor used to create the cluster for testing.
// If not specified, and the e2econfig variable IPFamily is IPV6, then "ipv6" is used,
// otherwise the default flavor is used.
Flavor *string
// If not specified, the default flavor for the selected infrastructure provider is used.
Flavor *string

// ControlPlaneMachineCount defines the number of control plane machines to be added to the workload cluster.
// If not specified, 1 will be used.
ControlPlaneMachineCount *int64

// WorkerMachineCount defines number of worker machines to be added to the workload cluster.
// If not specified, 1 will be used.
WorkerMachineCount *int64

// Allows to inject functions to be run while waiting for the control plane to be initialized,
// which unblocks CNI installation, and for the control plane machines to be ready (after CNI installation).
ControlPlaneWaiters clusterctl.ControlPlaneWaiters

// Allows to inject a function to be run after machines are provisioned.
// If not specified, this is a no-op.
PostMachinesProvisioned func(managementClusterProxy framework.ClusterProxy, workloadClusterNamespace, workloadClusterName string)
}

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

infrastructureProvider := clusterctl.DefaultInfrastructureProvider
if input.InfrastructureProvider != nil {
infrastructureProvider = *input.InfrastructureProvider
}

flavor := clusterctl.DefaultFlavor
if input.Flavor != nil {
flavor = *input.Flavor
}

controlPlaneMachineCount := pointer.Int64(1)
if input.ControlPlaneMachineCount != nil {
controlPlaneMachineCount = input.ControlPlaneMachineCount
}

workerMachineCount := pointer.Int64(1)
if input.WorkerMachineCount != nil {
workerMachineCount = input.WorkerMachineCount
}

clusterName := fmt.Sprintf("%s-%s", specName, util.RandomString(6))
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
ClusterProxy: input.BootstrapClusterProxy,
ConfigCluster: clusterctl.ConfigClusterInput{
LogFolder: filepath.Join(input.ArtifactFolder, "clusters", input.BootstrapClusterProxy.GetName()),
ClusterctlConfigPath: input.ClusterctlConfigPath,
KubeconfigPath: input.BootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
InfrastructureProvider: infrastructureProvider,
Flavor: flavor,
Namespace: namespace.Name,
ClusterName: clusterName,
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
ControlPlaneMachineCount: pointer.Int64(1),
WorkerMachineCount: pointer.Int64(1),
ControlPlaneMachineCount: controlPlaneMachineCount,
WorkerMachineCount: workerMachineCount,
},
ControlPlaneWaiters: input.ControlPlaneWaiters,
WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"),
Expand Down

0 comments on commit 6a8d983

Please sign in to comment.