Skip to content

Commit

Permalink
Add inplace upgrade E2E tests for scaling nodes in vsphere (#7572)
Browse files Browse the repository at this point in the history
* Add inplace upgrade E2E tests for scaling nodes in vsphere

* Rename tests and address comments
  • Loading branch information
sp1999 authored Feb 14, 2024
1 parent d3211ae commit 2e7f5ba
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/pkg/api/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,14 @@ func WithVSphereMachineConfig(name string, fillers ...VSphereMachineConfigFiller
FillVSphereMachineConfig(m, fillers...)
}
}

// RemoveEtcdVsphereMachineConfig removes the etcd VSphereMachineConfig from the cluster spec.
func RemoveEtcdVsphereMachineConfig() VSphereFiller {
return func(config VSphereConfig) {
for k, m := range config.machineConfigs {
if strings.HasSuffix(m.Name, "-etcd") {
delete(config.machineConfigs, k)
}
}
}
}
8 changes: 8 additions & 0 deletions test/e2e/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ func runSimpleUpgradeFlowWorkerNodeVersionForBareMetal(test *framework.ClusterE2
test.ValidateHardwareDecommissioned()
}

func runInPlaceUpgradeFlow(test *framework.ClusterE2ETest, clusterOpts ...framework.ClusterE2ETestOpt) {
test.CreateCluster()
test.UpgradeClusterWithNewConfig(clusterOpts)
test.ValidateClusterState()
test.StopIfFailed()
test.DeleteCluster()
}

func runInPlaceUpgradeFlowForBareMetal(test *framework.ClusterE2ETest, clusterOpts ...framework.ClusterE2ETestOpt) {
test.GenerateHardwareConfig()
test.CreateCluster(framework.WithControlPlaneWaitTimeout("20m"))
Expand Down
112 changes: 112 additions & 0 deletions test/e2e/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2475,6 +2475,118 @@ func TestVSphereKubernetes127to128UpgradeFromLatestMinorReleaseBottleRocketAPI(t
)
}

func TestVSphereKubernetes128UbuntuInPlaceCPScaleUp1To3(t *testing.T) {
provider := framework.NewVSphere(t, framework.WithUbuntu128())
test := framework.NewClusterE2ETest(
t,
provider,
framework.WithEnvVar(features.VSphereInPlaceEnvVar, "true"),
).WithClusterConfig(
api.ClusterToConfigFiller(
api.WithKubernetesVersion(v1alpha1.Kube128),
api.WithControlPlaneCount(1),
api.WithWorkerNodeCount(1),
api.WithStackedEtcdTopology(),
api.WithInPlaceUpgradeStrategy(),
),
api.VSphereToConfigFiller(
api.RemoveEtcdVsphereMachineConfig(),
),
provider.WithKubeVersionAndOS(v1alpha1.Kube128, framework.Ubuntu2004, nil),
)
runInPlaceUpgradeFlow(
test,
framework.WithClusterUpgrade(
api.WithControlPlaneCount(3),
api.WithInPlaceUpgradeStrategy(),
),
)
}

func TestVSphereKubernetes128UbuntuInPlaceCPScaleDown3To1(t *testing.T) {
provider := framework.NewVSphere(t, framework.WithUbuntu128())
test := framework.NewClusterE2ETest(
t,
provider,
framework.WithEnvVar(features.VSphereInPlaceEnvVar, "true"),
).WithClusterConfig(
api.ClusterToConfigFiller(
api.WithKubernetesVersion(v1alpha1.Kube128),
api.WithControlPlaneCount(3),
api.WithWorkerNodeCount(1),
api.WithStackedEtcdTopology(),
api.WithInPlaceUpgradeStrategy(),
),
api.VSphereToConfigFiller(
api.RemoveEtcdVsphereMachineConfig(),
),
provider.WithKubeVersionAndOS(v1alpha1.Kube128, framework.Ubuntu2004, nil),
)
runInPlaceUpgradeFlow(
test,
framework.WithClusterUpgrade(
api.WithControlPlaneCount(1),
api.WithInPlaceUpgradeStrategy(),
),
)
}

func TestVSphereKubernetes128UbuntuInPlaceWorkerScaleUp1To2(t *testing.T) {
provider := framework.NewVSphere(t, framework.WithUbuntu128())
test := framework.NewClusterE2ETest(
t,
provider,
framework.WithEnvVar(features.VSphereInPlaceEnvVar, "true"),
).WithClusterConfig(
api.ClusterToConfigFiller(
api.WithKubernetesVersion(v1alpha1.Kube128),
api.WithControlPlaneCount(1),
api.WithWorkerNodeCount(1),
api.WithStackedEtcdTopology(),
api.WithInPlaceUpgradeStrategy(),
),
api.VSphereToConfigFiller(
api.RemoveEtcdVsphereMachineConfig(),
),
provider.WithKubeVersionAndOS(v1alpha1.Kube128, framework.Ubuntu2004, nil),
)
runInPlaceUpgradeFlow(
test,
framework.WithClusterUpgrade(
api.WithWorkerNodeCount(2),
api.WithInPlaceUpgradeStrategy(),
),
)
}

func TestVSphereKubernetes128UbuntuInPlaceWorkerScaleDown2To1(t *testing.T) {
provider := framework.NewVSphere(t, framework.WithUbuntu128())
test := framework.NewClusterE2ETest(
t,
provider,
framework.WithEnvVar(features.VSphereInPlaceEnvVar, "true"),
).WithClusterConfig(
api.ClusterToConfigFiller(
api.WithKubernetesVersion(v1alpha1.Kube128),
api.WithControlPlaneCount(1),
api.WithWorkerNodeCount(2),
api.WithStackedEtcdTopology(),
api.WithInPlaceUpgradeStrategy(),
),
api.VSphereToConfigFiller(
api.RemoveEtcdVsphereMachineConfig(),
),
provider.WithKubeVersionAndOS(v1alpha1.Kube128, framework.Ubuntu2004, nil),
)
runInPlaceUpgradeFlow(
test,
framework.WithClusterUpgrade(
api.WithWorkerNodeCount(1),
api.WithInPlaceUpgradeStrategy(),
),
)
}

// Workload API
func TestVSphereMulticlusterWorkloadClusterAPI(t *testing.T) {
vsphere := framework.NewVSphere(t)
Expand Down

0 comments on commit 2e7f5ba

Please sign in to comment.