Skip to content

Commit 9b26455

Browse files
simonartxavieralmusil
authored andcommitted
ci: Run system tests in upgrade scenario.
When ovn is upgraded, ovn-controller is updated first on the compute nodes. Then ovn-northd and DB are upgraded. This patch tests whether the intermediate state (i.e. with ovn-controller being upgraded) works properly, running system tests from the base line (i.e. before the upgrade). Flow tables might change between releases. Hence this patch must take that into account by updating the (old) system tests with any updated table numbers. In some cases, (new) ovn-controller might change flows in existing tables, causing some 'upgrade' tests to fail. Such tests can be skipped using the TAG_TEST_NOT_UPGRADABLE tag. This patch upgrades the ci to run automatically some upgrade tests weekly, on schedule. It also provides a shell script to run those tests locally. This patch depends on patch [1] on branch-25.09. [1] "tests: Add new TAG_TEST_NOT_UPGRADABLE to some tests." Reported-at: https://issues.redhat.com/browse/FDP-1240 Assisted-by: claude, with model: Claude Sonnet 4.5 Signed-off-by: Xavier Simonart <xsimonar@redhat.com> Acked-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ales Musil <amusil@redhat.com>
1 parent f02eeac commit 9b26455

8 files changed

Lines changed: 1050 additions & 9 deletions

File tree

.ci/ci.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ function archive_logs() {
5454
cp -r $CONTAINER_WORKDIR/tests/system-*-testsuite.* \
5555
$log_dir || true \
5656
&& \
57+
cp -r $CONTAINER_WORKDIR/tests/upgrade-testsuite.* \
58+
$log_dir || true \
59+
&& \
5760
chmod -R +r $log_dir \
5861
&&
5962
tar -czvf $CONTAINER_WORKSPACE/logs.tgz $log_dir
@@ -102,7 +105,7 @@ function run_tests() {
102105
ARCH=$ARCH CC=$CC LIBS=$LIBS OPTS=$OPTS TESTSUITE=$TESTSUITE \
103106
TEST_RANGE=$TEST_RANGE SANITIZERS=$SANITIZERS DPDK=$DPDK \
104107
RECHECK=$RECHECK UNSTABLE=$UNSTABLE TIMEOUT=$TIMEOUT \
105-
./.ci/linux-build.sh
108+
BASE_VERSION=$BASE_VERSION ./.ci/linux-build.sh
106109
"
107110
}
108111

.ci/linux-build.sh

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#!/bin/bash
22

33
set -o errexit
4-
set -x
4+
5+
# Enable debug output for CI, optional for local
6+
NO_DEBUG=${NO_DEBUG:-0}
7+
if [ "$NO_DEBUG" = "0" ]; then
8+
set -x
9+
fi
510

611
ARCH=${ARCH:-"x86_64"}
712
USE_SPARSE=${USE_SPARSE:-"yes"}
@@ -181,17 +186,23 @@ function run_system_tests()
181186

182187
if ! sudo timeout -k 5m -v $TIMEOUT make $JOBS $type \
183188
TESTSUITEFLAGS="$TEST_RANGE" RECHECK=$RECHECK \
184-
SKIP_UNSTABLE=$SKIP_UNSTABLE; then
185-
# $log_file is necessary for debugging.
186-
cat tests/$log_file
189+
SKIP_UNSTABLE=$SKIP_UNSTABLE UPGRADE_TEST=$UPGRADE_TEST \
190+
BASE_VERSION=$BASE_VERSION; then
191+
# Suppress output locally when NO_DEBUG not 0.
192+
if [ "$NO_DEBUG" = "0" ]; then
193+
cat tests/$log_file
194+
fi
187195
return 1
188196
fi
189197
}
190198

191199
function execute_system_tests()
192200
{
193-
configure_ovn $OPTS
194-
make $JOBS || { cat config.log; exit 1; }
201+
# Upgrade tests build separately
202+
if [ "$UPGRADE_TEST" != "yes" ]; then
203+
configure_ovn $OPTS
204+
make $JOBS || { cat config.log; exit 1; }
205+
fi
195206

196207
local stable_rc=0
197208
local unstable_rc=0
@@ -201,8 +212,12 @@ function execute_system_tests()
201212
fi
202213

203214
if [ "$UNSTABLE" ]; then
204-
if ! SKIP_UNSTABLE=no TEST_RANGE="-k unstable" RECHECK=yes \
205-
run_system_tests $@; then
215+
if [[ "$TEST_RANGE" == *"-d"* ]]; then
216+
TEST_RANGE="-k unstable -d"
217+
else
218+
TEST_RANGE="-k unstable"
219+
fi
220+
if ! SKIP_UNSTABLE=no RECHECK=yes run_system_tests $@; then
206221
unstable_rc=1
207222
fi
208223
fi
@@ -238,6 +253,10 @@ if [ "$TESTSUITE" ]; then
238253
sudo bash -c "echo 2048 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages"
239254
execute_system_tests "check-system-dpdk" "system-dpdk-testsuite.log"
240255
;;
256+
257+
"upgrade-test")
258+
execute_system_tests "check-upgrade" "system-kmod-testsuite.log"
259+
;;
241260
esac
242261
else
243262
configure_ovn $OPTS

.ci/ovn_upgrade_test.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/env python3
2+
3+
import atexit
4+
import os
5+
import signal
6+
import sys
7+
from pathlib import Path
8+
9+
10+
from ovn_upgrade_utils import (
11+
log,
12+
chdir,
13+
run_command,
14+
run_shell_command,
15+
ovn_upgrade_save_current_binaries,
16+
ovn_upgrade_extract_info,
17+
run_upgrade_workflow,
18+
remove_upgrade_test_directory,
19+
UpgradeConfig
20+
)
21+
22+
DEFAULT_BASE_BRANCH = 'branch-24.03'
23+
24+
25+
def run_tests(config):
26+
log(f"Running system tests in upgrade scenario with flags "
27+
f"{config.env.flags}")
28+
29+
# Tests are run from the base-branch folder (when upgrading ovn-controller
30+
# and not yet northd, new features do not work. Hence we cannot use new
31+
# system-tests. We use the latest .ci/linux-build.sh i.e. from
32+
# ovn_root_dir.
33+
with chdir(config.path.base_dir):
34+
no_debug = "0" if config.is_ci else "1"
35+
36+
cmd = f"""CC={config.env.cc} TESTSUITE=system-test UPGRADE_TEST=yes
37+
TEST_RANGE="{config.env.flags}" UNSTABLE={config.env.unstable}
38+
NO_DEBUG={no_debug}
39+
. {config.path.ovn_root_dir}/.ci/linux-build.sh"""
40+
41+
return run_shell_command(cmd)
42+
43+
44+
def main():
45+
test_success = False
46+
47+
def cleanup():
48+
flags = os.environ.get('TESTSUITEFLAGS', '')
49+
if '-d' in flags or '--debug' in flags or not test_success:
50+
log(f"Keeping {config.path.upgrade_dir} for debugging")
51+
else:
52+
remove_upgrade_test_directory(config)
53+
54+
atexit.register(cleanup)
55+
signal.signal(signal.SIGINT, lambda s, f: sys.exit(1))
56+
signal.signal(signal.SIGTERM, lambda s, f: sys.exit(1))
57+
58+
config = UpgradeConfig.get(Path.cwd(), DEFAULT_BASE_BRANCH)
59+
60+
log("=" * 70)
61+
log(f"OVN Upgrade Test - Base: {config.base_version}, "
62+
f"Flags: {config.env.flags}")
63+
log("=" * 70)
64+
65+
if run_command("sudo -v").returncode:
66+
log("sudo access required")
67+
return 1
68+
69+
if not remove_upgrade_test_directory(config):
70+
return 1
71+
72+
config.path.upgrade_dir.mkdir(parents=True, exist_ok=True)
73+
config.path.base_dir.mkdir(parents=True, exist_ok=True)
74+
config.path.binaries_dir.mkdir(parents=True, exist_ok=True)
75+
76+
if not ovn_upgrade_save_current_binaries(config):
77+
return 1
78+
79+
if not ovn_upgrade_extract_info(config):
80+
return 1
81+
82+
if not run_upgrade_workflow(config):
83+
if config.is_ci:
84+
print(config.file.git_log.read_text(encoding='utf-8'))
85+
else:
86+
log(f"Check: {config.file.git_log}")
87+
return 1
88+
89+
test_success = run_tests(config)
90+
91+
log("=" * 70)
92+
if test_success:
93+
log("UPGRADE TESTS PASSED")
94+
else:
95+
log("UPGRADE TESTS FAILED")
96+
log(f"Check: {config.file.test_log}")
97+
log("=" * 70)
98+
99+
return 0 if test_success else 1
100+
101+
102+
if __name__ == "__main__":
103+
sys.exit(main())

0 commit comments

Comments
 (0)