From 6daf9c36a0e40c179b25584ca45f0f0426131293 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 6 Dec 2022 14:41:56 -0800 Subject: [PATCH] Make rpm-ostree tests generic, run on Silverblue and CoreOS This makes the two rpm-ostree tests written for IoT - overlaying and rebasing - work across all rpm-ostree-based flavors we currently test (IoT, CoreOS and Silverblue) and runs them on all those flavors. This requires some other changes. For the Workstation ostree installer update tests, we have install_default_update_ostree upload a disk image and run these tests on that image. That means install_default_update_ostree cannot use a scratch disk (as if we boot it with two disks but only upload one, the subsequent tests fail to boot, looking for the missing second disk), but its specified disk size should be large enough for all updates. Signed-off-by: Adam Williamson --- templates-updates.fif.json | 15 +++++- templates.fif.json | 60 ++++++++++++----------- tests/iot_rpmostree_overlay.pm | 81 ------------------------------- tests/iot_rpmostree_rebase.pm | 61 ------------------------ tests/rpmostree_overlay.pm | 87 ++++++++++++++++++++++++++++++++++ tests/rpmostree_rebase.pm | 69 +++++++++++++++++++++++++++ 6 files changed, 202 insertions(+), 171 deletions(-) delete mode 100644 tests/iot_rpmostree_overlay.pm delete mode 100644 tests/iot_rpmostree_rebase.pm create mode 100644 tests/rpmostree_overlay.pm create mode 100644 tests/rpmostree_rebase.pm diff --git a/templates-updates.fif.json b/templates-updates.fif.json index 213d33c2..e823c1fd 100644 --- a/templates-updates.fif.json +++ b/templates-updates.fif.json @@ -123,8 +123,8 @@ "settings": { "CANNED": "1", "DESKTOP": "gnome", + "DEPLOY_UPLOAD_TEST": "install_default_update_ostree", "HDDSIZEGB": "15", - "NUMDISKS": "2", "PACKAGE_SET": "default", "RETRY": "1", "SUBVARIANT": "Silverblue" @@ -400,7 +400,8 @@ "INSTALL": "1", "ISO": "%ADVISORY_OR_TASK%-%SUBVARIANT%-ostree-%ARCH%.iso", "PACKAGE_SET": "default", - "+START_AFTER_TEST": "ostree_build@%ARCH_BASE_MACHINE%" + "+START_AFTER_TEST": "ostree_build@%ARCH_BASE_MACHINE%", + "STORE_HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2" } }, "installer_build": { @@ -480,6 +481,16 @@ "fedora-updates-server-x86_64-*-64bit": 5 } }, + "rpmostree_overlay": { + "profiles": { + "fedora-updates-silverblue-dvd_ostree-iso-x86_64-*-64bit": 5 + } + }, + "rpmostree_rebase": { + "profiles": { + "fedora-updates-silverblue-dvd_ostree-iso-x86_64-*-64bit": 5 + } + }, "server_cockpit_basic": { "profiles": { "fedora-updates-server-aarch64-*-aarch64": 5, diff --git a/templates.fif.json b/templates.fif.json index 5455b5cf..189e44dd 100644 --- a/templates.fif.json +++ b/templates.fif.json @@ -2120,33 +2120,6 @@ "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" } }, - "iot_rpmostree_overlay": { - "profiles": { - "fedora-IoT-dvd_ostree-iso-aarch64-*-aarch64": 20, - "fedora-IoT-dvd_ostree-iso-x86_64-*-uefi": 20 - }, - "settings": { - "BOOTFROM": "c", - "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", - "POSTINSTALL": "iot_rpmostree_overlay", - "ROOT_PASSWORD": "weakpassword", - "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" - } - }, - "iot_rpmostree_rebase": { - "profiles": { - "fedora-IoT-dvd_ostree-iso-aarch64-*-aarch64": 20, - "fedora-IoT-dvd_ostree-iso-x86_64-*-uefi": 40 - }, - "settings": { - "BOOTFROM": "c", - "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", - "POSTINSTALL": "iot_rpmostree_rebase", - "ROOT_PASSWORD": "weakpassword", - "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%", - "USER_LOGIN": "false" - } - }, "iot_zezere_ignition": { "profiles": { "fedora-IoT-dvd_ostree-iso-aarch64-*-aarch64": 20, @@ -2346,6 +2319,39 @@ "USER_LOGIN": "false" } }, + "rpmostree_overlay": { + "profiles": { + "fedora-CoreOS-colive-iso-x86_64-*-64bit": 20, + "fedora-IoT-dvd_ostree-iso-aarch64-*-aarch64": 20, + "fedora-IoT-dvd_ostree-iso-x86_64-*-uefi": 20, + "fedora-Silverblue-dvd_ostree-iso-ppc64le-*-ppc64le": 50, + "fedora-Silverblue-dvd_ostree-iso-x86_64-*-64bit": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL": "rpmostree_overlay", + "ROOT_PASSWORD": "weakpassword", + "+START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "rpmostree_rebase": { + "profiles": { + "fedora-CoreOS-colive-iso-x86_64-*-64bit": 20, + "fedora-IoT-dvd_ostree-iso-aarch64-*-aarch64": 20, + "fedora-IoT-dvd_ostree-iso-x86_64-*-uefi": 20, + "fedora-Silverblue-dvd_ostree-iso-ppc64le-*-ppc64le": 50, + "fedora-Silverblue-dvd_ostree-iso-x86_64-*-64bit": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL": "rpmostree_rebase", + "ROOT_PASSWORD": "weakpassword", + "+START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%", + "USER_LOGIN": "false" + } + }, "server_cockpit_basic": { "profiles": { "fedora-Server-dvd-iso-aarch64-*-aarch64": 30, diff --git a/tests/iot_rpmostree_overlay.pm b/tests/iot_rpmostree_overlay.pm deleted file mode 100644 index fb5c4977..00000000 --- a/tests/iot_rpmostree_overlay.pm +++ /dev/null @@ -1,81 +0,0 @@ -use base "installedtest"; -use strict; -use testapi; -use utils; - -sub reboot_and_login { - # This subroutine reboots the host, waits out the boot process and logs in. - my $reboot_time = shift; - script_run "systemctl reboot"; - boot_to_login_screen(timeout => $reboot_time); - console_login(user => "root", password => get_var("ROOT_PASSWORD")); - sleep 2; -} - -sub run { - my $self = shift; - my $reboot_time = 300; - # switch to TTY3 for both, graphical and console tests - $self->root_console(tty => 3); - - # Install wget as rpm-ostree overlay. Let's have timeout defined - # quite generously, because it loads the package DBs. - assert_script_run "rpm-ostree install wget", timeout => 300; - # Reboot the machine to boot into the overlayed tree. - reboot_and_login "300"; - - # Check that wget rpm is installed - assert_script_run "rpm -q wget"; - # And that it works - assert_script_run "wget --version"; - - # Then install the httpd package. - assert_script_run "rpm-ostree install httpd", timeout => 300; - - # Reboot the machine to boot into the overlayed tree. - reboot_and_login "300"; - - # Check for new as well as old overlays - assert_script_run "rpm -q wget"; - assert_script_run "rpm -q httpd"; - assert_script_run "rpm -q apr"; - - # Start the httpd.service and check for its status - assert_script_run "systemctl start httpd"; - assert_script_run "systemctl is-active httpd"; - - # Check for the functional test page - assert_script_run "curl -o page.html http://localhost"; - assert_script_run "grep 'Fedora Project' page.html"; - - # Enable the httpd service - assert_script_run "systemctl enable httpd"; - - # Reboot the computer to boot check if the service has been enabled and starts - # automatically. - reboot_and_login "300"; - - # See if httpd is started - assert_script_run "systemctl is-active httpd"; - - # Uninstall wget and httpd again. - assert_script_run "rpm-ostree uninstall wget httpd", timeout => 300; - - # Reboot to see the changed tree - reboot_and_login "300"; - - # Check if wget and httpd were removed and no longer can be used. - assert_script_run "! rpm -q wget"; - assert_script_run "! rpm -q httpd"; - assert_script_run "! wget --version"; - assert_script_run "! systemctl is-active httpd"; - -} - -sub test_flags { - return {fatal => 1}; -} - -1; - -# vim: set sw=4 et: diff --git a/tests/iot_rpmostree_rebase.pm b/tests/iot_rpmostree_rebase.pm deleted file mode 100644 index c34b312a..00000000 --- a/tests/iot_rpmostree_rebase.pm +++ /dev/null @@ -1,61 +0,0 @@ -use base "installedtest"; -use strict; -use testapi; -use utils; - -sub run { - - my $self = shift; - $self->root_console(tty => 3); - - # list available branches - assert_script_run "ostree remote refs fedora-iot"; - - # check arch - my $arch = lc(get_var("ARCH")); - - # set default for rawhide or devel - my $rebase = "stable"; - - # if testing the current release, rebase to devel - unless (script_run "rpm-ostree status -b | grep stable") { - $rebase = "devel"; - } - # rebase to the appropriate release, arch - validate_script_output "rpm-ostree rebase fedora/${rebase}/${arch}/iot", sub { m/systemctl reboot/ }, 300; - script_run "systemctl reboot", 0; - - boot_to_login_screen; - $self->root_console(tty => 3); - - # check booted branch to make sure successful rebase - if ($rebase eq "devel") { - validate_script_output "rpm-ostree status -b", sub { m/devel/ }, 300; - } - if ($rebase eq "stable") { - validate_script_output "rpm-ostree status -b", sub { m/stable/ }, 300; - } - - # rollback and reboot - validate_script_output "rpm-ostree rollback", sub { m/systemctl reboot/ }, 300; - script_run "systemctl reboot", 0; - - boot_to_login_screen; - $self->root_console(tty => 3); - - # check to make sure rollback successful, also account for branched (devel) - if ($rebase eq "devel") { - validate_script_output "rpm-ostree status -b", sub { m/stable/ }, 300; - } - if ($rebase eq "stable") { - validate_script_output "rpm-ostree status -b", sub { m/rawhide|devel/ }, 300; - } -} - -sub test_flags { - return {fatal => 1}; -} - -1; - -# vim: set sw=4 et: diff --git a/tests/rpmostree_overlay.pm b/tests/rpmostree_overlay.pm new file mode 100644 index 00000000..df51a598 --- /dev/null +++ b/tests/rpmostree_overlay.pm @@ -0,0 +1,87 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +sub reboot_and_login { + # This subroutine reboots the host, waits out the boot process and logs in. + my $reboot_time = shift; + enter_cmd "systemctl reboot"; + boot_to_login_screen(timeout => $reboot_time); + console_login(user => "root", password => get_var("ROOT_PASSWORD")); + sleep 2; +} + +sub run { + my $self = shift; + my $reboot_time = 300; + # switch to TTY3 for both, graphical and console tests + $self->root_console(tty => 3); + # disable graphical boot on graphical images + assert_script_run "systemctl set-default multi-user.target"; + + # Install htop as rpm-ostree overlay. Let's have timeout defined + # quite generously, because it loads the package DBs. + assert_script_run "rpm-ostree install htop", timeout => 300; + # Reboot the machine to boot into the overlayed tree. + reboot_and_login "300"; + + # Check that htop rpm is installed + assert_script_run "rpm -q htop"; + # And that it works + assert_script_run "htop --version"; + + # Then install the psotgresql-server package. + assert_script_run "rpm-ostree install postgresql-server", timeout => 300; + + # Reboot the machine to boot into the overlayed tree. + reboot_and_login "300"; + + # Check for new as well as old overlays + assert_script_run "rpm -q htop"; + assert_script_run "rpm -q postgresql-server"; + # this is a dependency of postgresql-server; check it's there + assert_script_run "rpm -q postgresql"; + + # init the db (required to be able to run the service) + assert_script_run "/usr/bin/postgresql-setup --initdb"; + + # Start the postgresql.service and check for its status + assert_script_run "systemctl start postgresql"; + assert_script_run "systemctl is-active postgresql"; + + # Check it's working + assert_script_run 'su postgres -c "psql -l"'; + + # Enable the postgresql service + assert_script_run "systemctl enable postgresql"; + + # Reboot the computer to boot check if the service has been enabled and starts + # automatically. + reboot_and_login "300"; + + # See if postgresql is started + assert_script_run "systemctl is-active postgresql"; + + # Uninstall htop and postgresql again. + assert_script_run "rpm-ostree uninstall htop postgresql-server", timeout => 300; + + # Reboot to see the changed tree + reboot_and_login "300"; + + # Check if htop and postgresql-server were removed and no longer can be used. + assert_script_run "! rpm -q htop"; + assert_script_run "! rpm -q postgresql-server"; + assert_script_run "! rpm -q postgresql"; + assert_script_run "! htop --version"; + assert_script_run "! systemctl is-active postgresql"; + +} + +sub test_flags { + return {fatal => 1}; +} + +1; + +# vim: set sw=4 et: diff --git a/tests/rpmostree_rebase.pm b/tests/rpmostree_rebase.pm new file mode 100644 index 00000000..7138ebab --- /dev/null +++ b/tests/rpmostree_rebase.pm @@ -0,0 +1,69 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +sub run { + + my $self = shift; + $self->root_console(tty => 3); + + # list available branches + my $subv = lc(get_var("SUBVARIANT")); + my $remote = "fedora"; + $remote = "fedora-iot" if ($subv eq "iot"); + assert_script_run "ostree remote refs $remote"; + + # get current branch + my $current = script_output "rpm-ostree status -b | grep fedora"; + + my $arch = lc(get_var("ARCH")); + + # decide target + my $rebase; + my $target; + if ($current =~ "iot") { + $rebase = $current =~ "stable" ? "devel" : "stable"; + $target = "fedora/${rebase}/${arch}/iot"; + } + elsif ($current =~ "silverblue") { + my $relnum = get_release_number; + $rebase = $relnum - 1; + # avoid rebasing from 37 to <37, bad stuff happens + # FIXME when 38 branches, we should change this to RELNUM+1 + $rebase = "rawhide" if ($relnum eq "37"); + $target = "fedora/${rebase}/${arch}/silverblue"; + } + elsif ($current =~ "coreos") { + $rebase = $current =~ "stable" ? "testing" : "stable"; + $target = "fedora/${arch}/coreos/${rebase}"; + } + + # rebase to the chosen target + validate_script_output "rpm-ostree rebase $target", sub { m/systemctl reboot/ }, 300; + script_run "systemctl reboot", 0; + + boot_to_login_screen; + $self->root_console(tty => 3); + + # check booted branch to make sure successful rebase + validate_script_output "rpm-ostree status -b", sub { m/$target/ }, 300; + + # rollback and reboot + validate_script_output "rpm-ostree rollback", sub { m/systemctl reboot/ }, 300; + script_run "systemctl reboot", 0; + + boot_to_login_screen; + $self->root_console(tty => 3); + + # check to make sure rollback successful + validate_script_output "rpm-ostree status -b", sub { m/$current/ }, 300; +} + +sub test_flags { + return {fatal => 1}; +} + +1; + +# vim: set sw=4 et: