diff --git a/test/e2e/upgrade.go b/test/e2e/upgrade.go index d22ea710a429..52ac59d9ef39 100644 --- a/test/e2e/upgrade.go +++ b/test/e2e/upgrade.go @@ -60,6 +60,8 @@ func runSimpleUpgradeFlowWorkerNodeVersionForBareMetal(test *framework.ClusterE2 test.ValidateHardwareDecommissioned() } +// runInPlaceUpgradeFlow makes use of the new ValidateClusterState method instead of ValidateCluster, but we should incorporate this +// in runSimpleUpgradeFlow itself. func runInPlaceUpgradeFlow(test *framework.ClusterE2ETest, clusterOpts ...framework.ClusterE2ETestOpt) { test.CreateCluster() test.UpgradeClusterWithNewConfig(clusterOpts) diff --git a/test/e2e/vsphere_test.go b/test/e2e/vsphere_test.go index 94cf831a70b1..989af4fa7657 100644 --- a/test/e2e/vsphere_test.go +++ b/test/e2e/vsphere_test.go @@ -2723,6 +2723,66 @@ func TestVSphereKubernetes129Ubuntu2004To2204Upgrade(t *testing.T) { ) } +func TestVSphereKubernetes127UbuntuTo128InPlaceUpgradeCPOnly(t *testing.T) { + provider := framework.NewVSphere(t, framework.WithUbuntu127()) + kube127 := v1alpha1.Kube127 + kube128 := v1alpha1.Kube128 + test := framework.NewClusterE2ETest( + t, + provider, + framework.WithEnvVar(features.VSphereInPlaceEnvVar, "true"), + ).WithClusterConfig( + api.ClusterToConfigFiller( + api.WithKubernetesVersion(kube127), + api.WithControlPlaneCount(1), + api.WithWorkerNodeCount(1), + api.WithWorkerKubernetesVersion(nodeGroupLabel1, &kube127), + api.WithStackedEtcdTopology(), + api.WithInPlaceUpgradeStrategy(), + ), + api.VSphereToConfigFiller( + api.RemoveEtcdVsphereMachineConfig(), + ), + provider.WithKubeVersionAndOS(v1alpha1.Kube127, framework.Ubuntu2004, nil), + ) + runInPlaceUpgradeFlow( + test, + framework.WithClusterUpgrade(api.WithKubernetesVersion(kube128)), + provider.WithProviderUpgrade(provider.Ubuntu128TemplateForMachineConfig(providers.GetControlPlaneNodeName(test.ClusterName))), + ) +} + +func TestVSphereKubernetes127UbuntuTo128InPlaceUpgradeWorkerOnly(t *testing.T) { + provider := framework.NewVSphere(t, framework.WithUbuntu127()) + kube127 := v1alpha1.Kube127 + kube128 := v1alpha1.Kube128 + test := framework.NewClusterE2ETest( + t, + provider, + framework.WithEnvVar(features.VSphereInPlaceEnvVar, "true"), + ).WithClusterConfig( + api.ClusterToConfigFiller( + api.WithKubernetesVersion(kube128), + api.WithControlPlaneCount(1), + api.WithWorkerNodeCount(1), + api.WithWorkerKubernetesVersion(nodeGroupLabel1, &kube127), + api.WithStackedEtcdTopology(), + api.WithInPlaceUpgradeStrategy(), + ), + api.VSphereToConfigFiller( + api.RemoveEtcdVsphereMachineConfig(), + ), + ) + test.UpdateClusterConfig( + provider.WithKubeVersionAndOSMachineConfig(providers.GetControlPlaneNodeName(test.ClusterName), kube128, framework.Ubuntu2004), + ) + runInPlaceUpgradeFlow( + test, + framework.WithClusterUpgrade(api.WithWorkerKubernetesVersion(nodeGroupLabel1, &kube128)), + provider.WithProviderUpgrade(provider.Ubuntu128Template()), // this will just set everything to 1.28 as expected + ) +} + func TestVSphereKubernetes127UbuntuTo128UpgradeCiliumPolicyEnforcementMode(t *testing.T) { provider := framework.NewVSphere(t, framework.WithUbuntu127()) test := framework.NewClusterE2ETest( diff --git a/test/framework/vsphere.go b/test/framework/vsphere.go index 013304a61c8c..6e4b9ec28c06 100644 --- a/test/framework/vsphere.go +++ b/test/framework/vsphere.go @@ -385,6 +385,16 @@ func (v *VSphere) WithKubeVersionAndOS(kubeVersion anywherev1.KubernetesVersion, ) } +// WithKubeVersionAndOSMachineConfig returns a cluster config filler that sets the cluster kube version and the right template for a specific +// vsphere machine config. +func (v *VSphere) WithKubeVersionAndOSMachineConfig(name string, kubeVersion anywherev1.KubernetesVersion, os OS) api.ClusterConfigFiller { + return api.JoinClusterConfigFillers( + api.VSphereToConfigFiller( + v.templateForKubeVersionAndOSMachineConfig(name, kubeVersion, os), + ), + ) +} + // WithUbuntu125 returns a cluster config filler that sets the kubernetes version of the cluster to 1.25 // as well as the right ubuntu template and osFamily for all VSphereMachineConfigs. func (v *VSphere) WithUbuntu125() api.ClusterConfigFiller { @@ -452,6 +462,12 @@ func (v *VSphere) templateForKubeVersionAndOS(kubeVersion anywherev1.KubernetesV return api.WithTemplateForAllMachines(template) } +// templateForKubeVersionAndOSMachineConfig returns a vSphere filler for the given OS and Kubernetes version for a specific machine config. +func (v *VSphere) templateForKubeVersionAndOSMachineConfig(name string, kubeVersion anywherev1.KubernetesVersion, os OS) api.VSphereFiller { + template := v.templateForDevRelease(kubeVersion, os) + return api.WithMachineTemplate(name, template) +} + // Ubuntu125Template returns vsphere filler for 1.25 Ubuntu. func (v *VSphere) Ubuntu125Template() api.VSphereFiller { return v.templateForKubeVersionAndOS(anywherev1.Kube125, Ubuntu2004, nil) @@ -477,6 +493,11 @@ func (v *VSphere) Ubuntu129Template() api.VSphereFiller { return v.templateForKubeVersionAndOS(anywherev1.Kube129, Ubuntu2004, nil) } +// Ubuntu128TemplateForMachineConfig returns vsphere filler for 1.28 Ubuntu for a specific machine config. +func (v *VSphere) Ubuntu128TemplateForMachineConfig(name string) api.VSphereFiller { + return v.templateForKubeVersionAndOSMachineConfig(name, anywherev1.Kube128, Ubuntu2004) +} + // Ubuntu2204Kubernetes126Template returns vsphere filler for 1.26 Ubuntu 22.04. func (v *VSphere) Ubuntu2204Kubernetes126Template() api.VSphereFiller { return v.templateForKubeVersionAndOS(anywherev1.Kube126, Ubuntu2204, nil)