Files
linux-updater/tests/containers/run_tests.sh
T

129 lines
5.6 KiB
Bash
Executable File

#!/bin/sh
set -e
# Container integration test suite for Linux System Updater
# Runs inside clean Podman containers on macOS
DISTRO="${1:-all}"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
WORKSPACE="$(cd "${SCRIPT_DIR}/../.." && pwd)"
run_distro_test() {
D="$1"
echo ""
echo "=========================================================="
echo " [TEST] Starting container testing for: ${D}"
echo "=========================================================="
case "${D}" in
debian)
IMAGE="docker.io/library/debian:12-slim"
CMD="
apt-get update -qq && apt-get install -y -qq python3 > /dev/null
echo '=== 1. Building packages inside Debian container ==='
python3 packaging/build_packages.py
echo '=== 2. Installing .deb package ==='
dpkg -i dist/linux-updater_1.0.0_all.deb
echo '=== 3. Testing installed command ==='
linux-updater --version
echo '=== 4. Testing pre-flight health checks ==='
linux-updater health
echo '=== 5. Testing regular update (dry-run) ==='
linux-updater update --dry-run -y
echo '=== 6. Testing major release upgrade (dry-run) ==='
linux-updater release-upgrade --dry-run -y -t trixie
echo '=== 7. Verifying standard /var/log/linux-updater logging ==='
ls -la /var/log/linux-updater
test -f /var/log/linux-updater/latest.log
"
;;
ubuntu)
IMAGE="docker.io/library/ubuntu:22.04"
CMD="
apt-get update -qq && apt-get install -y -qq python3 > /dev/null
echo '=== 1. Building packages inside Ubuntu container ==='
python3 packaging/build_packages.py
echo '=== 2. Installing .deb package ==='
dpkg -i dist/linux-updater_1.0.0_all.deb
echo '=== 3. Testing installed command ==='
linux-updater --version
echo '=== 4. Testing pre-flight health checks ==='
linux-updater health
echo '=== 5. Testing regular update (dry-run) ==='
linux-updater update --dry-run -y
echo '=== 6. Testing major release upgrade (dry-run) ==='
linux-updater release-upgrade --dry-run -y -t 24.04
echo '=== 7. Verifying standard /var/log/linux-updater logging ==='
ls -la /var/log/linux-updater
test -f /var/log/linux-updater/latest.log
"
;;
fedora)
IMAGE="docker.io/library/fedora:40"
CMD="
dnf install -y -q python3 rpm-build python3-dnf-plugins-core > /dev/null
rm -rf dist/rpm
echo '=== 1. Building packages and RPM inside Fedora container ==='
python3 packaging/build_packages.py
echo '=== 2. Installing generated .rpm package ==='
rpm -Uvh --replacepkgs --replacefiles dist/rpm/RPMS/noarch/linux-updater-*.noarch.rpm
echo '=== 3. Testing installed command ==='
linux-updater --version
echo '=== 4. Testing pre-flight health checks ==='
linux-updater health
echo '=== 5. Testing regular update (dry-run) ==='
linux-updater update --dry-run -y
echo '=== 6. Testing major release upgrade (dry-run) ==='
linux-updater release-upgrade --dry-run -y -t 41
echo '=== 7. Verifying standard /var/log/linux-updater logging ==='
ls -la /var/log/linux-updater
test -f /var/log/linux-updater/latest.log
"
;;
almalinux8)
IMAGE="docker.io/library/almalinux:8"
CMD="
dnf install -y -q python3 rpm-build > /dev/null
rm -rf dist/rpm
echo '=== 1. Verifying Native Python on AlmaLinux 8 ==='
python3 --version
echo '=== 2. Building packages and RPM inside AlmaLinux 8 container ==='
python3 packaging/build_packages.py
echo '=== 3. Installing generated .rpm package ==='
rpm -Uvh --replacepkgs --replacefiles dist/rpm/RPMS/noarch/linux-updater-*.noarch.rpm
echo '=== 4. Testing installed command on Python 3.6 ==='
linux-updater --version
echo '=== 5. Testing pre-flight health checks ==='
linux-updater health
echo '=== 6. Testing regular update (dry-run) ==='
linux-updater update --dry-run -y
echo '=== 7. Testing major release upgrade (dry-run) ==='
linux-updater release-upgrade --dry-run -y
echo '=== 8. Verifying standard /var/log/linux-updater logging ==='
ls -la /var/log/linux-updater
test -f /var/log/linux-updater/latest.log
"
;;
*)
echo "Unknown distro: ${D}" >&2
return 1
;;
esac
podman run --rm -v "${WORKSPACE}:/workspace:Z" -w /workspace "${IMAGE}" bash -c "${CMD}"
echo ">>> [SUCCESS] Testing for ${D} PASSED!"
}
if [ "${DISTRO}" = "all" ]; then
for target in debian ubuntu fedora almalinux8; do
run_distro_test "${target}"
done
else
run_distro_test "${DISTRO}"
fi
echo ""
echo "=========================================================="
echo " ALL REQUESTED CONTAINER TESTS COMPLETED SUCCESSFULLY!"
echo "=========================================================="