Compare commits

...

1 Commits

Author SHA1 Message Date
Matteo Croce 39fb6e8cfe add test for upgrade
Add a basic test to check that systemd works after an upgrade
2025-04-17 14:21:55 +02:00
4 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,24 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
if [[ "$1" == "build" ]]; then
exit 0
fi
# Get the systemd version installed in the host assuming it's recent enough
# but a major version older than the one in the image.
if dnf --version |grep -q '^4\.'; then
disable='--disablerepo'
elif dnf --version |grep -q '^dnf5\s'; then
disable='--disable-repo'
else
echo 'Unknown dnf version!'
exit 1
fi
curver=$(dnf repoquery "$disable" mkosi --latest-limit=1 --queryformat='%{evr}' systemd)
pkgs=$(dnf repoquery 'systemd*' |grep -F "$curver" |grep -v -e -debuginfo -e -debugsource)
pkgdir=/usr/host-pkgs
dnf download --arch noarch --arch "$DISTRIBUTION_ARCHITECTURE" --destdir "$BUILDROOT$pkgdir" $pkgs

View File

@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
integration_tests += [
integration_test_template + {
'name' : fs.name(meson.current_source_dir()),
},
]

View File

@ -96,6 +96,7 @@ foreach dirname : [
'TEST-85-NETWORK', 'TEST-85-NETWORK',
'TEST-86-MULTI-PROFILE-UKI', 'TEST-86-MULTI-PROFILE-UKI',
'TEST-87-AUX-UTILS-VM', 'TEST-87-AUX-UTILS-VM',
'TEST-88-UPGRADE',
] ]
subdir(dirname) subdir(dirname)
endforeach endforeach

53
test/units/TEST-88-UPGRADE.sh Executable file
View File

@ -0,0 +1,53 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -eux
set -o pipefail
pkgdir=/usr/host-pkgs
if ! [ -d "$pkgdir" ]; then
echo "Distro packages not found in $pkgdir" >/skipped
exit 77
fi
minor=$(systemctl --version |awk '/^systemd/{print$2}')
if which networkctl >/dev/null; then
networkd=1
fi
if dnf --version |grep -q '^4\.'; then
disable='--disablerepo'
elif dnf --version |grep -q '^dnf5\s'; then
disable='--disable-repo'
else
echo 'Unknown dnf version!'
exit 1
fi
dnf downgrade -y --allowerasing "$disable" '*' "$pkgdir"/*.rpm
newminor=$(systemctl --version |awk '/^systemd/{print$2}')
if [ "$newminor" -lt "$minor" ]; then
echo "Downgrade to $newminor was successful."
else
echo "Downgrade failed. Current version is still $newminor."
exit 1
fi
# TODO: sanity checks
systemctl --failed |grep -Fqx '0 loaded units listed.'
[ -n "$networkd" ] && networkctl status
loginctl list-sessions
# Finally test the upgrade
dnf -y upgrade $disable '*' "$PACKAGEDIR"/*.rpm
# TODO: sanity checks
systemctl --failed |grep -Fqx '0 loaded units listed.'
[ -n "$networkd" ] && networkctl status
loginctl list-sessions