2018-01-28 23:16:22 +03:00
#!/bin/bash
#
# Copyright (C) 2017 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
set -euo pipefail
. ${ commondir } /libtest.sh
. ${ commondir } /libvm.sh
set -x
osid = $( vm_cmd grep -E '^ID=' /etc/os-release)
if test " ${ osid } " != 'ID=fedora' ; then
echo " ok skip on OS ID= ${ osid } "
exit 0
fi
2019-09-06 22:34:11 +03:00
versionid = $( vm_cmd grep -E '^VERSION_ID=' /etc/os-release)
versionid = ${ versionid : 11 } # trim off VERSION_ID=
2020-05-29 17:21:06 +03:00
# Test that we can override the kernel; we use the "gold"
# kernel because we know it won't be GC'd. Use e.g.
# `koji latest-pkg f32 kernel`
# to find this. (In contrast, koji latest-pkg f32-updates kernel
# will get the latest updates).
2018-01-28 23:16:22 +03:00
current = $( vm_get_booted_csum)
vm_cmd rpm-ostree db list " ${ current } " > current-dblist.txt
2019-09-06 22:34:11 +03:00
case $versionid in
Rework vmcheck to use `kola spawn`, move off of PAPR
There's a lot going on here, but essentially:
1. We change the `vmcheck` model so that it always operates on an
immutable base image. It takes that image and dynamically launches a
separate VM for each test using `kola spawn`. This means we can drop
a lot of hacks around re-using the same VMs.
2. Following from 1., `vmoverlay` now takes as input a base image,
overlays the built rpm-ostree bits, then creates a new base image. Of
course, we don't have to do this in CI, because we build FCOS with
the freshly built RPMs (so it uses `SKIP_VMOVERLAY=1`). `vmoverlay`
then will be more for the developer case where one doesn't want to
iterate via `cosa build` to test rpm-ostree changes. I say "will"
because the functionality doesn't exist yet; I'd like to enhance
`cosa dev-overlay` to do this. (Note `vmsync` should still works just
as before too.)
3. `vmcheck` can be run without building the tree first, as
`tests/vmcheck.sh`. The `make vmcheck` target still exists though for
finger compatibility and better meshing with `vmoverlay` in the
developer case.
What's really nice about using kola spawn is that it takes care of a lot
of things for us, such as the qemu command, journal and console
gathering, and SSH.
Similarly to the compose testsuites, we're using parallel here to run
multiple vmcheck tests at once. (On developer laptops, we cap
parallelism at `$(nproc) - 1`).
2019-12-13 20:23:41 +03:00
31) kernel_release = 5.3.7-301.fc31.x86_64; ;
2020-05-29 17:21:06 +03:00
32) kernel_release = 5.6.6-300.fc32.x86_64; ;
2020-12-07 14:40:06 +03:00
33) kernel_release = 5.8.15-301.fc33.x86_64; ;
2019-09-06 22:34:11 +03:00
*) assert_not_reached " Unsupported Fedora version: $versionid " ; ;
esac
2019-03-15 17:00:52 +03:00
assert_not_file_has_content current-dblist.txt $kernel_release
2019-04-04 18:33:19 +03:00
grep -E '^ kernel-5' current-dblist.txt | sed -e 's,^ *,,' > orig-kernel.txt
2018-01-28 23:16:22 +03:00
assert_streq " $( wc -l < orig-kernel.txt) " "1"
orig_kernel = $( cat orig-kernel.txt)
2019-09-06 22:34:11 +03:00
URL_ROOT = " https://dl.fedoraproject.org/pub/fedora/linux/releases/ $versionid /Everything/x86_64/os/Packages/k "
2018-08-18 00:34:02 +03:00
vm_rpmostree override replace \
2019-03-15 17:00:52 +03:00
" $URL_ROOT /kernel{,-core,-modules{,-extra}}- $kernel_release .rpm "
2018-01-28 23:16:22 +03:00
new = $( vm_get_pending_csum)
vm_cmd rpm-ostree db list " ${ new } " > new-dblist.txt
2019-03-15 17:00:52 +03:00
assert_file_has_content_literal new-dblist.txt $kernel_release
2018-01-28 23:16:22 +03:00
if grep -q -F -e " ${ orig_kernel } " new-dblist.txt; then
fatal " Found kernel: ${ line } "
fi
2018-04-23 19:59:57 +03:00
newroot = $( vm_get_deployment_root 0)
vm_cmd find ${ newroot } /usr/lib/modules -maxdepth 1 -type d > modules-dirs.txt
assert_streq " $( wc -l < modules-dirs.txt) " "2"
2019-03-15 17:00:52 +03:00
assert_file_has_content_literal modules-dirs.txt $kernel_release
2018-04-23 19:59:57 +03:00
2018-01-28 23:16:22 +03:00
echo "ok override kernel"
2020-02-26 19:14:51 +03:00
# And check that we can regenerate the initramfs and include files from our /etc
vm_cmd touch /etc/foobar.conf
vm_rpmostree initramfs --enable --arg= -I --arg= /etc/foobar.conf
newroot = $( vm_get_deployment_root 0)
vm_cmd lsinitrd ${ newroot } /usr/lib/modules/${ kernel_release } /initramfs.img > lsinitrd.txt
assert_file_has_content_literal lsinitrd.txt etc/foobar.conf
echo "ok override kernel with custom initramfs args"
2020-02-26 19:14:53 +03:00
# FCOS omits lvm; check that we still omit lvm here too
assert_file_has_content_literal lsinitrd.txt "--omit 'lvm'"
echo "ok override kernel uses base initramfs args"