From e6f37eab329c2d63deef76308f649e1bc59ab030 Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Thu, 1 Aug 2024 15:53:34 +0200 Subject: [PATCH] test: add coverage to find issues running on the next kubernetes release as management cluster --- scripts/ci-e2e-lib.sh | 10 ++++++++++ test/e2e/clusterctl_upgrade_test.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/scripts/ci-e2e-lib.sh b/scripts/ci-e2e-lib.sh index 259d88193fb0..a1aeacb2863f 100644 --- a/scripts/ci-e2e-lib.sh +++ b/scripts/ci-e2e-lib.sh @@ -63,6 +63,16 @@ k8s::prepareKindestImagesVariables() { fi fi + # Tests not focusing on anything and skipping [Conformance] run a clusterctl upgrade test + # on the latest kubernetes version as management cluster. + if [[ ${GINKGO_FOCUS:-} == "" ]] && [[ ${GINKGO_SKIP} == *"Conformance"* ]]; then + # Note: We do this because we want to specify KUBERNETES_VERSION_LATEST_CI *only* in the e2e config. + if [[ -z "${KUBERNETES_VERSION_LATEST_CI:-}" ]]; then + KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}') + echo "Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)" + fi + fi + # Tests not focusing on [PR-Blocking], [K8s-Install] or [K8s-Install-ci-latest], # also run upgrade tests so default KUBERNETES_VERSION_UPGRADE_TO and KUBERNETES_VERSION_UPGRADE_FROM # to the value in the e2e config if they are not set. diff --git a/test/e2e/clusterctl_upgrade_test.go b/test/e2e/clusterctl_upgrade_test.go index 087864997c4b..93b5dbf1839d 100644 --- a/test/e2e/clusterctl_upgrade_test.go +++ b/test/e2e/clusterctl_upgrade_test.go @@ -28,6 +28,7 @@ import ( "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/cluster-api/test/framework/kubernetesversions" ) var ( @@ -325,3 +326,31 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (v1.7=>cur } }) }) + +var _ = Describe("When testing clusterctl upgrades using ClusterClass (v1.7=>current) on K8S latest ci mgmt cluster [ClusterClass]", func() { + // Get v1.7 latest stable release + version := "1.7" + stableRelease, err := GetStableReleaseOfMinor(ctx, version) + Expect(err).ToNot(HaveOccurred(), "Failed to get stable version for minor release : %s", version) + ClusterctlUpgradeSpec(ctx, func() ClusterctlUpgradeSpecInput { + initKubernetesVersion, err := kubernetesversions.ResolveVersion(ctx, e2eConfig.GetVariable("KUBERNETES_VERSION_LATEST_CI")) + Expect(err).ToNot(HaveOccurred()) + return ClusterctlUpgradeSpecInput{ + E2EConfig: e2eConfig, + ClusterctlConfigPath: clusterctlConfigPath, + BootstrapClusterProxy: bootstrapClusterProxy, + ArtifactFolder: artifactFolder, + SkipCleanup: skipCleanup, + InfrastructureProvider: ptr.To("docker"), + InitWithBinary: fmt.Sprintf(clusterctlDownloadURL, stableRelease), + InitWithProvidersContract: "v1beta1", + // Note: InitWithKubernetesVersion should be the latest of the next supported kubernetes version by the target Cluster API version. + // Note: WorkloadKubernetesVersion should be the highest mgmt cluster version supported by the source Cluster API version. + InitWithKubernetesVersion: initKubernetesVersion, + WorkloadKubernetesVersion: "v1.30.0", + MgmtFlavor: "topology", + WorkloadFlavor: "topology", + UseKindForManagementCluster: true, + } + }) +})