Skip to content

Commit 4c6f899

Browse files
committed
Allow control plane count to be configurable in clusterctl upgrade test.
1 parent ab02db3 commit 4c6f899

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/e2e/clusterctl_upgrade.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ type ClusterctlUpgradeSpecInput struct {
130130
// If not set, the test will upgrade once to the v1beta1 contract.
131131
// For some examples see clusterctl_upgrade_test.go
132132
Upgrades []ClusterctlUpgradeSpecInputUpgrade
133+
134+
// ControlPlaneMachineCount specifies the number of control plane machines to create in the workload cluster.
135+
ControlPlaneMachineCount *int64
133136
}
134137

135138
// ClusterctlUpgradeSpecInputUpgrade defines an upgrade.
@@ -388,6 +391,11 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
388391
kubernetesVersion = input.E2EConfig.GetVariable(KubernetesVersion)
389392
}
390393
controlPlaneMachineCount := ptr.To[int64](1)
394+
395+
// Don't set controlPlaneMachineCount to 0 to satisfy the validation in the cluster template.
396+
if input.ControlPlaneMachineCount != nil && *input.ControlPlaneMachineCount != int64(0) {
397+
controlPlaneMachineCount = input.ControlPlaneMachineCount
398+
}
391399
workerMachineCount := ptr.To[int64](1)
392400

393401
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
436444
expectedMachinePoolNodeCount := calculateExpectedMachinePoolNodeCount(ctx, managementClusterProxy.GetClient(), workloadClusterUnstructured, coreCAPIStorageVersion)
437445
expectedMachinePoolMachineCount, err := calculateExpectedMachinePoolMachineCount(ctx, managementClusterProxy.GetClient(), workloadClusterNamespace, workloadClusterName)
438446
Expect(err).ToNot(HaveOccurred())
447+
448+
// Account for clusters that have a control plane count of 0.
449+
if input.ControlPlaneMachineCount != nil && *input.ControlPlaneMachineCount == int64(0) {
450+
controlPlaneMachineCount = input.ControlPlaneMachineCount
451+
}
439452
expectedMachineCount := *controlPlaneMachineCount + expectedMachineDeploymentMachineCount + expectedMachinePoolMachineCount
440453

441454
Byf("Expect %d Machines and %d MachinePool replicas to exist", expectedMachineCount, expectedMachinePoolNodeCount)

0 commit comments

Comments
 (0)