Skip to content

Commit

Permalink
Add e2e tests for workload cluster k8s inplace upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
sp1999 committed Feb 14, 2024
1 parent 4a383c3 commit f5e2bf0
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 2 deletions.
14 changes: 13 additions & 1 deletion test/e2e/multicluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,16 @@ func runWorkloadClusterUpgradeFlowWithAPIForBareMetal(test *framework.Multiclust
})
test.ManagementCluster.StopIfFailed()
test.DeleteManagementCluster()
}
}

func runInPlaceWorkloadUpgradeFlow(test *framework.MulticlusterE2ETest, clusterOpts ...framework.ClusterE2ETestOpt) {
test.CreateManagementCluster()
test.RunInWorkloadClusters(func(w *framework.WorkloadCluster) {
w.CreateCluster()
w.UpgradeClusterWithNewConfig(clusterOpts)
w.ValidateClusterState()
w.StopIfFailed()
w.DeleteCluster()
})
test.DeleteManagementCluster()
}
141 changes: 141 additions & 0 deletions test/e2e/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3555,6 +3555,147 @@ func TestVSphereKubernetes128UbuntuInPlaceWorkerScaleDown2To1(t *testing.T) {
)
}

func TestVSphereInPlaceUpgradeMulticlusterWorkloadClusterK8sUpgrade125To126(t *testing.T) {
provider := framework.NewVSphere(t, framework.WithUbuntu125())
managementCluster := framework.NewClusterE2ETest(
t,
provider,
framework.WithEnvVar(features.VSphereInPlaceEnvVar, "true"),
).WithClusterConfig(
api.ClusterToConfigFiller(
api.WithKubernetesVersion(v1alpha1.Kube125),
api.WithStackedEtcdTopology(),
api.WithInPlaceUpgradeStrategy(),
),
api.VSphereToConfigFiller(
api.RemoveEtcdVsphereMachineConfig(),
),
provider.WithKubeVersionAndOS(v1alpha1.Kube125, framework.Ubuntu2004, nil),
)
test := framework.NewMulticlusterE2ETest(t, managementCluster)
test.WithWorkloadClusters(
framework.NewClusterE2ETest(
t,
provider,
framework.WithClusterName(test.NewWorkloadClusterName()),
framework.WithEnvVar(features.VSphereInPlaceEnvVar, "true"),
).WithClusterConfig(
api.ClusterToConfigFiller(
api.WithManagementCluster(managementCluster.ClusterName),
api.WithKubernetesVersion(v1alpha1.Kube125),
api.WithStackedEtcdTopology(),
api.WithInPlaceUpgradeStrategy(),
),
api.VSphereToConfigFiller(
api.RemoveEtcdVsphereMachineConfig(),
),
provider.WithKubeVersionAndOS(v1alpha1.Kube125, framework.Ubuntu2004, nil),
),
)
runInPlaceWorkloadUpgradeFlow(
test,
framework.WithClusterUpgrade(
api.WithKubernetesVersion(v1alpha1.Kube126),
api.WithInPlaceUpgradeStrategy(),
),
provider.WithProviderUpgrade(provider.Ubuntu126Template()),
)
}

func TestVSphereInPlaceUpgradeMulticlusterWorkloadClusterK8sUpgrade126To127(t *testing.T) {
provider := framework.NewVSphere(t, framework.WithUbuntu126())
managementCluster := framework.NewClusterE2ETest(
t,
provider,
framework.WithEnvVar(features.VSphereInPlaceEnvVar, "true"),
).WithClusterConfig(
api.ClusterToConfigFiller(
api.WithKubernetesVersion(v1alpha1.Kube126),
api.WithStackedEtcdTopology(),
api.WithInPlaceUpgradeStrategy(),
),
api.VSphereToConfigFiller(
api.RemoveEtcdVsphereMachineConfig(),
),
provider.WithKubeVersionAndOS(v1alpha1.Kube126, framework.Ubuntu2004, nil),
)
test := framework.NewMulticlusterE2ETest(t, managementCluster)
test.WithWorkloadClusters(
framework.NewClusterE2ETest(
t,
provider,
framework.WithClusterName(test.NewWorkloadClusterName()),
framework.WithEnvVar(features.VSphereInPlaceEnvVar, "true"),
).WithClusterConfig(
api.ClusterToConfigFiller(
api.WithManagementCluster(managementCluster.ClusterName),
api.WithKubernetesVersion(v1alpha1.Kube126),
api.WithStackedEtcdTopology(),
api.WithInPlaceUpgradeStrategy(),
),
api.VSphereToConfigFiller(
api.RemoveEtcdVsphereMachineConfig(),
),
provider.WithKubeVersionAndOS(v1alpha1.Kube126, framework.Ubuntu2004, nil),
),
)
runInPlaceWorkloadUpgradeFlow(
test,
framework.WithClusterUpgrade(
api.WithKubernetesVersion(v1alpha1.Kube127),
api.WithInPlaceUpgradeStrategy(),
),
provider.WithProviderUpgrade(provider.Ubuntu127Template()),
)
}

func TestVSphereInPlaceUpgradeMulticlusterWorkloadClusterK8sUpgrade127To128(t *testing.T) {
provider := framework.NewVSphere(t, framework.WithUbuntu127())
managementCluster := framework.NewClusterE2ETest(
t,
provider,
framework.WithEnvVar(features.VSphereInPlaceEnvVar, "true"),
).WithClusterConfig(
api.ClusterToConfigFiller(
api.WithKubernetesVersion(v1alpha1.Kube127),
api.WithStackedEtcdTopology(),
api.WithInPlaceUpgradeStrategy(),
),
api.VSphereToConfigFiller(
api.RemoveEtcdVsphereMachineConfig(),
),
provider.WithKubeVersionAndOS(v1alpha1.Kube127, framework.Ubuntu2004, nil),
)
test := framework.NewMulticlusterE2ETest(t, managementCluster)
test.WithWorkloadClusters(
framework.NewClusterE2ETest(
t,
provider,
framework.WithClusterName(test.NewWorkloadClusterName()),
framework.WithEnvVar(features.VSphereInPlaceEnvVar, "true"),
).WithClusterConfig(
api.ClusterToConfigFiller(
api.WithManagementCluster(managementCluster.ClusterName),
api.WithKubernetesVersion(v1alpha1.Kube127),
api.WithStackedEtcdTopology(),
api.WithInPlaceUpgradeStrategy(),
),
api.VSphereToConfigFiller(
api.RemoveEtcdVsphereMachineConfig(),
),
provider.WithKubeVersionAndOS(v1alpha1.Kube127, framework.Ubuntu2004, nil),
),
)
runInPlaceWorkloadUpgradeFlow(
test,
framework.WithClusterUpgrade(
api.WithKubernetesVersion(v1alpha1.Kube128),
api.WithInPlaceUpgradeStrategy(),
),
provider.WithProviderUpgrade(provider.Ubuntu128Template()),
)
}

// Workload API
func TestVSphereMulticlusterWorkloadClusterAPI(t *testing.T) {
vsphere := framework.NewVSphere(t)
Expand Down
2 changes: 1 addition & 1 deletion test/framework/cluster/validations/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func validateMDUsDeleted(ctx context.Context, vc clusterf.StateValidationConfig)

func validateNUsAndPodsDeleted(ctx context.Context, vc clusterf.StateValidationConfig) error {
machines := &v1beta1.MachineList{}
if err := vc.ClusterClient.List(ctx, machines); err != nil {
if err := vc.ManagementClusterClient.List(ctx, machines); err != nil {
return fmt.Errorf("failed to list machines: %s", err)
}
client := vc.ManagementClusterClient
Expand Down

0 comments on commit f5e2bf0

Please sign in to comment.