From 8c40583ee6539e7be6270741275796703259874e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20R=C5=AF=C5=BEi=C4=8Dka?= Date: Thu, 28 May 2020 14:43:52 +0200 Subject: [PATCH] Automate the IoT rpm-ostree package layering test case. --- templates.fif.json | 13 ++++++ tests/iot_rpmostree_overlay.pm | 81 ++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 tests/iot_rpmostree_overlay.pm diff --git a/templates.fif.json b/templates.fif.json index 2d01ea6f..76a0d14f 100644 --- a/templates.fif.json +++ b/templates.fif.json @@ -1505,6 +1505,19 @@ "START_AFTER_TEST": "install_default_upload" } }, + "iot_rpmostree_overlay": { + "profiles": { + "fedora-IoT-dvd_ostree-iso-aarch64-*-aarch64": 20, + "fedora-IoT-dvd_ostree-iso-x86_64-*-64bit": 20 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL": "iot_rpmostree_overlay", + "ROOT_PASSWORD": "weakpassword", + "START_AFTER_TEST": "install_default_upload" + } + }, "mediakit_fileconflicts": { "profiles": { "fedora-Server-dvd-iso-aarch64-*-aarch64": 10, diff --git a/tests/iot_rpmostree_overlay.pm b/tests/iot_rpmostree_overlay.pm new file mode 100644 index 00000000..7ea45205 --- /dev/null +++ b/tests/iot_rpmostree_overlay.pm @@ -0,0 +1,81 @@ +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"; + + # 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: