From fa2ea10d9a0c47b4ec33d0959f2e09ec24c77638 Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Mon, 5 Aug 2024 15:51:11 +0200 Subject: [PATCH] test: add coverage to find issues running on the next kubernetes release as management cluster --- hack/ci-e2e-lib.sh | 23 ++++++++++++++ test/e2e/clusterctl_upgrade_test.go | 47 +++++++++++++++++++++++++++++ test/e2e/config/vsphere.yaml | 6 ++++ 3 files changed, 76 insertions(+) diff --git a/hack/ci-e2e-lib.sh b/hack/ci-e2e-lib.sh index 2bf32ffc8d..280945221f 100644 --- a/hack/ci-e2e-lib.sh +++ b/hack/ci-e2e-lib.sh @@ -26,6 +26,22 @@ k8s::prepareKindestImagesVariables() { KUBERNETES_VERSION_MANAGEMENT=$(grep KUBERNETES_VERSION_MANAGEMENT: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}') echo "Defaulting KUBERNETES_VERSION_MANAGEMENT to ${KUBERNETES_VERSION_MANAGEMENT} to trigger image build (because env var is not set)" fi + + # Ensure kind image get's built full e2e tests. + if [[ "${GINKGO_SKIP:-}" == "\\[Conformance\\] \\[specialized-infra\\]" ]]; then + if [[ "${GINKGO_FOCUS:-}" == "\\[supervisor\\]" ]] || [[ "${GINKGO_FOCUS:-}" == "" ]]; 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 + + # Ensure kind image get's built vcsim e2e tests. + if [[ -z "${GINKGO_SKIP:-}" ]]; then + if [[ "${GINKGO_FOCUS:-}" == "\\[vcsim\\]" ]] || [[ "${GINKGO_FOCUS:-}" == "\\[vcsim\\] \\[supervisor\\]" ]]; 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 } # k8s::prepareKindestImages checks all the e2e test variables representing a Kubernetes version, @@ -37,6 +53,13 @@ k8s::prepareKindestImages() { kind::prepareKindestImage "$resolveVersion" fi + + if [ -n "${KUBERNETES_VERSION_LATEST_CI:-}" ]; then + k8s::resolveVersion "KUBERNETES_VERSION_LATEST_CI" "$KUBERNETES_VERSION_LATEST_CI" + export KUBERNETES_VERSION_LATEST_CI=$resolveVersion + + kind::prepareKindestImage "$resolveVersion" + fi } # k8s::resolveVersion resolves kubernetes version labels (e.g. latest) to the corresponding version numbers. diff --git a/test/e2e/clusterctl_upgrade_test.go b/test/e2e/clusterctl_upgrade_test.go index e5603c8403..b612a7972d 100644 --- a/test/e2e/clusterctl_upgrade_test.go +++ b/test/e2e/clusterctl_upgrade_test.go @@ -25,6 +25,7 @@ import ( capi_e2e "sigs.k8s.io/cluster-api/test/e2e" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/test/framework/clusterctl" + "sigs.k8s.io/cluster-api/test/framework/kubernetesversions" "sigs.k8s.io/cluster-api-provider-vsphere/test/framework/vcsim" ) @@ -82,6 +83,52 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.10 ) }) +var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.10=>current, CAPI 1.7=>1.8) on K8S latest ci mgmt cluster [vcsim] [supervisor] [ClusterClass]", func() { + const specName = "clusterctl-upgrade-1.10-current" // prefix (clusterctl-upgrade) copied from CAPI + Setup(specName, func(testSpecificSettingsGetter func() testSettings) { + capi_e2e.ClusterctlUpgradeSpec(ctx, func() capi_e2e.ClusterctlUpgradeSpecInput { + capiVersion := "1.7" + capiStableRelease, err := getStableReleaseOfMinor(ctx, capiReleaseMarkerPrefix, capiVersion) + Expect(err).ToNot(HaveOccurred(), "Failed to get stable version for minor release : %s", capiVersion) + capvVersion := "1.10" + capvStableRelease, err := getStableReleaseOfMinor(ctx, capvReleaseMarkerPrefix, capvVersion) + Expect(err).ToNot(HaveOccurred(), "Failed to get stable version for minor release : %s", capvVersion) + initKubernetesVersion, err := kubernetesversions.ResolveVersion(ctx, e2eConfig.GetVariable("KUBERNETES_VERSION_LATEST_CI")) + Expect(err).ToNot(HaveOccurred()) + return capi_e2e.ClusterctlUpgradeSpecInput{ + E2EConfig: e2eConfig, + ClusterctlConfigPath: testSpecificSettingsGetter().ClusterctlConfigPath, + BootstrapClusterProxy: bootstrapClusterProxy, + ArtifactFolder: artifactFolder, + SkipCleanup: skipCleanup, + MgmtFlavor: testSpecificSettingsGetter().FlavorForMode("topology"), + PostNamespaceCreated: testSpecificSettingsGetter().PostNamespaceCreatedFunc, + InitWithBinary: fmt.Sprintf(clusterctlDownloadURL, capiStableRelease), + InitWithCoreProvider: fmt.Sprintf(providerCAPIPrefix, capiStableRelease), + InitWithBootstrapProviders: []string{fmt.Sprintf(providerKubeadmPrefix, capiStableRelease)}, + InitWithControlPlaneProviders: []string{fmt.Sprintf(providerKubeadmPrefix, capiStableRelease)}, + InitWithInfrastructureProviders: []string{fmt.Sprintf(providerVSpherePrefix, capvStableRelease)}, + InitWithRuntimeExtensionProviders: testSpecificSettingsGetter().RuntimeExtensionProviders, + InitWithIPAMProviders: []string{}, + // InitWithKubernetesVersion should be the highest kubernetes version supported by the init Cluster API version. + // This is to guarantee that both, the old and new CAPI version, support the defined version. + // Ensure all Kubernetes versions used here are covered in patch-vsphere-template.yaml + InitWithKubernetesVersion: initKubernetesVersion, + WorkloadKubernetesVersion: "v1.30.0", + WorkloadFlavor: testSpecificSettingsGetter().FlavorForMode("workload"), + // We are using a separate management cluster. For running in VCSim we also have to pass WithAdditionalVCSimServer + // below otherwise there will be no VCSim instance created in the management cluster. + UseKindForManagementCluster: true, + KindManagementClusterNewClusterProxyFunc: kindManagementClusterNewClusterProxyFunc, + } + }) + }, + WithIP("WORKLOAD_CONTROL_PLANE_ENDPOINT_IP"), + // This is required because we are using a separate management cluster with kind by passing `UseKindForManagementCluster` above. + WithAdditionalVCSimServer(true), + ) +}) + var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.9=>current, CAPI 1.6=>1.8) [vcsim] [supervisor] [ClusterClass]", func() { const specName = "clusterctl-upgrade-1.9-current" // prefix (clusterctl-upgrade) copied from CAPI Setup(specName, func(testSpecificSettingsGetter func() testSettings) { diff --git a/test/e2e/config/vsphere.yaml b/test/e2e/config/vsphere.yaml index ad695d68d7..a2992c8f2b 100644 --- a/test/e2e/config/vsphere.yaml +++ b/test/e2e/config/vsphere.yaml @@ -35,6 +35,8 @@ providers: replacements: - old: "imagePullPolicy: Always" new: "imagePullPolicy: IfNotPresent" + - old: "caBundle: Cg==" + new: "" - name: "{go://sigs.k8s.io/cluster-api@v1.7}" # supported release in the v1beta1 series value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/{go://sigs.k8s.io/cluster-api@v1.7}/core-components.yaml" type: "url" @@ -75,6 +77,8 @@ providers: replacements: - old: "imagePullPolicy: Always" new: "imagePullPolicy: IfNotPresent" + - old: "caBundle: Cg==" + new: "" - name: "{go://sigs.k8s.io/cluster-api@v1.7}" # supported release in the v1beta1 series value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/{go://sigs.k8s.io/cluster-api@v1.7}/bootstrap-components.yaml" type: "url" @@ -115,6 +119,8 @@ providers: replacements: - old: "imagePullPolicy: Always" new: "imagePullPolicy: IfNotPresent" + - old: "caBundle: Cg==" + new: "" - name: "{go://sigs.k8s.io/cluster-api@v1.7}" # supported release in the v1beta1 series value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/{go://sigs.k8s.io/cluster-api@v1.7}/control-plane-components.yaml" type: "url"