Skip to content

Commit

Permalink
Allow control plane count to be configurable in clusterctl upgrade test.
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed May 10, 2024
1 parent ab02db3 commit db89010
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/e2e/clusterctl_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit db89010

Please sign in to comment.