Skip to content

Commit

Permalink
Merge pull request #1116 from rvykydal/ostreecontainer-bootc-update
Browse files Browse the repository at this point in the history
Ostreecontainer bootc test with reboot
  • Loading branch information
rvykydal authored Apr 10, 2024
2 parents 716755c + d7e66d1 commit b4d8aa0
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 16 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Default storage configuration with lvm type enforced for Fedora
zerombr
clearpart --all
autopart --type=lvm
1 change: 0 additions & 1 deletion fragments/platform/rhel10/payload/ostreecontainer.ks

This file was deleted.

1 change: 0 additions & 1 deletion fragments/platform/rhel9/payload/ostreecontainer.ks

This file was deleted.

4 changes: 4 additions & 0 deletions fragments/shared/storage/ostreecontainer_autopart.ks
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Default storage configuration
zerombr
clearpart --all
autopart
23 changes: 19 additions & 4 deletions fragments/shared/validation/success_on_first_boot.ks
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
53 changes: 53 additions & 0 deletions rpm-ostree-container-bootc.ks.in
Original file line number Diff line number Diff line change
@@ -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
73 changes: 73 additions & 0 deletions rpm-ostree-container-bootc.sh
Original file line number Diff line number Diff line change
@@ -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)"
}
11 changes: 2 additions & 9 deletions rpm-ostree-container.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions scripts/defaults-rhel10.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
1 change: 1 addition & 0 deletions scripts/defaults-rhel9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
1 change: 1 addition & 0 deletions scripts/defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit b4d8aa0

Please sign in to comment.