From 2e7f5ba9515138b427a8ff729772549dbcba31a6 Mon Sep 17 00:00:00 2001 From: Saurabh Parekh Date: Tue, 13 Feb 2024 18:10:12 -0800 Subject: [PATCH] Add inplace upgrade E2E tests for scaling nodes in vsphere (#7572) * Add inplace upgrade E2E tests for scaling nodes in vsphere * Rename tests and address comments --- internal/pkg/api/vsphere.go | 11 ++++ test/e2e/upgrade.go | 8 +++ test/e2e/vsphere_test.go | 112 ++++++++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) diff --git a/internal/pkg/api/vsphere.go b/internal/pkg/api/vsphere.go index 54023bb404ee..1e599f72f44c 100644 --- a/internal/pkg/api/vsphere.go +++ b/internal/pkg/api/vsphere.go @@ -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) + } + } + } +} diff --git a/test/e2e/upgrade.go b/test/e2e/upgrade.go index d4cac4e6063b..d22ea710a429 100644 --- a/test/e2e/upgrade.go +++ b/test/e2e/upgrade.go @@ -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")) diff --git a/test/e2e/vsphere_test.go b/test/e2e/vsphere_test.go index d18b3bc0fb22..61aca70f63fa 100644 --- a/test/e2e/vsphere_test.go +++ b/test/e2e/vsphere_test.go @@ -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)