Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in place modular upgrade e2e tests #7588

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/e2e/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
60 changes: 60 additions & 0 deletions test/e2e/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
21 changes: 21 additions & 0 deletions test/framework/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Loading