diff --git a/fragments/platform/fedora_rawhide/payload/ostreecontainer.ks b/fragments/platform/fedora_rawhide/payload/ostreecontainer.ks deleted file mode 100644 index 7b175a55..00000000 --- a/fragments/platform/fedora_rawhide/payload/ostreecontainer.ks +++ /dev/null @@ -1 +0,0 @@ -ostreecontainer --no-signature-verification --transport=registry --url=quay.io/centos-bootc/fedora-bootc:eln diff --git a/fragments/platform/fedora_rawhide/storage/ostreecontainer_autopart.ks b/fragments/platform/fedora_rawhide/storage/ostreecontainer_autopart.ks new file mode 100644 index 00000000..c82b8849 --- /dev/null +++ b/fragments/platform/fedora_rawhide/storage/ostreecontainer_autopart.ks @@ -0,0 +1,4 @@ +# Default storage configuration with lvm type enforced for Fedora +zerombr +clearpart --all +autopart --type=lvm diff --git a/fragments/platform/rhel10/payload/ostreecontainer.ks b/fragments/platform/rhel10/payload/ostreecontainer.ks deleted file mode 100644 index 3869cff0..00000000 --- a/fragments/platform/rhel10/payload/ostreecontainer.ks +++ /dev/null @@ -1 +0,0 @@ -ostreecontainer --no-signature-verification --transport=registry --url=quay.io/centos-bootc/centos-bootc:stream10 diff --git a/fragments/platform/rhel9/payload/ostreecontainer.ks b/fragments/platform/rhel9/payload/ostreecontainer.ks deleted file mode 100644 index 0036cca0..00000000 --- a/fragments/platform/rhel9/payload/ostreecontainer.ks +++ /dev/null @@ -1 +0,0 @@ -ostreecontainer --no-signature-verification --transport=registry --url=quay.io/centos-bootc/centos-bootc:stream9 diff --git a/fragments/shared/storage/ostreecontainer_autopart.ks b/fragments/shared/storage/ostreecontainer_autopart.ks new file mode 100644 index 00000000..233a3fe6 --- /dev/null +++ b/fragments/shared/storage/ostreecontainer_autopart.ks @@ -0,0 +1,4 @@ +# Default storage configuration +zerombr +clearpart --all +autopart diff --git a/fragments/shared/validation/success_on_first_boot.ks b/fragments/shared/validation/success_on_first_boot.ks index eaab708a..03cee8e5 100644 --- a/fragments/shared/validation/success_on_first_boot.ks +++ b/fragments/shared/validation/success_on_first_boot.ks @@ -3,7 +3,22 @@ # by the kickstart test that includes this fragment. This file is empty # by default. +# A somewhat different approach via systemd-sysext/overlayfs is needed +# in ostree systems with read-only /usr + %post +# detect if the system uses ostree and change path prefix if needed +if ostree admin status &> /dev/null; then + # based on info from https://www.reddit.com/r/Fedora/comments/wir3cq/comment/ijhjfah + mkdir -p /var/lib/extensions/kickstart-tests/usr/lib/extension-release.d \ + /var/lib/extensions/kickstart-tests/usr/libexec + cp /etc/os-release /var/lib/extensions/kickstart-tests/usr/lib/extension-release.d/extension-release.kickstart-tests + script_prefix="/var/lib/extensions/kickstart-tests" + systemd-sysext merge + systemctl enable systemd-sysext +else + script_prefix="" +fi # Create a systemd service. cat > /etc/systemd/system/kickstart-test.service << EOF @@ -16,7 +31,7 @@ After=graphical.target [Service] Type=oneshot -ExecStart=/bin/sh /usr/libexec/kickstart-service.sh +ExecStart=/bin/sh ${script_prefix}/usr/libexec/kickstart-service.sh [Install] WantedBy=graphical.target @@ -26,13 +41,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 ${script_prefix}/usr/libexec/kickstart-test.sh # Create a script for the service -cat > /usr/libexec/kickstart-service.sh << 'EOF' +cat > ${script_prefix}/usr/libexec/kickstart-service.sh << 'EOF' # Check error messages in the syslog. -error_messages="$(/bin/sh /usr/libexec/kickstart-test.sh)" +error_messages="$(/bin/sh ${script_prefix}/usr/libexec/kickstart-test.sh)" if [[ ! -z "${error_messages}" ]]; then echo "*** System has started with errors:" >> /root/RESULT diff --git a/rpm-ostree-container-bootc.ks.in b/rpm-ostree-container-bootc.ks.in new file mode 100644 index 00000000..e0954b43 --- /dev/null +++ b/rpm-ostree-container-bootc.ks.in @@ -0,0 +1,53 @@ +#test name: rpm-ostree-container-bootc +# for bootc/bootupd, remote and stateroot ostreecontainer options +# depends on the referenced ostree container being bootable + +# Use the default settings. +%ksappend common/common_no_storage_and_payload.ks +# On Fedora enforce lvm scheme (overriding btrfs default) +%ksappend storage/ostreecontainer_autopart.ks + +ostreecontainer --no-signature-verification --remote=test-remote --stateroot=test-stateroot --url=@KSTEST_OSTREECONTAINER_URL@ + +# Reboot the installed system. +reboot + +# Validate on the first boot. +%ksappend validation/success_on_first_boot.ks + +%post + +# Checks after boot +cat >> /var/lib/extensions/kickstart-tests/usr/libexec/kickstart-test.sh << 'EOF' + +# propagate any errors from %post validations +if [ -e /root/RESULT ]; then + cat /root/RESULT +fi + +# Check that state root 'test-stateroot' exists +if [ ! -d /ostree/deploy/test-stateroot ]; then + echo "Couldn't find 'test-stateroot' stateroot" +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 &> /dev/null || echo "bootupctl command not available after booting" +bootc --help &> /dev/null || echo "bootc command not available after booting" + +expected_url="@KSTEST_OSTREECONTAINER_URL@" +remote_url="$(ostree remote show-url test-remote)" +if [ ${?} -ne 0 ]; then + echo "Couldn't list remote URL for 'test-remote'" >> /root/RESULT +fi + +if [ "${remote_url}" != "${expected_url}" ]; then + echo "Unexpected URL: ${remote_url}, expected ${expected_url}"" >> /root/RESULT +fi + + +EOF +%end diff --git a/rpm-ostree-container-bootc.sh b/rpm-ostree-container-bootc.sh new file mode 100755 index 00000000..336cd157 --- /dev/null +++ b/rpm-ostree-container-bootc.sh @@ -0,0 +1,73 @@ +# +# 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-8 skip-on-rhel-10" + +. ${KSTESTDIR}/functions.sh + +copy_interesting_files_from_system() { + local disksdir + disksdir="${1}" + + # Find disks. + local args + args=$(for d in ${disksdir}/disk-*img; do echo -a ${d}; done) + + # Use also iscsi disk if there is any. + if [[ -n ${iscsi_disk_img} ]]; then + args="${args} -a ${disksdir}/${iscsi_disk_img}" + fi + + # Grab files out of the installed system while it still exists. + # Grab these files: + # + # logs from Anaconda - whole /var/log/anaconda/ directory is copied out, + # this can be used for saving specific test output + # original-ks.cfg - the kickstart used for the test + # anaconda-ks.cfg - the kickstart saved after installation, useful for + # debugging + # RESULT - file from the test + # + # The location of aforementioned files is different in an ostree system + + root_device=$(guestfish ${args} <<< " + launch + lvs" | \ + grep root) + + for item in /ostree/deploy/test-stateroot/var/roothome/original-ks.cfg \ + /ostree/deploy/test-stateroot/var/roothome/anaconda-ks.cfg \ + /ostree/deploy/test-stateroot/var/roothome/anabot.log \ + /ostree/deploy/test-stateroot/var/log/anaconda/ \ + /ostree/deploy/test-stateroot/var/roothome/RESULT + do + guestfish ${args} <<< " + launch + mount ${root_device} / + copy-out '${item}' '${disksdir}' + " 2>/dev/null + done +} + +additional_runner_args() { + # Wait for reboot and shutdown of the VM, + # but exit after the specified timeout. + echo "--wait $(get_timeout)" +} diff --git a/rpm-ostree-container.ks.in b/rpm-ostree-container.ks.in index d1963ab5..f2ae2db2 100644 --- a/rpm-ostree-container.ks.in +++ b/rpm-ostree-container.ks.in @@ -7,20 +7,13 @@ %ksappend common/common_no_payload.ks -# Set up the RPM OSTree source. -%ksappend payload/ostreecontainer.ks +ostreecontainer --no-signature-verification --transport=registry --url=@KSTEST_OSTREECONTAINER_URL@ %post -if [[ "@KSTEST_OS_NAME@" == "rhel" ]]; then - EXPECTED_URL="quay.io/centos-bootc/centos-bootc:stream9" -else - EXPECTED_URL="quay.io/centos-bootc/fedora-bootc:eln" -fi - # Check the url of the remote. url="$(ostree remote show-url default)" -if [ "${url}" != "${EXPECTED_URL}" ]; then +if [ "${url}" != "@KSTEST_OSTREECONTAINER_URL@" ]; then echo "Unexpected URL: ${url}" >> /root/RESULT fi diff --git a/scripts/defaults-rhel10.sh b/scripts/defaults-rhel10.sh index d5b47568..31d6fe1a 100644 --- a/scripts/defaults-rhel10.sh +++ b/scripts/defaults-rhel10.sh @@ -6,3 +6,4 @@ source network-device-names.cfg export KSTEST_URL='http://download.eng.bos.redhat.com/rhel-10/nightly/RHEL-10-Public-Beta/latest-RHEL-10.0/compose/BaseOS/x86_64/os/' export KSTEST_MODULAR_URL='http://download.eng.bos.redhat.com/rhel-10/nightly/RHEL-10-Public-Beta/latest-RHEL-10.0/compose/AppStream/x86_64/os/' export KSTEST_FTP_URL='ftp://ftp.tu-chemnitz.de/pub/linux/fedora/linux/development/rawhide/Everything/$basearch/os/' +export KSTEST_OSTREECONTAINER_URL='quay.io/centos-bootc/centos-bootc:stream10' diff --git a/scripts/defaults-rhel9.sh b/scripts/defaults-rhel9.sh index 2229f74a..a4d88d41 100644 --- a/scripts/defaults-rhel9.sh +++ b/scripts/defaults-rhel9.sh @@ -4,3 +4,4 @@ source network-device-names.cfg export KSTEST_URL='http://download.eng.bos.redhat.com/rhel-9/nightly/RHEL-9/latest-RHEL-9.4.0/compose/BaseOS/x86_64/os/' export KSTEST_MODULAR_URL='http://download.eng.bos.redhat.com/rhel-9/nightly/RHEL-9/latest-RHEL-9.4.0/compose/AppStream/x86_64/os/' export KSTEST_FTP_URL='ftp://ftp.tu-chemnitz.de/pub/linux/fedora/linux/development/rawhide/Everything/$basearch/os/' +export KSTEST_OSTREECONTAINER_URL='quay.io/centos-bootc/centos-bootc:stream9' diff --git a/scripts/defaults.sh b/scripts/defaults.sh index 1174b050..8b1abeba 100644 --- a/scripts/defaults.sh +++ b/scripts/defaults.sh @@ -12,3 +12,4 @@ export KSTEST_METALINK='https://mirrors.fedoraproject.org/metalink?repo=fedora-$ export KSTEST_MIRRORLIST='https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch' export KSTEST_MODULAR_URL='http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Modular/$basearch/os/' export KSTEST_FTP_URL='ftp://ftp.tu-chemnitz.de/pub/linux/fedora/linux/development/rawhide/Everything/$basearch/os/' +export KSTEST_OSTREECONTAINER_URL='quay.io/centos-bootc/fedora-bootc:eln'