Skip to content

Commit 40b1238

Browse files
committed
fix: make compatibility versions test use dynamic n-1 branch for test (from hardcoded release-1.31)
1 parent 1936263 commit 40b1238

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

config/jobs/kubernetes/sig-testing/compatibility-versions-e2e.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ periodics:
3535
- -c
3636
- curl -sSL https://kind.sigs.k8s.io/dl/latest/linux-amd64.tgz | tar xvfz - -C "${PATH%%:*}/" && ./../test-infra/experiment/compatibility-versions/e2e-k8s-compatibility-versions.sh
3737
env:
38-
- name: EMULATED_VERSION
39-
value: "1.31" # TODO(aaron-prindle) FIXME - hardcoded for now
4038
- name: SKIP
4139
value: Alpha|Disruptive|Slow|Flaky|IPv6|LoadBalancer|PodSecurityPolicy|nfs
4240
- name: PARALLEL

experiment/compatibility-versions/e2e-k8s-compatibility-versions.sh

+21-14
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@ EOF
223223

224224
# run e2es with ginkgo-e2e.sh
225225
run_tests() {
226-
# Change to the cloned Kubernetes repository
227-
pushd ../kubernetes
228-
229226
# IPv6 clusters need some CoreDNS changes in order to work in k8s CI:
230227
# 1. k8s CI doesn´t offer IPv6 connectivity, so CoreDNS should be configured
231228
# to work in an offline environment:
@@ -286,17 +283,19 @@ run_tests() {
286283
"--report-dir=${ARTIFACTS}" '--disable-log-dump=true' &
287284
GINKGO_PID=$!
288285
wait "$GINKGO_PID"
289-
290-
# Return to the original directory
291-
popd
292286
}
293287

294-
# clone kubernetes repo for specific release branch
295-
clone_kubernetes_release() {
296-
# Clone the specific Kubernetes release branch
297-
# Replace "release-1.31" with the desired branch
298-
KUBE_RELEASE_BRANCH=${KUBE_RELEASE_BRANCH:-release-1.31}
299-
git clone --single-branch --branch "${KUBE_RELEASE_BRANCH}" https://github.com/kubernetes/kubernetes.git
288+
get_latest_release_version() {
289+
# Fetch all branch names
290+
git ls-remote --heads https://github.com/kubernetes/kubernetes.git | \
291+
# Extract branch names that match release-X.Y pattern
292+
grep -o 'refs/heads/release-[0-9]\+\.[0-9]\+$' | \
293+
# Extract version numbers
294+
sed 's/refs\/heads\/release-//' | \
295+
# Sort versions by number
296+
sort -t. -k1,1n -k2,2n | \
297+
# Get the latest version
298+
tail -n1
300299
}
301300

302301
main() {
@@ -307,6 +306,8 @@ main() {
307306
export ARTIFACTS="${ARTIFACTS:-${PWD}/_artifacts}"
308307
mkdir -p "${ARTIFACTS}"
309308

309+
export EMULATED_VERSION=$(get_latest_release_version)
310+
310311
# export the KUBECONFIG to a unique path for testing
311312
KUBECONFIG="${HOME}/.kube/kind-test-config"
312313
export KUBECONFIG
@@ -327,10 +328,16 @@ main() {
327328
res=0
328329
create_cluster || res=$?
329330

330-
# Clone the specific Kubernetes release branch
331-
clone_kubernetes_release
331+
# Clone the previous versions Kubernetes release branch
332+
# TODO(aaron-prindle) extend the branches to test from n-1 -> n-1..3 as more k8s releases are done that support compatibility versions
333+
export PREV_RELEASE_BRANCH="release-${EMULATED_VERSION}"
334+
git clone --single-branch --branch "${PREV_RELEASE_BRANCH}" https://github.com/kubernetes/kubernetes.git "${PREV_RELEASE_BRANCH}"
332335

336+
# enter the release branch and run tests
337+
pushd "${PREV_RELEASE_BRANCH}"
333338
run_tests || res=$?
339+
popd
340+
334341
cleanup || res=$?
335342
exit $res
336343
}

0 commit comments

Comments
 (0)