Skip to content

Commit d42f6b3

Browse files
compat-ver: fix 2 step upgrade tests.
Signed-off-by: Siyuan Zhang <[email protected]>
1 parent c596351 commit d42f6b3

File tree

4 files changed

+35
-22
lines changed

4 files changed

+35
-22
lines changed

experiment/compatibility-versions/common.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,19 +224,20 @@ EOF
224224
return 0
225225
}
226226

227-
build_prev_version_bins() {
227+
build_test_bins() {
228+
local release_branch=$1
228229
GINKGO_SRC_DIR="vendor/github.com/onsi/ginkgo/v2/ginkgo"
229230

230-
echo "Building e2e.test binary from release branch ${PREV_RELEASE_BRANCH}..."
231+
echo "Building e2e.test binary from release branch ${release_branch}..."
231232
make all WHAT="cmd/kubectl test/e2e/e2e.test ${GINKGO_SRC_DIR}"
232233

233234
# Ensure the built kubectl is used instead of system
234235
export PATH="${PWD}/_output/bin:$PATH"
235-
echo "Finished building e2e.test binary from ${PREV_RELEASE_BRANCH}."
236+
echo "Finished building e2e.test binary from ${release_branch}."
236237
}
237238

238239
# run e2es with ginkgo-e2e.sh
239-
run_prev_version_tests() {
240+
run_e2e_tests() {
240241
# IPv6 clusters need some CoreDNS changes in order to work in k8s CI:
241242
# 1. k8s CI doesn´t offer IPv6 connectivity, so CoreDNS should be configured
242243
# to work in an offline environment:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ main() {
119119

120120
# enter the cloned prev repo branch (in temp) and run tests
121121
pushd "${PREV_RELEASE_REPO_PATH}"
122-
build_prev_version_bins || res=$?
123-
run_prev_version_tests || res=$?
122+
build_test_bins "${PREV_RELEASE_BRANCH}" || res=$?
123+
run_e2e_tests || res=$?
124124
popd
125125

126126

experiment/compatibility-versions/e2e-skip-version-testing.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ run_skip_version_tests() {
4949
return 1
5050
fi
5151
pushd "${PREV_RELEASE_REPO_PATH}"
52-
build_prev_version_bins || ret=$?
53-
run_prev_version_tests || ret=$?
52+
build_test_bins "${PREV_RELEASE_BRANCH}" || ret=$?
53+
run_e2e_tests || ret=$?
5454
if [[ "$ret" -ne 0 ]]; then
5555
echo "Failed running skip version tests for emulated version $EMULATED_VERSION"
5656
return 1
@@ -66,8 +66,8 @@ run_skip_version_tests() {
6666
# Test removal of emulated version entirely.
6767
export PREV_RELEASE_BRANCH="release-${EMULATED_VERSION}"
6868
delete_emulation_version || ret=$?
69-
build_prev_version_bins || ret=$?
70-
run_prev_version_tests || ret=$?
69+
build_test_bins "${PREV_RELEASE_BRANCH}" || ret=$?
70+
run_e2e_tests || ret=$?
7171
return $ret
7272
}
7373

experiment/compatibility-versions/e2e-two-steps-upgrade.sh

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ main() {
9797
res=0
9898
create_cluster || res=$?
9999

100-
100+
# first step: upgrade binary version while keeping emulated version the same as previous version
101101
# Perform the upgrade. Assume kind-upgrade.sh is in the same directory as this script.
102102
UPGRADE_SCRIPT="${UPGRADE_SCRIPT:-${PWD}/../test-infra/experiment/compatibility-versions/kind-upgrade.sh}"
103103
echo "Upgrading cluster with ${UPGRADE_SCRIPT}"
@@ -109,24 +109,36 @@ main() {
109109
exit $res
110110
fi
111111

112-
EMULATED_VERSION_UPGRADE_SCRIPT="${EMULATED_VERSION_UPGRADE_SCRIPT:-${PWD}/../test-infra/experiment/compatibility-versions/emulated-version-upgrade.sh}"
113-
echo "Upgrading cluster with ${EMULATED_VERSION_UPGRADE_SCRIPT}"
114-
"${EMULATED_VERSION_UPGRADE_SCRIPT}" | tee "${ARTIFACTS}/emulated-upgrade-output.txt"
112+
# after first step of upgrading binary version without bumping emulated version, verify all tests from the previous version pass
115113

116114
# Clone the previous versions Kubernetes release branch
117115
# TODO(aaron-prindle) extend the branches to test from n-1 -> n-1..3 as more k8s releases are done that support compatibility versions
118-
export RELEASE_BRANCH="release-${CURRENT_VERSION}"
116+
export PREV_RELEASE_BRANCH="release-${PREV_VERSION}"
119117
# Define the path within the temp directory for the cloned repo
120-
RELEASE_REPO_PATH="${TMP_DIR}/release-k8s"
121-
echo "Cloning branch ${RELEASE_BRANCH} into ${RELEASE_REPO_PATH}"
122-
git clone --filter=blob:none --single-branch --branch "${RELEASE_BRANCH}" https://github.com/kubernetes/kubernetes.git "${RELEASE_REPO_PATH}"
123-
118+
PREV_RELEASE_REPO_PATH="${TMP_DIR}/prev-release-k8s"
119+
echo "Cloning branch ${PREV_RELEASE_BRANCH} into ${PREV_RELEASE_REPO_PATH}"
120+
git clone --filter=blob:none --single-branch --branch "${PREV_RELEASE_BRANCH}" https://github.com/kubernetes/kubernetes.git "${PREV_RELEASE_REPO_PATH}"
124121
# enter the cloned prev repo branch (in temp) and run tests
125-
pushd "${RELEASE_REPO_PATH}"
126-
build_prev_version_bins || res=$?
127-
run_prev_version_tests || res=$?
122+
pushd "${PREV_RELEASE_REPO_PATH}"
123+
build_test_bins "${PREV_RELEASE_BRANCH}" || res=$?
124+
run_e2e_tests || res=$?
125+
# debug kubectl version
126+
kubectl version
127+
# remove "${PWD}/_output/bin" from PATH
128+
export PATH="${PATH//${PWD}\/_output\/bin:}"
128129
popd
129130

131+
# second step: bump emulated version
132+
EMULATED_VERSION_UPGRADE_SCRIPT="${EMULATED_VERSION_UPGRADE_SCRIPT:-${PWD}/../test-infra/experiment/compatibility-versions/emulated-version-upgrade.sh}"
133+
echo "Upgrading cluster with ${EMULATED_VERSION_UPGRADE_SCRIPT}"
134+
"${EMULATED_VERSION_UPGRADE_SCRIPT}" | tee "${ARTIFACTS}/emulated-upgrade-output.txt"
135+
136+
# verify all tests from the current version pass after upgrade is complete
137+
# debug kubectl version
138+
kubectl version
139+
# run tests at head
140+
build_test_bins "${CURRENT_VERSION}" || res=$?
141+
run_e2e_tests || res=$?
130142

131143
cleanup || res=$?
132144
exit $res

0 commit comments

Comments
 (0)