From 99302c6fd4a3654a23c7e2eeaa6ec792bc1ea6b7 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 29 Jan 2019 15:56:01 +0100 Subject: [PATCH] Add a live image build test for updates Just like the installer image build test, only...it builds a live image. This involves reimplementing quite a chunk of the Koji livemedia task. Ah, well. Also involves rethinking the flavor names a bit here, these seem...better. Signed-off-by: Adam Williamson --- lib/installedtest.pm | 24 ++++++++++-- templates-updates | 88 +++++++++++++++++++++++++++++++++++++++----- tests/_live_build.pm | 61 ++++++++++++++++++++++++++++++ 3 files changed, 159 insertions(+), 14 deletions(-) create mode 100644 tests/_live_build.pm diff --git a/lib/installedtest.pm b/lib/installedtest.pm index 94c460a0..1e098463 100644 --- a/lib/installedtest.pm +++ b/lib/installedtest.pm @@ -99,10 +99,26 @@ sub post_fail_hook { # Sometimes useful for diagnosing FreeIPA issues upload_logs "/etc/nsswitch.conf", failok=>1; - # for installer creation test - upload_logs "/root/imgbuild/pylorax.log", failok=>1; - upload_logs "/root/imgbuild/lorax.log", failok=>1; - upload_logs "/root/imgbuild/program.log", failok=>1; + if (get_var("FLAVOR") eq "updates-everything-boot-iso") { + # for installer creation test + script_run "df -h"; + upload_logs "/root/imgbuild/pylorax.log", failok=>1; + upload_logs "/root/imgbuild/lorax.log", failok=>1; + upload_logs "/root/imgbuild/program.log", failok=>1; + } + + if (get_var("FLAVOR") eq "updates-workstation-live-iso") { + # for live image creation test + script_run "df -h"; + script_run 'mock -r openqa --chroot "ls -l /chroot_tmpdir/lmc-logs/anaconda"'; + unless (script_run "mock -r openqa --copyout /chroot_tmpdir/lmc-logs/livemedia-out.log .") { + upload_logs "livemedia-out.log"; + } + unless (script_run "mock -r openqa --copyout /chroot_tmpdir/lmc-logs/anaconda/ anaconda") { + assert_script_run "tar cvzf anaconda.tar.gz anaconda/"; + upload_logs "anaconda.tar.gz"; + } + } } # For update tests, let's do the update package info log stuff, diff --git a/templates-updates b/templates-updates index 938b354f..23e2de9f 100755 --- a/templates-updates +++ b/templates-updates @@ -373,7 +373,7 @@ product => { arch => "x86_64", distri => "fedora", - flavor => "updates-installer", + flavor => "updates-everything-boot-iso", version => "*", }, test_suite => { name => "installer_build" }, @@ -385,7 +385,7 @@ product => { arch => "x86_64", distri => "fedora", - flavor => "updates-installer", + flavor => "updates-everything-boot-iso", version => "*", }, test_suite => { name => "support_server" }, @@ -397,10 +397,10 @@ product => { arch => "x86_64", distri => "fedora", - flavor => "updates-installer", + flavor => "updates-everything-boot-iso", version => "*", }, - test_suite => { name => "install_default_update" }, + test_suite => { name => "install_default_update_netinst" }, }, { group_name => "Fedora Updates", @@ -409,10 +409,46 @@ product => { arch => "x86_64", distri => "fedora", - flavor => "updates-installer", + flavor => "updates-everything-boot-iso", version => "*", }, - test_suite => { name => "install_default_update" }, + test_suite => { name => "install_default_update_netinst" }, + }, + { + group_name => "Fedora Updates", + machine => { name => "64bit" }, + prio => 40, + product => { + arch => "x86_64", + distri => "fedora", + flavor => "updates-workstation-live-iso", + version => "*", + }, + test_suite => { name => "live_build" }, + }, + { + group_name => "Fedora Updates", + machine => { name => "64bit" }, + prio => 40, + product => { + arch => "x86_64", + distri => "fedora", + flavor => "updates-workstation-live-iso", + version => "*", + }, + test_suite => { name => "install_default_update_live" }, + }, + { + group_name => "Fedora Updates", + machine => { name => "uefi" }, + prio => 41, + product => { + arch => "x86_64", + distri => "fedora", + flavor => "updates-workstation-live-iso", + version => "*", + }, + test_suite => { name => "install_default_update_live" }, }, { group_name => "Fedora PowerPC Updates", @@ -921,9 +957,9 @@ version => "*", }, { - arch => "ppc64le", + arch => "x86_64", distri => "fedora", - flavor => "updates-server", + flavor => "updates-everything-boot-iso", name => "", settings => [ ], @@ -932,7 +968,19 @@ { arch => "x86_64", distri => "fedora", - flavor => "updates-installer", + flavor => "updates-workstation-live-iso", + name => "", + settings => [ + { key => "LIVE", value => "1" }, + { key => "PACKAGE_SET", value => "default" }, + { key => "DESKTOP", value => "gnome" } + ], + version => "*", + }, + { + arch => "ppc64le", + distri => "fedora", + flavor => "updates-server", name => "", settings => [ ], @@ -1005,7 +1053,19 @@ ], }, { - name => "install_default_update", + name => "live_build", + settings => [ + { key => "POSTINSTALL", value => "_live_build" }, + { key => "USER_LOGIN", value => "false" }, + { key => "ROOT_PASSWORD", value => "weakpassword" }, + { key => "BOOTFROM", value => "c" }, + { key => "+DESKTOP", value => "" }, + { key => "+LIVE", value => "" }, + { key => "HDD_1", value => "disk_f%VERSION%_minimal_3_%ARCH%.img" }, + ], + }, + { + name => "install_default_update_netinst", settings => [ { key => "INSTALL", value => "1" }, { key => "INSTALL_UNLOCK", value => "support_ready" }, @@ -1018,5 +1078,13 @@ { key => "WORKER_CLASS", value => "tap" }, ], }, + { + name => "install_default_update_live", + settings => [ + { key => "INSTALL", value => "1" }, + { key => "ISO", value => "Fedora-%SUBVARIANT%-Live-%ARCH%-%ADVISORY_OR_TASK%.iso" }, + { key => "+START_AFTER_TEST", value => "live_build:%ARCH_BASE_MACHINE%" }, + ], + }, ], } diff --git a/tests/_live_build.pm b/tests/_live_build.pm new file mode 100644 index 00000000..4e6d8fa5 --- /dev/null +++ b/tests/_live_build.pm @@ -0,0 +1,61 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +sub run { + my $self = shift; + my $version = get_var("VERSION"); + my $advortask = get_var("ADVISORY_OR_TASK"); + my $arch = get_var("ARCH"); + my $subv = get_var("SUBVARIANT"); + my $lcsubv = lc($subv); + # we need to be in permissive mode or the built image has selinux issues + assert_script_run "setenforce Permissive"; + # install the tools we need + assert_script_run "dnf -y install mock git pykickstart tar", 120; + # make the update/task repo and the serial device available inside the mock root + assert_script_run 'echo "config_opts[\'plugin_conf\'][\'bind_mount_enable\'] = True" > /etc/mock/openqa.cfg'; + assert_script_run 'echo "config_opts[\'plugin_conf\'][\'bind_mount_opts\'][\'dirs\'].append((\'/opt/update_repo\', \'/opt/update_repo\'))" >> /etc/mock/openqa.cfg'; + assert_script_run 'echo "config_opts[\'plugin_conf\'][\'bind_mount_opts\'][\'dirs\'].append((\'/dev/' . $serialdev . '\', \'/dev/' . $serialdev . '\'))" >> /etc/mock/openqa.cfg'; + # now append the whole 'stock' config except for the final """ line + assert_script_run "head -n-1 /etc/mock/fedora-${version}-${arch}.cfg >> /etc/mock/openqa.cfg"; + # now add the side repo to the config + assert_script_run 'printf "[advisory]\nname=Advisory repo\nbaseurl=file:///opt/update_repo\nenabled=1\nmetadata_expire=3600\ngpgcheck=0\n\"\"\"" >> /etc/mock/openqa.cfg'; + # upload the config so we can check it's OK + upload_logs "/etc/mock/openqa.cfg"; + # now check out the kickstarts + assert_script_run 'git clone https://pagure.io/fedora-kickstarts.git'; + assert_script_run 'cd fedora-kickstarts'; + assert_script_run "git checkout f${version}"; + # now add the side repo to fedora-repo-not-rawhide.ks + assert_script_run 'echo "repo --name=advisory --baseurl=file:///opt/update_repo" >> fedora-repo-not-rawhide.ks'; + # now flatten the kickstart + assert_script_run "ksflatten -c fedora-live-${lcsubv}.ks -o openqa.ks"; + # upload the kickstart so we can check it + upload_logs "openqa.ks"; + # now install the tools into the mock + assert_script_run "mock -r openqa --install bash coreutils glibc-all-langpacks lorax-lmc-novirt selinux-policy-targeted shadow-utils util-linux", 300; + # now make the image build directory inside the mock root and put the kickstart there + assert_script_run 'mock -r openqa --chroot "mkdir -p /chroot_tmpdir"'; + assert_script_run "mock -r openqa --copyin openqa.ks /chroot_tmpdir"; + # PULL SOME LEVERS! PULL SOME LEVERS! + assert_script_run "mock -r openqa --enable-network --old-chroot --chroot \"/sbin/livemedia-creator --ks /chroot_tmpdir/openqa.ks --logfile /chroot_tmpdir/lmc-logs/livemedia-out.log --no-virt --resultdir /chroot_tmpdir/lmc --project Fedora-${subv}-Live --make-iso --volid FWL-${advortask} --iso-only --iso-name Fedora-${subv}-Live-${arch}-${advortask}.iso --releasever ${version} --title Fedora-${subv}-Live --macboot\"", 2400; + unless (script_run "mock -r openqa --copyout /chroot_tmpdir/lmc-logs/livemedia-out.log .") { + upload_logs "livemedia-out.log"; + } + unless (script_run "mock -r openqa --copyout /chroot_tmpdir/lmc-logs/anaconda/ anaconda") { + assert_script_run "tar cvzf anaconda.tar.gz anaconda/"; + upload_logs "anaconda.tar.gz"; + } + assert_script_run "mock -r openqa --copyout /chroot_tmpdir/lmc/Fedora-${subv}-Live-${arch}-${advortask}.iso ."; + upload_asset "./Fedora-${subv}-Live-${arch}-${advortask}.iso"; +} + +sub test_flags { + return { fatal => 1 }; +} + +1; + +# vim: set sw=4 et: