Skip to content

Commit

Permalink
test: add storage test helper for disabled dropdown actions
Browse files Browse the repository at this point in the history
This new helper allows you to easily assert why a storage card row
dropdown action is disabled.
  • Loading branch information
jelly committed Jan 23, 2024
1 parent 4144931 commit 5a5f852
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 25 deletions.
6 changes: 6 additions & 0 deletions test/common/storagelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,12 @@ def click_card_dropdown(self, card_title, button_title):
def click_devices_dropdown(self, title):
self.click_card_dropdown("Storage", title)

def check_dropdown_action_disabled(self, parent, title, expected_text):
self.browser.click(self.dropdown_toggle(parent))
self.browser.wait_visible(self.dropdown_action(parent, title) + "[disabled]")
self.browser.wait_text(self.dropdown_description(parent, title), expected_text)
self.browser.click(self.dropdown_toggle(parent))

def wait_mounted(self, card_title):
with self.browser.wait_timeout(30):
self.browser.wait_not_in_text(self.card_desc(card_title, "Mount point"),
Expand Down
6 changes: 1 addition & 5 deletions test/verify/check-storage-btrfs
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,7 @@ class TestStorageBtrfs(storagelib.StorageCase):
""")

subvol_loc = f"{os.path.basename(ro_subvol)}/readonly"
b.click(self.dropdown_toggle(self.card_row("Storage", name=subvol_loc)))
b.wait_visible(self.dropdown_action(self.card_row("Storage", name=subvol_loc), "Create subvolume") + "[disabled]")
b.wait_text(self.dropdown_description(self.card_row("Storage", name=subvol_loc), "Create subvolume"),
"Subvolume needs to be mounted")
b.click(self.dropdown_toggle(self.card_row("Storage", name=subvol_loc)))
self.check_dropdown_action_disabled(self.card_row("Storage", name=subvol_loc), "Create subvolume", "Subvolume needs to be mounted")

def testMultiDevice(self):
m = self.machine
Expand Down
24 changes: 4 additions & 20 deletions test/verify/check-storage-mdraid
Original file line number Diff line number Diff line change
Expand Up @@ -282,22 +282,14 @@ class TestStorageMdRaid(storagelib.StorageCase):
b.wait_text(self.card_desc("MDRAID device", "State"), "Not running")

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 device", name=disk1)))
self.check_dropdown_action_disabled(self.card_row("MDRAID device", name=disk1), "Remove", "The MDRAID device must be running")

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 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 device", name=disk1)))
self.check_dropdown_action_disabled(self.card_row("MDRAID device", name=disk1), "Remove", "Need a spare disk")

# Adding a spare will allow removal of the "in-sync" disks.
self.raid_add_disk(disk3)
Expand All @@ -307,11 +299,7 @@ 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 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 device", name=disk3)))
self.check_dropdown_action_disabled(self.card_row("MDRAID device", name=disk3), "Remove", "Need a spare disk")

# A failed disk can be removed
dev = b.text(self.card_desc("MDRAID device", "Device"))
Expand All @@ -321,11 +309,7 @@ class TestStorageMdRaid(storagelib.StorageCase):
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 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 device", name=disk2)))
self.check_dropdown_action_disabled(self.card_row("MDRAID device", name=disk2), "Remove", "Need a spare disk")

def testBitmap(self):
m = self.machine
Expand Down

0 comments on commit 5a5f852

Please sign in to comment.