From db8901051c63d02dfdd04b875812f7efdfb50383 Mon Sep 17 00:00:00 2001 From: willie-yao Date: Thu, 9 May 2024 22:58:18 +0000 Subject: [PATCH] Allow control plane count to be configurable in clusterctl upgrade test. --- test/e2e/clusterctl_upgrade.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/e2e/clusterctl_upgrade.go b/test/e2e/clusterctl_upgrade.go index 7168b71d66f2..6bd6a754886c 100644 --- a/test/e2e/clusterctl_upgrade.go +++ b/test/e2e/clusterctl_upgrade.go @@ -130,6 +130,9 @@ type ClusterctlUpgradeSpecInput struct { // If not set, the test will upgrade once to the v1beta1 contract. // For some examples see clusterctl_upgrade_test.go Upgrades []ClusterctlUpgradeSpecInputUpgrade + + // ControlPlaneMachineCount specifies the number of control plane machines to create in the workload cluster. + ControlPlaneMachineCount *int64 } // ClusterctlUpgradeSpecInputUpgrade defines an upgrade. @@ -388,6 +391,11 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg kubernetesVersion = input.E2EConfig.GetVariable(KubernetesVersion) } controlPlaneMachineCount := ptr.To[int64](1) + + // Don't set controlPlaneMachineCount to 0 to satisfy the validation in the cluster template. + if input.ControlPlaneMachineCount != nil && input.ControlPlaneMachineCount != ptr.To[int64](0) { + controlPlaneMachineCount = input.ControlPlaneMachineCount + } workerMachineCount := ptr.To[int64](1) log.Logf("Creating the workload cluster with name %q using the %q template (Kubernetes %s, %d control-plane machines, %d worker machines)", @@ -436,6 +444,11 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg expectedMachinePoolNodeCount := calculateExpectedMachinePoolNodeCount(ctx, managementClusterProxy.GetClient(), workloadClusterUnstructured, coreCAPIStorageVersion) expectedMachinePoolMachineCount, err := calculateExpectedMachinePoolMachineCount(ctx, managementClusterProxy.GetClient(), workloadClusterNamespace, workloadClusterName) Expect(err).ToNot(HaveOccurred()) + + // Account for clusters that have a control plane count of 0. + if input.ControlPlaneMachineCount != nil && input.ControlPlaneMachineCount == ptr.To[int64](0) { + controlPlaneMachineCount = input.ControlPlaneMachineCount + } expectedMachineCount := *controlPlaneMachineCount + expectedMachineDeploymentMachineCount + expectedMachinePoolMachineCount Byf("Expect %d Machines and %d MachinePool replicas to exist", expectedMachineCount, expectedMachinePoolNodeCount)