From 69f77e451fabaade9c030e5585c686c595d6db42 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Mon, 8 Jul 2024 12:25:22 +0200 Subject: [PATCH 1/4] tests: replace usage of contains: with selectors that are available in interactive debugging --- test/helpers/installer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/helpers/installer.py b/test/helpers/installer.py index e573609d14..bf5d3de374 100644 --- a/test/helpers/installer.py +++ b/test/helpers/installer.py @@ -64,7 +64,8 @@ def __init__(self, browser, machine, hidden_steps=None, scenario=None): def begin_installation(self, should_fail=False, confirm_erase=True, button_text='Erase data and install'): current_page = self.get_current_page() - self.browser.click(f"button:contains('{button_text}')") + self.browser.wait_text("#installation-next-btn", button_text) + self.browser.click("#installation-next-btn") if confirm_erase: self.browser.click(f"#{self.steps.REVIEW}-disk-erase-confirm") From 81dea59727f513ceb6c06f854ee3dc2c47275aa0 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Mon, 8 Jul 2024 12:27:06 +0200 Subject: [PATCH 2/4] tests: specify disk size also if we are using backing_file When using backing_file at the disk creation specifying the size is not obligatory, but if we specify it the disk image is using the specified size. This is quite useful for many tests scenarios, like the ones that install in the free space on the disk another OS, as we need to control the free space there. --- test/anacondalib.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/anacondalib.py b/test/anacondalib.py index 73726bbc4e..4ed8526e5b 100644 --- a/test/anacondalib.py +++ b/test/anacondalib.py @@ -40,6 +40,7 @@ class VirtInstallMachineCase(MachineCase): efi = False disk_image = "" + disk_size = 15 MachineCase.machine_class = VirtInstallMachine @classmethod @@ -58,8 +59,7 @@ def setUp(self): # Add installation target disk backing_file = None if not self.disk_image else os.path.join(BOTS_DIR, f"./images/{self.disk_image}") - size = None if backing_file else 15 - self.add_disk(size, backing_file) + self.add_disk(self.disk_size, backing_file) # Select the disk as boot device subprocess.check_call([ "virt-xml", "-c", "qemu:///session", @@ -107,7 +107,7 @@ def _create_disk_image(self, size, image_path=None, backing_file=None): "qemu-img", "create", "-f", "qcow2", *(["-o", f"backing_file={backing_file},backing_fmt=qcow2"] if backing_file else []), image_path, - *([f"{size}G"] if size else []) + f"{size}G" ]) return image_path From 79b4545b39b32086d704c7e3d1835df4f70541ad Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Fri, 5 Jul 2024 14:15:33 +0200 Subject: [PATCH 3/4] tests: add test for dual booting with another Linux OS Since now we depend on more images for the test runs, adjust the Makefile to download the utilized images. --- Makefile | 6 +++++- test/anacondalib.py | 15 +++++++++++++++ test/check-existing-system | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4a10f2302f..d172f3a015 100644 --- a/Makefile +++ b/Makefile @@ -181,12 +181,16 @@ bots: test/common live-vm: bots $(UPDATES_IMG) ./test/webui_testvm.py $(TEST_LIVE_OS) -prepare-test-deps: bots test/common payload +prepare-test-deps: bots test/common payload images .PHONY: payload payload: bots bots/image-download $(PAYLOAD) +.PHONY: images +images: bots + bots/image-download $(TEST_OS) debian-stable + $(UPDATES_IMG): bots test/prepare-updates-img diff --git a/test/anacondalib.py b/test/anacondalib.py index 4ed8526e5b..9dfca859c2 100644 --- a/test/anacondalib.py +++ b/test/anacondalib.py @@ -165,8 +165,23 @@ def handleReboot(self): self.installation_finished = True p = Progress(self.browser) p.reboot() + + # The installed machine does not need to skip the nologin check + os.environ["TEST_ALLOW_NOLOGIN"] = "false" + self.addCleanup(lambda: os.environ["TEST_ALLOW_NOLOGIN"] == "true") self.machine.wait_reboot() + def selectBootMenuEntry(self, entry): + grub_cfg = """ + GRUB_DEFAULT=saved + GRUB_TIMEOUT=0 + GRUB_HIDDEN_TIMEOUT=0 + GRUB_HIDDEN_TIMEOUT_QUIET=true + """ + + self.write_file("/etc/default/grub", grub_cfg) + self.machine.execute(f"grub2-set-default {entry}") + def tearDown(self): if not self.installation_finished: self.downloadLogs() diff --git a/test/check-existing-system b/test/check-existing-system index fb0366290c..e2810629d1 100755 --- a/test/check-existing-system +++ b/test/check-existing-system @@ -17,8 +17,11 @@ import anacondalib from installer import Installer +from progress import Progress from review import Review +from storage import Storage from testlib import nondestructive, test_main # pylint: disable=import-error +from utils import get_pretty_name @nondestructive @@ -40,6 +43,37 @@ class TestExistingSystemFedora(anacondalib.VirtInstallMachineCase): r.check_deleted_system("Fedora Linux") +class TestExistingSystemDebian(anacondalib.VirtInstallMachineCase): + disk_image = "debian-stable" + disk_size = 20 + + def testScenarioUseFreeSpace(self): + b = self.browser + m = self.machine + i = Installer(b, m) + s = Storage(b, m) + p = Progress(b) + + i.open() + i.reach(i.steps.INSTALLATION_METHOD) + s.set_partitioning("use-free-space") + i.next() + s.check_encryption_selected(False) + i.reach(i.steps.REVIEW) + i.begin_installation(button_text="Install") + with b.wait_timeout(300): + p.wait_done() + + # Expect the new OS is the default grub entry + self.handleReboot() + pretty_name = get_pretty_name(m) + self.assertIn("Fedora Linux", pretty_name) + # Select second OS grub entry + self.selectBootMenuEntry(2) + m.reboot() + pretty_name = get_pretty_name(m) + self.assertIn("Debian GNU/Linux", pretty_name) + if __name__ == '__main__': test_main() From 62e184b17ae35db3111f2297976c9c2e64b39b97 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Mon, 8 Jul 2024 13:03:37 +0200 Subject: [PATCH 4/4] tests: unselecting disk encryption is done by default Remove unneeded code. See _steps_callbacks[DISK_ENCRYPTION]. --- test/check-storage-reclaim | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/check-storage-reclaim b/test/check-storage-reclaim index cd7719f48c..b1c820175d 100755 --- a/test/check-storage-reclaim +++ b/test/check-storage-reclaim @@ -72,8 +72,6 @@ class TestStorageUseFreeSpaceScenario(anacondalib.VirtInstallMachineCase, Storag s.reclaim_check_checkbox(True, False) s.reclaim_set_checkbox(False) - i.next() - s.check_encryption_selected(False) i.reach(i.steps.REVIEW) r.check_disk_row(dev, "/", "vda5, LVM", "8.59 GB", True, "xfs") @@ -147,7 +145,6 @@ class TestStorageUseFreeSpaceScenario(anacondalib.VirtInstallMachineCase, Storag s.reclaim_check_available_space("9.66 GB") s.reclaim_modal_submit() - s.check_encryption_selected(False) i.reach(i.steps.REVIEW) r.check_disk_row(dev, parent="vda4", action="delete") @@ -172,7 +169,6 @@ class TestStorageUseFreeSpaceScenarioExistingSystemFedora(anacondalib.VirtInstal s.reclaim_remove_device("vda4") s.reclaim_modal_submit() - s.check_encryption_selected(False) i.reach(i.steps.REVIEW) r.check_affected_system("Fedora Linux", [("vda4", ["home", "root", "var"])])