Skip to content

Commit

Permalink
Merge pull request #6636 from Nordix/clusterclt-upgrade-test-hook/moh…
Browse files Browse the repository at this point in the history
…ammed

🌱 add preCreateCluster hook and CNIPath to e2e clusterctl upgrade test
  • Loading branch information
k8s-ci-robot authored Sep 29, 2022
2 parents 6c15f27 + c5a7611 commit dca818a
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions test/e2e/clusterctl_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,16 @@ type ClusterctlUpgradeSpecInput struct {
// UpgradeClusterctlVariables can be used to set additional variables for clusterctl upgrade.
UpgradeClusterctlVariables map[string]string
SkipCleanup bool
ControlPlaneWaiters clusterctl.ControlPlaneWaiters
PreInit func(managementClusterProxy framework.ClusterProxy)
PreUpgrade func(managementClusterProxy framework.ClusterProxy)
PostUpgrade func(managementClusterProxy framework.ClusterProxy)
MgmtFlavor string
WorkloadFlavor string
// PreWaitForCluster is a function that can be used as a hook to apply extra resources (that cannot be part of the template) in the generated namespace hosting the cluster
// This function is called after applying the cluster template and before waiting for the cluster resources.
PreWaitForCluster func(managementClusterProxy framework.ClusterProxy, workloadClusterNamespace string, workloadClusterName string)
ControlPlaneWaiters clusterctl.ControlPlaneWaiters
PreInit func(managementClusterProxy framework.ClusterProxy)
PreUpgrade func(managementClusterProxy framework.ClusterProxy)
PostUpgrade func(managementClusterProxy framework.ClusterProxy)
MgmtFlavor string
CNIManifestPath string
WorkloadFlavor string
}

// ClusterctlUpgradeSpec implements a test that verifies clusterctl upgrade of a management cluster.
Expand Down Expand Up @@ -193,6 +197,12 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
ControlPlaneMachineCount: pointer.Int64Ptr(1),
WorkerMachineCount: pointer.Int64Ptr(1),
},
PreWaitForCluster: func() {
if input.PreWaitForCluster != nil {
input.PreWaitForCluster(input.BootstrapClusterProxy, managementClusterNamespace.Name, managementClusterName)
}
},
CNIManifestPath: input.CNIManifestPath,
ControlPlaneWaiters: input.ControlPlaneWaiters,
WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"),
WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"),
Expand Down Expand Up @@ -290,6 +300,11 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
log.Logf("Applying the cluster template yaml to the cluster")
Expect(managementClusterProxy.Apply(ctx, workloadClusterTemplate)).To(Succeed())

if input.PreWaitForCluster != nil {
By("Running PreWaitForCluster steps against the management cluster")
input.PreWaitForCluster(managementClusterProxy, testNamespace.Name, workLoadClusterName)
}

By("Waiting for the machines to exists")
Eventually(func() (int64, error) {
var n int64
Expand Down

0 comments on commit dca818a

Please sign in to comment.