Skip to content

Commit

Permalink
e2e-upgrades: add basic tests with new rpm-ostree version
Browse files Browse the repository at this point in the history
Test new rpm-ostree with kernel override, initramfs args,
initramfs-etc, layering, overrides.
See #4776
  • Loading branch information
HuijingHei committed Jan 19, 2024
1 parent 57c7a00 commit e3b0be9
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ci/prow/kola/upgrades
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

set -xeuo pipefail

. /usr/lib/coreos-assembler/tests/kola/rpm-ostree/utils.sh

cd $(mktemp -d)

case "${AUTOPKGTEST_REBOOT_MARK:-}" in
Expand All @@ -25,6 +27,9 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in
rpm -q moby-engine
test '!' -f /etc/somenewfile

# test with new rpm-ostree
do_testing

upgrade_image=$(cat /etc/upgrade-image)
rpm-ostree rebase ${upgrade_image}
/tmp/autopkgtest-reboot 1
Expand All @@ -43,6 +48,8 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in
fi
test -f /etc/somenewfile

do_checking

echo "ok e2e upgrade"
;;
*) echo "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}"; exit 1;;
Expand Down
87 changes: 87 additions & 0 deletions ci/prow/kola/utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

. /etc/os-release
case $VERSION_ID in
39) kernel_release=6.5.6-300.fc39.x86_64
koji_kernel_url="https://koji.fedoraproject.org/koji/buildinfo?buildID=2302642"
;;
*) echo "Unsupported Fedora version: $VERSION_ID"
exit 1
;;
esac

get_deployment_root() {
local csum="$(rpm-ostree status --json | jq -r '.deployments[0].checksum')"

Check warning

Code scanning / shellcheck

Declare and assign separately to avoid masking return values. Warning

Declare and assign separately to avoid masking return values.
local serial="$(rpm-ostree status --json | jq -r '.deployments[0].serial')"

Check warning

Code scanning / shellcheck

Declare and assign separately to avoid masking return values. Warning

Declare and assign separately to avoid masking return values.
local osname="$(rpm-ostree status --json | jq -r '.deployments[0].osname')"

Check warning

Code scanning / shellcheck

Declare and assign separately to avoid masking return values. Warning

Declare and assign separately to avoid masking return values.
echo /ostree/deploy/$osname/deploy/$csum.$serial
}

do_testing() {
# override kernel
# copy test code from test-override-kernel.sh
current=$(rpm-ostree status --json | jq -r '.deployments[0].checksum')
rpm-ostree db list "${current}" > current-dblist.txt
if grep -qF $kernel_release current-dblist.txt; then
echo "Should not find $kernel_release in current deployment"
exit 1
fi

grep -E '^ kernel-[0-9]' current-dblist.txt | sed -e 's,^ *,,' > orig-kernel.txt
test "$(wc -l < orig-kernel.txt)" == "1"
orig_kernel=$(cat orig-kernel.txt)

rpm-ostree override replace $koji_kernel_url
new=$(rpm-ostree status --json | jq -r '.deployments[0].checksum')
rpm-ostree db list "${new}" > new-dblist.txt
if ! grep -qF $kernel_release new-dblist.txt; then
echo "Should find $kernel_release in the new deployment"
exit 1
fi

if grep -q -F -e "${orig_kernel}" new-dblist.txt; then
echo "Should not find ${orig_kernel} in the new deployment"
exit 1
fi
newroot=$(get_deployment_root)
find ${newroot}/usr/lib/modules -maxdepth 1 -type d > modules-dirs.txt
test "$(wc -l < modules-dirs.txt)" == "2"
if ! grep -qF $kernel_release modules-dirs.txt; then
echo "Should find $kernel_release in ${newroot}/usr/lib/modules"
exit 1
fi

rpm-ostree kargs --append foo=bar

touch /etc/foobar.conf
rpm-ostree initramfs --enable --arg=-I --arg=/etc/foobar.conf

rpm-ostree override remove vim-minimal
rpm-ostree install vim-filesystem
}

do_checking() {
test "$(uname -r)" == $kernel_release

cat /proc/cmdline > cmdlinekargs.txt
if ! grep foo=bar cmdlinekargs.txt; then
echo "can not find kernel parameter foo=bar"
exit 1
fi

lsinitrd "/usr/lib/modules/$(uname -r)/initramfs.img" > lsinitrd.txt
if ! grep etc/foobar.conf lsinitrd.txt; then
echo "can not find file expected to be included in initramfs.img"
exit 1
fi

if rpm -q vim-minimal 2>/dev/null; then
echo "found package expected to be removed"
exit 1
fi

if ! rpm -q vim-filesystem; then
echo "can not find package expected to be installed"
exit 1
fi
}

0 comments on commit e3b0be9

Please sign in to comment.