Skip to content

Commit

Permalink
Merge pull request #344 from KKoukiou/dual-boot
Browse files Browse the repository at this point in the history
test: dual boot with debian
  • Loading branch information
KKoukiou authored Jul 8, 2024
2 parents 4b5303d + 62e184b commit 551478c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 9 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 18 additions & 3 deletions test/anacondalib.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
class VirtInstallMachineCase(MachineCase):
efi = False
disk_image = ""
disk_size = 15
MachineCase.machine_class = VirtInstallMachine

@classmethod
Expand All @@ -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",
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
34 changes: 34 additions & 0 deletions test/check-existing-system
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
4 changes: 0 additions & 4 deletions test/check-storage-reclaim
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -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"])])

Expand Down
3 changes: 2 additions & 1 deletion test/helpers/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 551478c

Please sign in to comment.