Skip to content

Commit

Permalink
WIP - tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer committed Nov 29, 2023
1 parent d574f20 commit a177612
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 66 deletions.
30 changes: 15 additions & 15 deletions test/verify/check-storage-lvm2
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class TestStorageLvm2(storagelib.StorageCase):
# just in case the test fails
self.addCleanup(m.execute, "vgremove --force TEST1 2>/dev/null || true")
b.click(self.card_row("Storage", name="TEST1"))
b.wait_visible(self.card_row("LVM2 physical volumes", name=dev_1))
b.wait_visible(self.card_row("LVM2 physical volumes", name=dev_2))
b.wait_visible(self.card_row("LVM2 volume group", name=dev_1))
b.wait_visible(self.card_row("LVM2 volume group", name=dev_2))

# Create two logical volumes
m.execute("lvcreate TEST1 -n one -L 20m")
Expand All @@ -79,12 +79,12 @@ class TestStorageLvm2(storagelib.StorageCase):
# remove a disk from the volume group
m.execute(f"pvmove {dev_2} &>/dev/null || true")
m.execute(f"vgreduce TEST1 {dev_2}")
b.wait_not_present(self.card_row("LVM2 physical volumes", name=dev_2))
b.wait_not_present(self.card_row("LVM2 volume group", name=dev_2))

# The remaining lone disk is not removable
b.click(self.dropdown_toggle(self.card_row("LVM2 physical volumes", name=dev_1)))
b.wait_visible(self.dropdown_action(self.card_row("LVM2 physical volumes", name=dev_1), "Remove") + "[disabled]")
b.wait_text(self.dropdown_description(self.card_row("LVM2 physical volumes", name=dev_1), "Remove"),
b.click(self.dropdown_toggle(self.card_row("LVM2 volume group", name=dev_1)))
b.wait_visible(self.dropdown_action(self.card_row("LVM2 volume group", name=dev_1), "Remove") + "[disabled]")
b.wait_text(self.dropdown_description(self.card_row("LVM2 volume group", name=dev_1), "Remove"),
"Last cannot be removed")

# Wipe the disk and make sure lvmetad forgets about it. This
Expand Down Expand Up @@ -191,8 +191,8 @@ class TestStorageLvm2(storagelib.StorageCase):
self.assertEqual(m.execute(f"grep {mount_point_one} /etc/fstab || true"), "")

# remove disk2
self.click_dropdown(self.card_row("LVM2 physical volumes", name=dev_2), "Remove")
b.wait_not_present(self.card_row("LVM2 physical volumes", name=dev_2))
self.click_dropdown(self.card_row("LVM2 volume group", name=dev_2), "Remove")
b.wait_not_present(self.card_row("LVM2 volume group", name=dev_2))
b.wait_in_text(self.card_desc("LVM2 volume group", "Capacity"), "50.3 MB")

# create thin pool and volume
Expand All @@ -212,12 +212,12 @@ class TestStorageLvm2(storagelib.StorageCase):
b.wait_text(self.card_row_col("LVM2 logical volumes", 2, 1), "thin")

# add a disk and resize the pool
b.click(self.card_button("LVM2 physical volumes", "Add physical volume"))
b.click(self.card_button("LVM2 volume group", "Add physical volume"))
self.dialog_wait_open()
self.dialog_set_val('disks', {dev_2: True})
self.dialog_apply()
self.dialog_wait_close()
b.wait_visible(self.card_row("LVM2 physical volumes", name=dev_2))
b.wait_visible(self.card_row("LVM2 volume group", name=dev_2))
# this is sometimes 96, sometimes 100 MB
cap = self.card_desc("LVM2 volume group", "Capacity")
b.wait_js_func("(sel => { const c = Number(ph_text(sel).split(' ')[0]); return c >= 96 && c <= 101 })", cap)
Expand Down Expand Up @@ -303,15 +303,15 @@ class TestStorageLvm2(storagelib.StorageCase):
b.click(self.card_row("Storage", name="vgroup0"))

# Check the we are really using a partition on disk1 now
b.wait_in_text(self.card_row_col("LVM2 physical volumes", 1, 2), "Partition - Linux scsi_debug")
b.wait_in_text(self.card_row_col("LVM2 volume group", 1, 2), "Partition - Linux scsi_debug")

# Add the unused space of disk2
self.dialog_with_retry(trigger=lambda: b.click(self.card_button("LVM2 physical volumes",
self.dialog_with_retry(trigger=lambda: b.click(self.card_button("LVM2 volume group",
"Add physical volume")),
expect=lambda: self.dialog_is_present(
'disks', "unpartitioned space on " + disk2),
values={"disks": {disk2: True}})
b.wait_in_text(self.card_row_col("LVM2 physical volumes", 1, 2), "Partition - Block device")
b.wait_in_text(self.card_row_col("LVM2 volume group", 1, 2), "Partition - Block device")

def testSnapshots(self):
m = self.machine
Expand Down Expand Up @@ -510,12 +510,12 @@ class TestStorageLvm2(storagelib.StorageCase):
self.dialog_wait_close()

b.click(self.card_parent_link())
b.click(self.card_button("LVM2 physical volumes", "Add physical volume"))
b.click(self.card_button("LVM2 volume group", "Add physical volume"))
self.dialog_wait_open()
self.dialog_set_val('disks', {disk4: True})
self.dialog_apply()
self.dialog_wait_close()
b.wait_visible(self.card_row("LVM2 physical volumes", name=disk4))
b.wait_visible(self.card_row("LVM2 volume group", name=disk4))
b.click(self.card_row("LVM2 logical volumes", 1))

b.click(self.card_button("LVM2 logical volume", "Repair"))
Expand Down
54 changes: 27 additions & 27 deletions test/verify/check-storage-mdraid
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ class TestStorageMdRaid(storagelib.StorageCase):

def wait_states(self, states):
for s in states.keys():
self.browser.wait_in_text(self.card_row("MDRAID disks", name=s), states[s])
self.browser.wait_in_text(self.card_row("MDRAID device", name=s), states[s])

def raid_add_disk(self, name):
self.dialog_open_with_retry(trigger=lambda: self.browser.click(self.card_button("MDRAID disks", "Add disk")),
self.dialog_open_with_retry(trigger=lambda: self.browser.click(self.card_button("MDRAID device", "Add disk")),
expect=lambda: self.dialog_is_present('disks', name))
self.dialog_set_val("disks", {name: True})
self.dialog_apply_with_retry()

def raid_remove_disk(self, name):
self.click_dropdown(self.card_row("MDRAID disks", name=name), "Remove")
self.click_dropdown(self.card_row("MDRAID device", name=name), "Remove")

def raid_action(self, action):
self.browser.click(self.card_button("MDRAID device", action))
Expand Down Expand Up @@ -203,7 +203,7 @@ class TestStorageMdRaid(storagelib.StorageCase):

# Remove DISK1. The spare takes over.
self.raid_remove_disk(disk1)
b.wait_not_present(self.card_row("MDRAID disks", name=disk1))
b.wait_not_present(self.card_row("MDRAID device", name=disk1))
self.wait_states({disk4: "In sync"})

# Stop the array, destroy a disk, and start the array
Expand All @@ -216,7 +216,7 @@ class TestStorageMdRaid(storagelib.StorageCase):
self.raid_default_action_finish("Stop")
b.wait_text(self.card_desc("MDRAID device", "State"), "Not running")
m.execute("wipefs -a /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_DISK2")
b.wait_not_present(self.card_row("MDRAID disks", name=disk2))
b.wait_not_present(self.card_row("MDRAID device", name=disk2))
self.raid_default_action("Start")
b.wait_text(self.card_desc("MDRAID device", "State"), "Running")
wait_degraded_state(is_degraded=True)
Expand All @@ -231,7 +231,7 @@ class TestStorageMdRaid(storagelib.StorageCase):
self.wait_states({disk2: "Spare"})

# Remove it by formatting DISK2
b.click(self.card_row("MDRAID disks", name=disk2))
b.click(self.card_row("MDRAID device", name=disk2))
self.click_card_dropdown("Hard Disk Drive", "Create partition table")
b.wait_in_text('#dialog', "remove from MDRAID, initialize")
self.dialog_set_val("type", "empty")
Expand All @@ -240,8 +240,8 @@ class TestStorageMdRaid(storagelib.StorageCase):

b.go("#/")
b.click(self.card_row("Storage", name="/dev/md/raid0"))
b.wait_visible(self.card("MDRAID disks"))
b.wait_not_present(self.card_row("MDRAID disks", name=disk2))
b.wait_visible(self.card("MDRAID device"))
b.wait_not_present(self.card_row("MDRAID device", name=disk2))

# Delete the array. We are back on the storage page.
self.click_card_dropdown("MDRAID device", "Delete")
Expand Down Expand Up @@ -281,23 +281,23 @@ class TestStorageMdRaid(storagelib.StorageCase):
self.raid_default_action("Stop")
b.wait_text(self.card_desc("MDRAID device", "State"), "Not running")

b.wait_visible(self.card_button("MDRAID disks", "Add disk") + ":disabled")
b.click(self.dropdown_toggle(self.card_row("MDRAID disks", name=disk1)))
b.wait_visible(self.dropdown_action(self.card_row("MDRAID disks", name=disk1), "Remove") + "[disabled]")
b.wait_text(self.dropdown_description(self.card_row("MDRAID disks", name=disk1), "Remove"),
b.wait_visible(self.card_button("MDRAID device", "Add disk") + ":disabled")
b.click(self.dropdown_toggle(self.card_row("MDRAID device", name=disk1)))
b.wait_visible(self.dropdown_action(self.card_row("MDRAID device", name=disk1), "Remove") + "[disabled]")
b.wait_text(self.dropdown_description(self.card_row("MDRAID device", name=disk1), "Remove"),
"The MDRAID device must be running")
b.click(self.dropdown_toggle(self.card_row("MDRAID disks", name=disk1)))
b.click(self.dropdown_toggle(self.card_row("MDRAID device", name=disk1)))

self.raid_default_action("Start")
b.wait_text(self.card_desc("MDRAID device", "State"), "Running")

# With a running array, we can add spares, but not remove "in-sync" disks
b.wait_not_present(self.card_button("MDRAID disks", "Add disk") + ":disabled")
b.click(self.dropdown_toggle(self.card_row("MDRAID disks", name=disk1)))
b.wait_visible(self.dropdown_action(self.card_row("MDRAID disks", name=disk1), "Remove") + "[disabled]")
b.wait_text(self.dropdown_description(self.card_row("MDRAID disks", name=disk1), "Remove"),
b.wait_not_present(self.card_button("MDRAID device", "Add disk") + ":disabled")
b.click(self.dropdown_toggle(self.card_row("MDRAID device", name=disk1)))
b.wait_visible(self.dropdown_action(self.card_row("MDRAID device", name=disk1), "Remove") + "[disabled]")
b.wait_text(self.dropdown_description(self.card_row("MDRAID device", name=disk1), "Remove"),
"Need a spare disk")
b.click(self.dropdown_toggle(self.card_row("MDRAID disks", name=disk1)))
b.click(self.dropdown_toggle(self.card_row("MDRAID device", name=disk1)))

# Adding a spare will allow removal of the "in-sync" disks.
self.raid_add_disk(disk3)
Expand All @@ -307,25 +307,25 @@ class TestStorageMdRaid(storagelib.StorageCase):
disk2: "In sync"})

# Removing the disk will make the rest un-removable again
b.click(self.dropdown_toggle(self.card_row("MDRAID disks", name=disk3)))
b.wait_visible(self.dropdown_action(self.card_row("MDRAID disks", name=disk3), "Remove") + "[disabled]")
b.wait_text(self.dropdown_description(self.card_row("MDRAID disks", name=disk3), "Remove"),
b.click(self.dropdown_toggle(self.card_row("MDRAID device", name=disk3)))
b.wait_visible(self.dropdown_action(self.card_row("MDRAID device", name=disk3), "Remove") + "[disabled]")
b.wait_text(self.dropdown_description(self.card_row("MDRAID device", name=disk3), "Remove"),
"Need a spare disk")
b.click(self.dropdown_toggle(self.card_row("MDRAID disks", name=disk3)))
b.click(self.dropdown_toggle(self.card_row("MDRAID device", name=disk3)))

# A failed disk can be removed
dev = b.text(self.card_desc("MDRAID device", "Device"))
m.execute(f"mdadm --quiet {dev} --fail /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_DISK3")
self.wait_states({disk3: "Failed"})
self.raid_remove_disk(disk3)
b.wait_not_present(self.card_row("MDRAID disks", name=disk3))
b.wait_not_present(self.card_row("MDRAID device", name=disk3))

# The last disk can not be removed
b.click(self.dropdown_toggle(self.card_row("MDRAID disks", name=disk2)))
b.wait_visible(self.dropdown_action(self.card_row("MDRAID disks", name=disk2), "Remove") + "[disabled]")
b.wait_text(self.dropdown_description(self.card_row("MDRAID disks", name=disk2), "Remove"),
b.click(self.dropdown_toggle(self.card_row("MDRAID device", name=disk2)))
b.wait_visible(self.dropdown_action(self.card_row("MDRAID device", name=disk2), "Remove") + "[disabled]")
b.wait_text(self.dropdown_description(self.card_row("MDRAID device", name=disk2), "Remove"),
"Need a spare disk")
b.click(self.dropdown_toggle(self.card_row("MDRAID disks", name=disk2)))
b.click(self.dropdown_toggle(self.card_row("MDRAID device", name=disk2)))

def testBitmap(self):
m = self.machine
Expand Down
20 changes: 10 additions & 10 deletions test/verify/check-storage-msdos
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ class TestStorageMsDOS(storagelib.StorageCase):
# Format it with a DOS partition table
self.click_card_dropdown("Solid State Drive", "Create partition table")
self.dialog({"type": "dos"})
b.wait_text(self.card_row_col("GPT partitions", 1, 1), "Free space")
b.wait_text(self.card_row_col("DOS partitions", 1, 1), "Free space")

# Create a primary partition
self.click_dropdown(self.card_row("GPT partitions", 1), "Create partition")
self.click_dropdown(self.card_row("DOS partitions", 1), "Create partition")
self.dialog({"size": 10,
"type": "ext4",
"mount_point": "/foo",
"name": "FIRST"},
secondary=True)
b.wait_text(self.card_row_col("GPT partitions", 1, 2), "ext4 filesystem")
b.wait_text(self.card_row_col("DOS partitions", 1, 2), "ext4 filesystem")

# Open dialog for formatting the primary partition and check that "dos-extended" is not offered.
b.click(self.card_row("GPT partitions", 1))
b.click(self.card_row("DOS partitions", 1))
self.click_card_dropdown("ext4 filesystem", "Format")
self.dialog_wait_open()
b.wait_not_present("select option[value='dos-extended']")
Expand All @@ -57,31 +57,31 @@ class TestStorageMsDOS(storagelib.StorageCase):
b.click(self.card_parent_link())

# Create a extended partition to fill the rest of the disk
self.click_dropdown(self.card_row("GPT partitions", 2), "Create partition")
self.click_dropdown(self.card_row("DOS partitions", 2), "Create partition")
self.dialog_wait_open()
self.dialog_set_val("type", "dos-extended")
self.dialog_wait_not_present("name")
self.dialog_wait_not_present("mount_point")
self.dialog_wait_not_present("mount_options")
self.dialog_apply()
self.dialog_wait_close()
b.wait_text(self.card_row_col("GPT partitions", 2, 1), "Extended partition")
b.wait_text(self.card_row_col("GPT partitions", 3, 1), "Free space")
b.wait_text(self.card_row_col("DOS partitions", 2, 1), "Extended partition")
b.wait_text(self.card_row_col("DOS partitions", 3, 1), "Free space")

# Create logical partitions and check that "dos-extended" is
# not offered.
self.click_dropdown(self.card_row("GPT partitions", 3), "Create partition")
self.click_dropdown(self.card_row("DOS partitions", 3), "Create partition")
self.dialog_wait_open()
b.wait_not_present("select option[value='dos-extended']")
self.dialog_cancel()
self.dialog_wait_close()

# Delete it

self.click_dropdown(self.card_row("GPT partitions", 2), "Delete")
self.click_dropdown(self.card_row("DOS partitions", 2), "Delete")
self.confirm()

b.wait_text(self.card_row_col("GPT partitions", 2, 1), "Free space")
b.wait_text(self.card_row_col("DOS partitions", 2, 1), "Free space")


if __name__ == '__main__':
Expand Down
Loading

0 comments on commit a177612

Please sign in to comment.