From 8e30ce0d37cdb141f3bf302cf5c233b486df14d5 Mon Sep 17 00:00:00 2001 From: mboukhalfa Date: Tue, 27 Sep 2022 16:14:00 +0300 Subject: [PATCH] add PreWaitForCluster hook and CNIPath to e2e clusterctl upgrade test --- test/e2e/clusterctl_upgrade.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/test/e2e/clusterctl_upgrade.go b/test/e2e/clusterctl_upgrade.go index 1a700d3409ae..00f91789206e 100644 --- a/test/e2e/clusterctl_upgrade.go +++ b/test/e2e/clusterctl_upgrade.go @@ -74,12 +74,15 @@ 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 + WorkloadFlavor string } // ClusterctlUpgradeSpec implements a test that verifies clusterctl upgrade of a management cluster. @@ -193,6 +196,10 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg ControlPlaneMachineCount: pointer.Int64Ptr(1), WorkerMachineCount: pointer.Int64Ptr(1), }, + PreWaitForCluster: func() { + 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"), @@ -290,6 +297,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