Skip to content

Commit 7745421

Browse files
authored
Merge pull request #3139 from chrischdi/pr-clusterctl-upgrade-latest-k8s
🌱 test: add coverage to find issues running on the next kubernetes release as management cluster
2 parents 9379efd + fa2ea10 commit 7745421

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

hack/ci-e2e-lib.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ k8s::prepareKindestImagesVariables() {
2626
KUBERNETES_VERSION_MANAGEMENT=$(grep KUBERNETES_VERSION_MANAGEMENT: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
2727
echo "Defaulting KUBERNETES_VERSION_MANAGEMENT to ${KUBERNETES_VERSION_MANAGEMENT} to trigger image build (because env var is not set)"
2828
fi
29+
30+
# Ensure kind image get's built full e2e tests.
31+
if [[ "${GINKGO_SKIP:-}" == "\\[Conformance\\] \\[specialized-infra\\]" ]]; then
32+
if [[ "${GINKGO_FOCUS:-}" == "\\[supervisor\\]" ]] || [[ "${GINKGO_FOCUS:-}" == "" ]]; then
33+
KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
34+
echo "Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
35+
fi
36+
fi
37+
38+
# Ensure kind image get's built vcsim e2e tests.
39+
if [[ -z "${GINKGO_SKIP:-}" ]]; then
40+
if [[ "${GINKGO_FOCUS:-}" == "\\[vcsim\\]" ]] || [[ "${GINKGO_FOCUS:-}" == "\\[vcsim\\] \\[supervisor\\]" ]]; then
41+
KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
42+
echo "Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
43+
fi
44+
fi
2945
}
3046

3147
# k8s::prepareKindestImages checks all the e2e test variables representing a Kubernetes version,
@@ -37,6 +53,13 @@ k8s::prepareKindestImages() {
3753

3854
kind::prepareKindestImage "$resolveVersion"
3955
fi
56+
57+
if [ -n "${KUBERNETES_VERSION_LATEST_CI:-}" ]; then
58+
k8s::resolveVersion "KUBERNETES_VERSION_LATEST_CI" "$KUBERNETES_VERSION_LATEST_CI"
59+
export KUBERNETES_VERSION_LATEST_CI=$resolveVersion
60+
61+
kind::prepareKindestImage "$resolveVersion"
62+
fi
4063
}
4164

4265
# k8s::resolveVersion resolves kubernetes version labels (e.g. latest) to the corresponding version numbers.

test/e2e/clusterctl_upgrade_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
2626
"sigs.k8s.io/cluster-api/test/framework"
2727
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
28+
"sigs.k8s.io/cluster-api/test/framework/kubernetesversions"
2829

2930
"sigs.k8s.io/cluster-api-provider-vsphere/test/framework/vcsim"
3031
)
@@ -82,6 +83,52 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.10
8283
)
8384
})
8485

86+
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() {
87+
const specName = "clusterctl-upgrade-1.10-current" // prefix (clusterctl-upgrade) copied from CAPI
88+
Setup(specName, func(testSpecificSettingsGetter func() testSettings) {
89+
capi_e2e.ClusterctlUpgradeSpec(ctx, func() capi_e2e.ClusterctlUpgradeSpecInput {
90+
capiVersion := "1.7"
91+
capiStableRelease, err := getStableReleaseOfMinor(ctx, capiReleaseMarkerPrefix, capiVersion)
92+
Expect(err).ToNot(HaveOccurred(), "Failed to get stable version for minor release : %s", capiVersion)
93+
capvVersion := "1.10"
94+
capvStableRelease, err := getStableReleaseOfMinor(ctx, capvReleaseMarkerPrefix, capvVersion)
95+
Expect(err).ToNot(HaveOccurred(), "Failed to get stable version for minor release : %s", capvVersion)
96+
initKubernetesVersion, err := kubernetesversions.ResolveVersion(ctx, e2eConfig.GetVariable("KUBERNETES_VERSION_LATEST_CI"))
97+
Expect(err).ToNot(HaveOccurred())
98+
return capi_e2e.ClusterctlUpgradeSpecInput{
99+
E2EConfig: e2eConfig,
100+
ClusterctlConfigPath: testSpecificSettingsGetter().ClusterctlConfigPath,
101+
BootstrapClusterProxy: bootstrapClusterProxy,
102+
ArtifactFolder: artifactFolder,
103+
SkipCleanup: skipCleanup,
104+
MgmtFlavor: testSpecificSettingsGetter().FlavorForMode("topology"),
105+
PostNamespaceCreated: testSpecificSettingsGetter().PostNamespaceCreatedFunc,
106+
InitWithBinary: fmt.Sprintf(clusterctlDownloadURL, capiStableRelease),
107+
InitWithCoreProvider: fmt.Sprintf(providerCAPIPrefix, capiStableRelease),
108+
InitWithBootstrapProviders: []string{fmt.Sprintf(providerKubeadmPrefix, capiStableRelease)},
109+
InitWithControlPlaneProviders: []string{fmt.Sprintf(providerKubeadmPrefix, capiStableRelease)},
110+
InitWithInfrastructureProviders: []string{fmt.Sprintf(providerVSpherePrefix, capvStableRelease)},
111+
InitWithRuntimeExtensionProviders: testSpecificSettingsGetter().RuntimeExtensionProviders,
112+
InitWithIPAMProviders: []string{},
113+
// InitWithKubernetesVersion should be the highest kubernetes version supported by the init Cluster API version.
114+
// This is to guarantee that both, the old and new CAPI version, support the defined version.
115+
// Ensure all Kubernetes versions used here are covered in patch-vsphere-template.yaml
116+
InitWithKubernetesVersion: initKubernetesVersion,
117+
WorkloadKubernetesVersion: "v1.30.0",
118+
WorkloadFlavor: testSpecificSettingsGetter().FlavorForMode("workload"),
119+
// We are using a separate management cluster. For running in VCSim we also have to pass WithAdditionalVCSimServer
120+
// below otherwise there will be no VCSim instance created in the management cluster.
121+
UseKindForManagementCluster: true,
122+
KindManagementClusterNewClusterProxyFunc: kindManagementClusterNewClusterProxyFunc,
123+
}
124+
})
125+
},
126+
WithIP("WORKLOAD_CONTROL_PLANE_ENDPOINT_IP"),
127+
// This is required because we are using a separate management cluster with kind by passing `UseKindForManagementCluster` above.
128+
WithAdditionalVCSimServer(true),
129+
)
130+
})
131+
85132
var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.9=>current, CAPI 1.6=>1.8) [vcsim] [supervisor] [ClusterClass]", func() {
86133
const specName = "clusterctl-upgrade-1.9-current" // prefix (clusterctl-upgrade) copied from CAPI
87134
Setup(specName, func(testSpecificSettingsGetter func() testSettings) {

test/e2e/config/vsphere.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ providers:
3535
replacements:
3636
- old: "imagePullPolicy: Always"
3737
new: "imagePullPolicy: IfNotPresent"
38+
- old: "caBundle: Cg=="
39+
new: ""
3840
- name: "{go://sigs.k8s.io/[email protected]}" # supported release in the v1beta1 series
3941
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/{go://sigs.k8s.io/[email protected]}/core-components.yaml"
4042
type: "url"
@@ -75,6 +77,8 @@ providers:
7577
replacements:
7678
- old: "imagePullPolicy: Always"
7779
new: "imagePullPolicy: IfNotPresent"
80+
- old: "caBundle: Cg=="
81+
new: ""
7882
- name: "{go://sigs.k8s.io/[email protected]}" # supported release in the v1beta1 series
7983
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/{go://sigs.k8s.io/[email protected]}/bootstrap-components.yaml"
8084
type: "url"
@@ -115,6 +119,8 @@ providers:
115119
replacements:
116120
- old: "imagePullPolicy: Always"
117121
new: "imagePullPolicy: IfNotPresent"
122+
- old: "caBundle: Cg=="
123+
new: ""
118124
- name: "{go://sigs.k8s.io/[email protected]}" # supported release in the v1beta1 series
119125
value: "https://github.com/kubernetes-sigs/cluster-api/releases/download/{go://sigs.k8s.io/[email protected]}/control-plane-components.yaml"
120126
type: "url"

0 commit comments

Comments
 (0)