Skip to content

Commit

Permalink
Add in place modular upgrade e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vivek-koppuru committed Feb 14, 2024
1 parent 4a383c3 commit 8efec27
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
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

0 comments on commit 8efec27

Please sign in to comment.