From 5ee53310f79bbcda734a2967cc62865ee0e34d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Sl=C3=A1vik?= Date: Thu, 7 Dec 2023 21:12:49 +0100 Subject: [PATCH] Add test for bootupd/bootc ostree containers --- rpm-ostree-container-bootc.ks.in | 44 ++++++++++++++++++++++++++ rpm-ostree-container-bootc.sh | 53 ++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 rpm-ostree-container-bootc.ks.in create mode 100755 rpm-ostree-container-bootc.sh diff --git a/rpm-ostree-container-bootc.ks.in b/rpm-ostree-container-bootc.ks.in new file mode 100644 index 00000000..e0fa8274 --- /dev/null +++ b/rpm-ostree-container-bootc.ks.in @@ -0,0 +1,44 @@ +#test name: rpm-ostree-container-bootc +# for bootc/bootupd +# depends on the referenced ostree container being bootable + +# Use the default settings. +%ksappend common/common_no_payload.ks + +# Set up the RPM OSTree source. +ostreecontainer --no-signature-verification --url=quay.io/centos-bootc/fedora-bootc:eln + +# Reboot the installed system. +reboot + +# Validate on the first boot. +%ksappend validation/success_on_first_boot.ks + +%post + +# Checks in %post +# Check the url of the remote. +url="$(ostree remote show-url default)" +if [ "${url}" != "quay.io/centos-bootc/fedora-bootc:eln" ]; then + echo "Unexpected URL: ${url}" >> /root/RESULT +fi + +# Checks after boot +cat > /etc/kickstart-test.sh << 'EOF' + +# propagate any errors from %post validations +if [ -e /root/RESULT ]; then + cat /root/RESULT +fi + +# Check that bootupd information is present +if [ ! -e /boot/bootupd-state.json ]; then + echo "/boot/bootupd-state.json not found on installed system after booting" +fi + +bootupctl --help || echo "bootupctl command not available after booting" +bootc --help || echo "bootc command not available after booting" + +EOF + +%end diff --git a/rpm-ostree-container-bootc.sh b/rpm-ostree-container-bootc.sh new file mode 100755 index 00000000..766aa68f --- /dev/null +++ b/rpm-ostree-container-bootc.sh @@ -0,0 +1,53 @@ +# +# Copyright (C) 2023 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. You should have received a copy of the +# GNU General Public License along with this program; if not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# + +# Ignore unused variable parsed out by tooling scripts as test tags metadata +# shellcheck disable=SC2034 +TESTTYPE="payload ostree bootc reboot skip-on-rhel" + +. ${KSTESTDIR}/functions.sh + +kernel_args() { + # Enforce the Fedora-Silverblue configuration. + echo ${DEFAULT_BOOTOPTS} inst.profile=fedora-silverblue +} + +validate() { + # We are not able to copy files from the system. + # Look for the result in the logs we have. + local disksdir=$1 + cat "${disksdir}/virt-install.log" | grep -q "SUCCESS" + + if [[ $? != 0 ]]; then + status=1 + echo '*** The test has failed.' + return 1 + fi + + return 0 +} + +get_timeout() { + echo "120" +} + +additional_runner_args() { + # Wait for reboot and shutdown of the VM, + # but exit after the specified timeout. + echo "--wait $(get_timeout)" +}