From 5a7384173533d90d01168f2984ff026c6781f2c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Sl=C3=A1vik?= Date: Tue, 12 Dec 2023 15:23:17 +0100 Subject: [PATCH 1/2] Use universal path in reboot tests The /etc directory is writable from %post also with ostree, while /usr/libexec only on normal systems. --- fragments/shared/validation/success_on_first_boot.ks | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fragments/shared/validation/success_on_first_boot.ks b/fragments/shared/validation/success_on_first_boot.ks index eaab708a..3967c4d0 100644 --- a/fragments/shared/validation/success_on_first_boot.ks +++ b/fragments/shared/validation/success_on_first_boot.ks @@ -1,5 +1,5 @@ # Report success if no errors have been reported on the first boot. -# Additional tests can be implemented in /usr/libexec/kickstart-test.sh +# Additional tests can be implemented in /etc/kickstart-test.sh # by the kickstart test that includes this fragment. This file is empty # by default. @@ -16,7 +16,7 @@ After=graphical.target [Service] Type=oneshot -ExecStart=/bin/sh /usr/libexec/kickstart-service.sh +ExecStart=/bin/sh /etc/kickstart-service.sh [Install] WantedBy=graphical.target @@ -26,13 +26,13 @@ EOF # Create a script with the actual test. Print errors to stdout. # IMPORTANT: This file should be rewritten in tests! -touch /usr/libexec/kickstart-test.sh +touch /etc/kickstart-test.sh # Create a script for the service -cat > /usr/libexec/kickstart-service.sh << 'EOF' +cat > /etc/kickstart-service.sh << 'EOF' # Check error messages in the syslog. -error_messages="$(/bin/sh /usr/libexec/kickstart-test.sh)" +error_messages="$(/bin/sh /etc/kickstart-test.sh)" if [[ ! -z "${error_messages}" ]]; then echo "*** System has started with errors:" >> /root/RESULT From 91994b06ff9514c9898785b58867644c5375aa03 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 2/2] Add test for bootupd/bootc ostree containers --- rpm-ostree-container-bootc.ks.in | 44 +++++++++++++++++++++++++ rpm-ostree-container-bootc.sh | 56 ++++++++++++++++++++++++++++++++ 2 files changed, 100 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..71475321 --- /dev/null +++ b/rpm-ostree-container-bootc.sh @@ -0,0 +1,56 @@ +# +# 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() { + disksdir=$1 + args=$(for d in ${disksdir}/disk-*img; do echo -a ${d}; done) + + # There should be a /ostree/deploy/default/var/roothome/RESULT file with results in it. + # Check its contents and decide whether the test finally succeeded or not. + result=$(run_with_timeout ${COPY_FROM_IMAGE_TIMEOUT} "virt-cat ${args} /ostree/deploy/default/var/roothome/RESULT") + if [[ $? != 0 ]]; then + status=1 + echo '*** The RESULT file does not exist in VM image.' + elif [[ "${result}" != "SUCCESS" ]]; then + status=1 + echo "${result}" + fi + + return ${status} +} + +get_timeout() { + echo "80" +} + +additional_runner_args() { + # Wait for reboot and shutdown of the VM, + # but exit after the specified timeout. + echo "--wait $(get_timeout)" +}