Skip to content

Commit dca818a

Browse files
authored
Merge pull request #6636 from Nordix/clusterclt-upgrade-test-hook/mohammed
🌱 add preCreateCluster hook and CNIPath to e2e clusterctl upgrade test
2 parents 6c15f27 + c5a7611 commit dca818a

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

test/e2e/clusterctl_upgrade.go

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,16 @@ type ClusterctlUpgradeSpecInput struct {
7474
// UpgradeClusterctlVariables can be used to set additional variables for clusterctl upgrade.
7575
UpgradeClusterctlVariables map[string]string
7676
SkipCleanup bool
77-
ControlPlaneWaiters clusterctl.ControlPlaneWaiters
78-
PreInit func(managementClusterProxy framework.ClusterProxy)
79-
PreUpgrade func(managementClusterProxy framework.ClusterProxy)
80-
PostUpgrade func(managementClusterProxy framework.ClusterProxy)
81-
MgmtFlavor string
82-
WorkloadFlavor string
77+
// 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
78+
// This function is called after applying the cluster template and before waiting for the cluster resources.
79+
PreWaitForCluster func(managementClusterProxy framework.ClusterProxy, workloadClusterNamespace string, workloadClusterName string)
80+
ControlPlaneWaiters clusterctl.ControlPlaneWaiters
81+
PreInit func(managementClusterProxy framework.ClusterProxy)
82+
PreUpgrade func(managementClusterProxy framework.ClusterProxy)
83+
PostUpgrade func(managementClusterProxy framework.ClusterProxy)
84+
MgmtFlavor string
85+
CNIManifestPath string
86+
WorkloadFlavor string
8387
}
8488

8589
// ClusterctlUpgradeSpec implements a test that verifies clusterctl upgrade of a management cluster.
@@ -193,6 +197,12 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
193197
ControlPlaneMachineCount: pointer.Int64Ptr(1),
194198
WorkerMachineCount: pointer.Int64Ptr(1),
195199
},
200+
PreWaitForCluster: func() {
201+
if input.PreWaitForCluster != nil {
202+
input.PreWaitForCluster(input.BootstrapClusterProxy, managementClusterNamespace.Name, managementClusterName)
203+
}
204+
},
205+
CNIManifestPath: input.CNIManifestPath,
196206
ControlPlaneWaiters: input.ControlPlaneWaiters,
197207
WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"),
198208
WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"),
@@ -290,6 +300,11 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
290300
log.Logf("Applying the cluster template yaml to the cluster")
291301
Expect(managementClusterProxy.Apply(ctx, workloadClusterTemplate)).To(Succeed())
292302

303+
if input.PreWaitForCluster != nil {
304+
By("Running PreWaitForCluster steps against the management cluster")
305+
input.PreWaitForCluster(managementClusterProxy, testNamespace.Name, workLoadClusterName)
306+
}
307+
293308
By("Waiting for the machines to exists")
294309
Eventually(func() (int64, error) {
295310
var n int64

0 commit comments

Comments
 (0)