223
223
224
224
# run e2es with ginkgo-e2e.sh
225
225
run_tests () {
226
- # Change to the cloned Kubernetes repository
227
- pushd ../kubernetes
228
-
229
226
# IPv6 clusters need some CoreDNS changes in order to work in k8s CI:
230
227
# 1. k8s CI doesn´t offer IPv6 connectivity, so CoreDNS should be configured
231
228
# to work in an offline environment:
@@ -286,17 +283,19 @@ run_tests() {
286
283
" --report-dir=${ARTIFACTS} " ' --disable-log-dump=true' &
287
284
GINKGO_PID=$!
288
285
wait " $GINKGO_PID "
289
-
290
- # Return to the original directory
291
- popd
292
286
}
293
287
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
300
299
}
301
300
302
301
main () {
@@ -307,6 +306,8 @@ main() {
307
306
export ARTIFACTS=" ${ARTIFACTS:- ${PWD} / _artifacts} "
308
307
mkdir -p " ${ARTIFACTS} "
309
308
309
+ export EMULATED_VERSION=$( get_latest_release_version)
310
+
310
311
# export the KUBECONFIG to a unique path for testing
311
312
KUBECONFIG=" ${HOME} /.kube/kind-test-config"
312
313
export KUBECONFIG
@@ -327,10 +328,16 @@ main() {
327
328
res=0
328
329
create_cluster || res=$?
329
330
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} "
332
335
336
+ # enter the release branch and run tests
337
+ pushd " ${PREV_RELEASE_BRANCH} "
333
338
run_tests || res=$?
339
+ popd
340
+
334
341
cleanup || res=$?
335
342
exit $res
336
343
}
0 commit comments