Skip to content

Commit

Permalink
Merge pull request #3139 from chrischdi/pr-clusterctl-upgrade-latest-k8s
Browse files Browse the repository at this point in the history
🌱 test: add coverage to find issues running on the next kubernetes release as management cluster
  • Loading branch information
k8s-ci-robot committed Aug 6, 2024
2 parents 9379efd + fa2ea10 commit 7745421
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
23 changes: 23 additions & 0 deletions hack/ci-e2e-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down
47 changes: 47 additions & 0 deletions test/e2e/clusterctl_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/config/vsphere.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 7745421

Please sign in to comment.