From 27940987eb45983212d1c0ce0c26883ebe30f5d7 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 9 Aug 2022 15:04:36 -0700 Subject: [PATCH] Add an updates test that builds an ostree and ostree installer Signed-off-by: Adam Williamson --- templates-updates.fif.json | 36 ++++++++++++++ tests/_ostree_build.pm | 97 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 tests/_ostree_build.pm diff --git a/templates-updates.fif.json b/templates-updates.fif.json index 909f8fd3..ea127a38 100644 --- a/templates-updates.fif.json +++ b/templates-updates.fif.json @@ -116,6 +116,21 @@ }, "version": "*" }, + "fedora-updates-silverblue-dvd_ostree-iso-x86_64-*": { + "arch": "x86_64", + "distri": "fedora", + "flavor": "updates-silverblue-dvd_ostree-iso", + "settings": { + "CANNED": "1", + "DESKTOP": "gnome", + "HDDSIZEGB": "15", + "LIVE": "1", + "NUMDISKS": "2", + "PACKAGE_SET": "default", + "RETRY": "1" + }, + "version": "*" + }, "fedora-updates-workstation-live-iso-x86_64-*": { "arch": "x86_64", "distri": "fedora", @@ -223,6 +238,10 @@ "machine": "uefi", "product": "fedora-updates-kde-live-iso-x86_64-*" }, + "fedora-updates-silverblue-dvd_ostree-iso-x86_64-*-64bit": { + "machine": "64bit", + "product": "fedora-updates-silverblue-dvd_ostree-iso-x86_64-*" + }, "fedora-updates-workstation-live-iso-x86_64-*-64bit": { "machine": "64bit", "product": "fedora-updates-workstation-live-iso-x86_64-*" @@ -401,6 +420,23 @@ "USER_LOGIN": "false" } }, + "ostree_build": { + "profiles": { + "fedora-updates-silverblue-dvd_ostree-iso-x86_64-*-64bit": 40 + }, + "settings": { + "+DESKTOP": "", + "+CANNED": "", + "BOOTFROM": "c", + "GRUB_POSTINSTALL": "selinux=0", + "HDD_1": "disk_f%VERSION%_minimal_3_%ARCH%.qcow2", + "HDDSIZEGB_3": "25", + "+NUMDISKS": "3", + "POSTINSTALL": "_ostree_build", + "ROOT_PASSWORD": "weakpassword", + "USER_LOGIN": "false" + } + }, "podman": { "profiles": { "fedora-updates-container-aarch64-*-aarch64": 40, diff --git a/tests/_ostree_build.pm b/tests/_ostree_build.pm new file mode 100644 index 00000000..041b4a8f --- /dev/null +++ b/tests/_ostree_build.pm @@ -0,0 +1,97 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +sub run { + my $self = shift; + my $version = get_var("VERSION"); + my $currrel = get_var("CURRREL"); + my $rawrel = get_var("RAWREL"); + my $repo = $version eq $rawrel ? "fedora-rawhide.repo" : "fedora.repo"; + my $branch; + my $releasever; + if ($version eq $rawrel) { + $branch = "main"; + $releasever = "Rawhide"; + } + else { + $branch = "f${version}"; + $releasever = $version; + } + my $advortask = get_var("ADVISORY_OR_TASK"); + my $arch = get_var("ARCH"); + my $subv = get_var("SUBVARIANT"); + my $lcsubv = lc($subv); + if (get_var("NUMDISKS") > 2) { + # put /var/lib/mock on the third disk, so we don't run out of + # space on the main disk. The second disk will have already + # been claimed for the update repo. + assert_script_run "echo 'type=83' | sfdisk /dev/vdc"; + assert_script_run "mkfs.ext4 /dev/vdc1"; + assert_script_run "echo '/dev/vdc1 /var/lib/mock ext4 defaults 1 2' >> /etc/fstab"; + assert_script_run "mkdir -p /var/lib/mock"; + assert_script_run "mount /var/lib/mock"; + } + # install the tools we need + assert_script_run "dnf -y install mock git lorax flatpak", 120; + # create the mock config + make_update_mock_config; + # now check out workstation-ostree-config + assert_script_run 'git clone https://pagure.io/workstation-ostree-config.git'; + assert_script_run 'cd fedora-kickstarts'; + assert_script_run "git checkout ${branch}"; + # now copy the advisory and workaround repo config files in + assert_script_run 'cp /etc/yum.repos.d/advisory.repo .'; + assert_script_run 'cp /etc/yum.repos.d/workarounds.repo .'; + # and add them to the config file + assert_script_run 'sed -i -e "s,repos:,repos:\n - advisory\n - workarounds,g" fedora-' . $lcsubv . '.yaml'; + # upload the config so we can check it + upload_logs "fedora-$lcsubv.yaml"; + # now install the tools into the mock + assert_script_run "mock -r openqa --install ostree rpm-ostree", 600; + # now make the ostree repo directory inside the mock root + assert_script_run 'mock -r openqa --isolation=simple --chroot "mkdir -p /ostree/repo"'; + # copy in the modified config repo + assert_script_run "mock -r openqa --isolation=simple --copyin workstation-ostree-config /"; + # PULL SOME LEVERS! PULL SOME LEVERS! + assert_script_run "mock -r openqa --enable-network --chroot 'rpm-ostree compose tree --repo=/ostree/repo/ --write-commitid-to=/ostree/commitid.log --add-metadata-string=version=${advortask} --force-nocache /workstation-ostree-config/fedora-$lcsubv.json > /tmp/ostree.log'", 4500; + unless (script_run "mock -r openqa --isolation=simple --copyout /tmp/ostree.log .") { + upload_logs "ostree.log"; + } + # check out the ostree installer lorax templates + assert_script_run 'cd /'; + assert_script_run 'git clone https://pagure.io/fedora-lorax-templates.git'; + # also check out pungi-fedora and use our script to build part of + # the lorax command + assert_script_run 'git clone https://pagure.io/pungi-fedora.git'; + assert_script_run 'cd pungi-fedora/'; + assert_script_run 'wget https://pagure.io/fedora-qa/os-autoinst-distri-fedora/blob/main/f/ostree-parse-pungi.py', timeout => 120; + my $loraxargs = script_output "python3 ostree-parse-pungi.py $lcsubv $arch"; + + # this 'temporary file cleanup' thing can actually wipe bits of + # the lorax install root while lorax is still running... + assert_script_run "systemctl stop systemd-tmpfiles-clean.timer"; + # create the installer ISO + assert_script_run "mkdir -p /root/imgbuild"; + assert_script_run "cd /root/imgbuild"; + assert_script_run "setenforce Permissive"; + + my $cmd = "lorax -p Fedora -v ${version} -r ${version} --repo=/etc/yum.repos.d/${repo} --variant=${subv} --nomacboot --buildarch=${arch} --volid=Fedora-${subv}-ostree-x86_64-oqa --logfile=./lorax.log ${loraxargs}"; + unless ($version > $currrel) { + $cmd .= " --isfinal --repo=/etc/yum.repos.d/fedora-updates.repo"; + } + $cmd .= " --repo=/etc/yum.repos.d/advisory.repo --repo=/etc/yum.repos.d/workarounds.repo ./results"; + assert_script_run $cmd, 2400; + # good to have the log around for checks + upload_logs "lorax.log", failok => 1; + assert_script_run "mv results/images/boot.iso ./${advortask}-${subv}-ostree-${arch}.iso"; + upload_asset "./${advortask}-${subv}-ostree-${arch}.iso"; +} + +sub test_flags { + return {fatal => 1}; +} + +1; +