Skip to content

Commit

Permalink
fix: make compatibility versions test use dynamic n-1 branch for test…
Browse files Browse the repository at this point in the history
… (from hardcoded release-1.31)
  • Loading branch information
aaron-prindle committed Nov 25, 2024
1 parent 1936263 commit 40b1238
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ periodics:
- -c
- 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
env:
- name: EMULATED_VERSION
value: "1.31" # TODO(aaron-prindle) FIXME - hardcoded for now
- name: SKIP
value: Alpha|Disruptive|Slow|Flaky|IPv6|LoadBalancer|PodSecurityPolicy|nfs
- name: PARALLEL
Expand Down
35 changes: 21 additions & 14 deletions experiment/compatibility-versions/e2e-k8s-compatibility-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@ EOF

# run e2es with ginkgo-e2e.sh
run_tests() {
# Change to the cloned Kubernetes repository
pushd ../kubernetes

# IPv6 clusters need some CoreDNS changes in order to work in k8s CI:
# 1. k8s CI doesn´t offer IPv6 connectivity, so CoreDNS should be configured
# to work in an offline environment:
Expand Down Expand Up @@ -286,17 +283,19 @@ run_tests() {
"--report-dir=${ARTIFACTS}" '--disable-log-dump=true' &
GINKGO_PID=$!
wait "$GINKGO_PID"

# Return to the original directory
popd
}

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

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

export EMULATED_VERSION=$(get_latest_release_version)

# export the KUBECONFIG to a unique path for testing
KUBECONFIG="${HOME}/.kube/kind-test-config"
export KUBECONFIG
Expand All @@ -327,10 +328,16 @@ main() {
res=0
create_cluster || res=$?

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

# enter the release branch and run tests
pushd "${PREV_RELEASE_BRANCH}"
run_tests || res=$?
popd

cleanup || res=$?
exit $res
}
Expand Down

0 comments on commit 40b1238

Please sign in to comment.