Skip to content

Commit

Permalink
add preCreateCluster hook and CNIPath to e2e clusterctl upgrade test
Browse files Browse the repository at this point in the history
  • Loading branch information
mboukhalfa committed Jun 14, 2022
1 parent 8a6b4c6 commit 6da970e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/e2e/clusterctl_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ type ClusterctlUpgradeSpecInput struct {
// provider contract to use to initialise the secondary management cluster, e.g. `v1alpha3`
InitWithProvidersContract string
SkipCleanup bool
PreCreateCluster func(managementClusterProxy framework.ClusterProxy, managementClusterNamespace string)
PreInit func(managementClusterProxy framework.ClusterProxy)
PreUpgrade func(managementClusterProxy framework.ClusterProxy)
PostUpgrade func(managementClusterProxy framework.ClusterProxy)
MgmtFlavor string
CNIManifestPath string
WorkloadFlavor string
}

Expand Down Expand Up @@ -146,6 +148,12 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg

It("Should create a management cluster and then upgrade all the providers", func() {
By("Creating a workload cluster to be used as a new management cluster")

if input.PreCreateCluster != nil {
By("Running Pre-CreateCluster steps against the bootstrap cluster")
input.PreCreateCluster(input.BootstrapClusterProxy, managementClusterNamespace.Name)
}

// NOTE: given that the bootstrap cluster could be shared by several tests, it is not practical to use it for testing clusterctl upgrades.
// So we are creating a workload cluster that will be used as a new management cluster where to install older version of providers
managementClusterName = fmt.Sprintf("%s-%s", specName, util.RandomString(6))
Expand All @@ -163,6 +171,7 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
ControlPlaneMachineCount: pointer.Int64Ptr(1),
WorkerMachineCount: pointer.Int64Ptr(1),
},
CNIManifestPath: input.CNIManifestPath,
WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"),
WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"),
WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
Expand Down Expand Up @@ -248,6 +257,11 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
log.Logf("Creating the workload cluster with name %q using the %q template (Kubernetes %s, %d control-plane machines, %d worker machines)",
workLoadClusterName, "(default)", kubernetesVersion, *controlPlaneMachineCount, *workerMachineCount)

if input.PreCreateCluster != nil {
By("Running Pre-CreateCluster steps against the management cluster")
input.PreCreateCluster(managementClusterProxy, testNamespace.Name)
}

log.Logf("Getting the cluster template yaml")
workloadClusterTemplate := clusterctl.ConfigClusterWithBinary(ctx, clusterctlBinaryPath, clusterctl.ConfigClusterInput{
// pass reference to the management cluster hosting this test
Expand Down

0 comments on commit 6da970e

Please sign in to comment.