Skip to content

Commit

Permalink
WIP - more precise card_desc testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer committed Nov 13, 2023
1 parent 1a6bac8 commit 0451240
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 52 deletions.
15 changes: 4 additions & 11 deletions pkg/storaged/containers/lvm2-logical-volume.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import client from "../client";
import { Alert } from "@patternfly/react-core/dist/esm/components/Alert/index.js";
import { CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.js";
import { DescriptionList } from "@patternfly/react-core/dist/esm/components/DescriptionList/index.js";
import { Flex, FlexItem } from "@patternfly/react-core/dist/esm/layouts/Flex/index.js";
import { StorageButton, StorageLink } from "../storage-controls.jsx";

import { SCard } from "../utils/card.jsx";
Expand Down Expand Up @@ -227,16 +226,10 @@ const LVM2LogicalVolumeContainer = ({ container, vgroup, lvol, block, unused_spa
<SCard title={_("LVM2 logical volume")} actions={<ActionButtons container={container} />}>
<CardBody>
<DescriptionList className="pf-m-horizontal-on-sm">
<SDesc title={_("Name")}>
<Flex>
<FlexItem>{lvol.Name}</FlexItem>
<FlexItem>
<StorageLink onClick={rename}>
{_("edit")}
</StorageLink>
</FlexItem>
</Flex>
</SDesc>
<SDesc title={_("Name")} value={lvol.Name}
action={<StorageLink onClick={rename}>
{_("edit")}
</StorageLink>} />
{ (layout && layout != "linear") &&
<SDesc title={_("Layout")} value={layout_desc[layout] || layout} />
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/storaged/utils/desc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export const SDesc = ({ title, value, action, children }) => {
if (action && value) {
content = (
<Flex>
<FlexItem>{value}</FlexItem>
<FlexItem>{action}</FlexItem>
<FlexItem data-test-value>{value}</FlexItem>
<FlexItem data-test-action>{action}</FlexItem>
</Flex>);
} else {
content = value || action;
Expand All @@ -40,6 +40,8 @@ export const SDesc = ({ title, value, action, children }) => {
return (
<DescriptionListGroup data-test-desc-title={title}>
<DescriptionListTerm>{title}</DescriptionListTerm>
<DescriptionListDescription>{content}{children}</DescriptionListDescription>
<DescriptionListDescription data-test-value={!(action && value)}>
{content}{children}
</DescriptionListDescription>
</DescriptionListGroup>);
};
5 changes: 4 additions & 1 deletion test/common/storagelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,10 @@ def card_row_col(self, title, row_index, col_index):
return self.card_row(title, row_index) + f" td:nth-child({col_index})"

def card_desc(self, card_title, desc_title):
return self.card(card_title) + f" [data-test-desc-title='{desc_title}'] dd"
return self.card(card_title) + f" [data-test-desc-title='{desc_title}'] [data-test-value=true]"

def card_desc_action(self, card_title, desc_title):
return self.card(card_title) + f" [data-test-desc-title='{desc_title}'] [data-test-action=true] button"

def dropdown_action(self, parent, title):
return [
Expand Down
2 changes: 1 addition & 1 deletion test/verify/check-storage-ignored
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TestStorageIgnored(storagelib.StorageCase):
b.wait_visible(self.card("Block device"))
m.execute(f"yes | mke2fs -q -L TESTLABEL {disk}")
with b.wait_timeout(30):
b.wait_in_text(self.card_desc("ext2 filesystem", "Name"), "TESTLABEL")
b.wait_text(self.card_desc("ext2 filesystem", "Name"), "TESTLABEL")

# Hide it via a udev rule.
m.write("/run/udev/rules.d/99-ignore.rules",
Expand Down
12 changes: 6 additions & 6 deletions test/verify/check-storage-luks
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class TestStorageLuks(storagelib.StorageCase):

# cut off minutes, to avoid a too wide race condition in the test
date_no_mins = b.eval_js("Intl.DateTimeFormat('en', { dateStyle: 'medium', timeStyle: 'short' }).format()").split(':')[0]
b.wait_in_text(self.card_desc("Encryption", "Stored passphrase"),
b.wait_text(self.card_desc("Encryption", "Stored passphrase"),
f"Last modified: {date_no_mins}:")

b.assert_pixels(self.card("Encryption"), "card",
Expand All @@ -116,12 +116,12 @@ class TestStorageLuks(storagelib.StorageCase):
self.assert_not_in_configuration(cleartext_dev, "fstab", "opts", "noauto")
self.wait_mounted("ext4 filesystem (encrypted)")

b.click(self.card_desc("Encryption", "Options") + " button")
b.click(self.card_desc_action("Encryption", "Options"))
self.dialog({"options": "weird,options"})
self.assert_in_configuration(dev, "crypttab", "options", "weird,options")

# Change stored passphrase
b.click(self.card_desc("Encryption", "Stored passphrase") + " button")
b.click(self.card_desc_action("Encryption", "Stored passphrase"))
self.dialog({"passphrase": "wrong-passphrase"})
self.assert_in_configuration(dev, "crypttab", "passphrase-path", passphrase_path)
self.assertEqual(m.execute(f"cat {passphrase_path}"), "wrong-passphrase")
Expand All @@ -146,7 +146,7 @@ class TestStorageLuks(storagelib.StorageCase):
self.wait_mounted("ext4 filesystem (encrypted)")

# Remove passphrase
b.click(self.card_desc("Encryption", "Stored passphrase") + " button")
b.click(self.card_desc_action("Encryption", "Stored passphrase"))
self.dialog({"passphrase": ""})
self.assert_in_configuration(dev, "crypttab", "passphrase-path", "")

Expand Down Expand Up @@ -208,7 +208,7 @@ class TestStorageLuks(storagelib.StorageCase):
b.wait_visible(self.card("Locked encrypted data"))

# Make it readonly
b.click(self.card_desc("Encryption", "Options") + " button")
b.click(self.card_desc_action("Encryption", "Options"))
self.dialog({"options": "readonly"})
self.assertNotEqual(m.execute("grep readonly /etc/crypttab"), "")

Expand Down Expand Up @@ -549,7 +549,7 @@ class TestStorageNBDE(storagelib.StorageCase, packagelib.PackageCase):
# Reset the options so that we can check that they get added
# also when a second key is added.
#
b.click(self.card_desc("ext4 filesystem (encrypted)", "Mount point") + " button")
b.click(self.card_desc_action("ext4 filesystem (encrypted)", "Mount point"))
self.dialog({"at_boot": "nofail"})
b.wait_in_text(self.card_desc("Encryption", "Options"), "nofail")

Expand Down
10 changes: 5 additions & 5 deletions test/verify/check-storage-lvm2
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ class TestStorageLvm2(storagelib.StorageCase):

# rename lvol0
b.click(self.card_row("LVM2 logical volumes", 1))
b.click(self.card_desc("LVM2 logical volume", "Name") + " button")
b.click(self.card_desc_action("LVM2 logical volume", "Name"))
self.dialog_wait_open()
self.dialog({"name": "lvol1"})
b.wait_in_text(self.card_desc("LVM2 logical volume", "Name"), "lvol1")
b.wait_text(self.card_desc("LVM2 logical volume", "Name"), "lvol1")

if self.can_do_layouts():
# check that it is stored on dev_2
Expand Down Expand Up @@ -261,7 +261,7 @@ class TestStorageLvm2(storagelib.StorageCase):
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 3), mount_point_one)

# rename volume group
b.click(self.card_desc("LVM2 volume group", "Name") + " button")
b.click(self.card_desc_action("LVM2 volume group", "Name"))
self.dialog_wait_open()
self.dialog_set_val("name", "vgroup1")
self.dialog_apply()
Expand Down Expand Up @@ -399,7 +399,7 @@ class TestStorageLvm2(storagelib.StorageCase):
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 1), "lvol0")
b.click(self.card_row("LVM2 logical volumes", 1))

b.wait_in_text(self.card_desc("LVM2 logical volume", "Layout"), "Distributed parity (RAID 5)")
b.wait_text(self.card_desc("LVM2 logical volume", "Layout"), "Distributed parity (RAID 5)")
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk2))
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk3))
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk4))
Expand Down Expand Up @@ -476,7 +476,7 @@ class TestStorageLvm2(storagelib.StorageCase):
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 1), "lvol0")
b.click(self.card_row("LVM2 logical volumes", 1))

b.wait_in_text(self.card_desc("LVM2 logical volume", "Layout"), "Distributed parity (RAID 5)")
b.wait_text(self.card_desc("LVM2 logical volume", "Layout"), "Distributed parity (RAID 5)")
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk1))
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk2))
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk3))
Expand Down
26 changes: 13 additions & 13 deletions test/verify/check-storage-mounting
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TestStorageMounting(storagelib.StorageCase):
self.dialog_apply()
self.dialog_wait_close()
self.assert_in_configuration("/dev/sda", "fstab", "dir", mount_point_foo)
b.wait_in_text(self.card_desc("ext4 filesystem", "Name"), "FILESYSTEM")
b.wait_text(self.card_desc("ext4 filesystem", "Name"), "FILESYSTEM")
b.wait_in_text(self.card_desc("ext4 filesystem", "Mount point"), mount_point_foo)

# Keep the mount point busy
Expand Down Expand Up @@ -80,11 +80,11 @@ ExecStart=/usr/bin/sleep infinity

m.execute("! systemctl --quiet is-active keep-mnt-busy")

b.click(self.card_desc("ext4 filesystem", "Name") + " button")
b.click(self.card_desc_action("ext4 filesystem", "Name"))
self.dialog({"name": "filesystem"})
b.wait_in_text(self.card_desc("ext4 filesystem", "Name"), "filesystem")
b.wait_text(self.card_desc("ext4 filesystem", "Name"), "filesystem")

b.click(self.card_desc("ext4 filesystem", "Mount point") + " button")
b.click(self.card_desc_action("ext4 filesystem", "Mount point"))
self.dialog(expect={"mount_point": mount_point_foo},
values={"mount_point": mount_point_bar})
self.assert_in_configuration("/dev/sda", "fstab", "dir", mount_point_bar)
Expand All @@ -95,7 +95,7 @@ ExecStart=/usr/bin/sleep infinity
b.wait_not_in_text(self.card_desc("ext4 filesystem", "Mount point"), "The filesystem is not mounted")

# Set the "Never unlock at boot option"
b.click(self.card_desc("ext4 filesystem", "Mount point") + " button")
b.click(self.card_desc_action("ext4 filesystem", "Mount point"))
self.dialog({"at_boot": "never"})
self.assertIn("noauto", m.execute(f"findmnt -s -n -o OPTIONS {mount_point_bar}"))
self.assertIn("x-cockpit-never-auto", m.execute(f"findmnt -s -n -o OPTIONS {mount_point_bar}"))
Expand Down Expand Up @@ -144,7 +144,7 @@ ExecStart=/usr/bin/sleep infinity
self.dialog_set_val("mount_point", "/run/foo")
self.dialog_apply()
self.dialog_wait_close()
b.wait_in_text(self.card_desc("ext4 filesystem", "Name"), "FILESYSTEM")
b.wait_text(self.card_desc("ext4 filesystem", "Name"), "FILESYSTEM")
b.wait_in_text(self.card_desc("ext4 filesystem", "Mount point"), "/run/foo")

# Unmount externally, remount with Cockpit
Expand Down Expand Up @@ -256,12 +256,12 @@ ExecStart=/usr/bin/sleep infinity
# have a bug where this would accidentally unmount the
# filesystem.

b.click(self.card_desc("ext4 filesystem", "Mount point") + " button")
b.click(self.card_desc_action("ext4 filesystem", "Mount point"))
self.dialog({})
b.wait_not_in_text(self.card_desc("ext4 filesystem", "Mount point"), "The filesystem is not mounted")

# Try to set a bad option while the filesystem is mounted.
b.click(self.card_desc("ext4 filesystem", "Mount point") + " button")
b.click(self.card_desc_action("ext4 filesystem", "Mount point"))
self.dialog_wait_open()
self.dialog_set_val("mount_options.extra", "hurr")
self.dialog_apply()
Expand Down Expand Up @@ -354,7 +354,7 @@ class TestStorageMountingLUKS(storagelib.StorageCase):
self.dialog_set_val("at_boot", "netdev")
self.dialog_apply()
self.dialog_wait_close()
b.wait_in_text(self.card_desc("ext4 filesystem (encrypted)", "Name"), "FILESYSTEM")
b.wait_text(self.card_desc("ext4 filesystem (encrypted)", "Name"), "FILESYSTEM")
b.wait_in_text(self.card_desc("ext4 filesystem (encrypted)", "Mount point"), "/run/foo")

# Unmount and lock externally, unlock and remount with Cockpit
Expand Down Expand Up @@ -435,7 +435,7 @@ class TestStorageMountingLUKS(storagelib.StorageCase):
"passphrase": "vainu-reku-toma-rolle-kaja",
"passphrase2": "vainu-reku-toma-rolle-kaja",
"mount_point": "/run/data"})
b.click(self.card_desc("ext4 filesystem (encrypted)", "Stored on") + " button")
b.click(self.card_desc_action("ext4 filesystem (encrypted)", "Stored on"))
b.wait_text(self.card_row_col("Logical volumes", 1, 2), "ext4 filesystem (encrypted)")
b.wait_text(self.card_row_col("Logical volumes", 1, 3), "/run/data")

Expand All @@ -452,15 +452,15 @@ class TestStorageMountingLUKS(storagelib.StorageCase):
self.dialog_wait_error("mount_point", "Mount point is already used for /dev/test/one")
self.dialog_cancel()
self.dialog_wait_close()
b.click(self.card_desc("Unformatted data", "Stored on") + " button")
b.click(self.card_desc_action("Unformatted data", "Stored on"))

# Format the first and re-use /run/data as the mount point.
# This should be allowed.
b.click(self.card_row("Logical volumes", 1))
b.click(self.card_button("ext4 filesystem (encrypted)", "Format"))
self.dialog({"type": "ext4",
"mount_point": "/run/data"})
b.click(self.card_desc("ext4 filesystem (encrypted)", "Stored on") + " button")
b.click(self.card_desc_action("ext4 filesystem (encrypted)", "Stored on"))
b.wait_text(self.card_row_col("Logical volumes", 1, 2), "ext4 filesystem (encrypted)")
b.wait_text(self.card_row_col("Logical volumes", 1, 3), "/run/data")

Expand Down Expand Up @@ -507,7 +507,7 @@ class TestStorageMountingLUKS(storagelib.StorageCase):
self.assertNotEqual(m.execute("grep noauto /etc/crypttab"), "")

# As should updating the mount information
b.click(self.card_desc("ext4 filesystem (encrypted)", "Mount point") + " button")
b.click(self.card_desc_action("ext4 filesystem (encrypted)", "Mount point"))
self.dialog_check({"mount_options.extra": False})
self.dialog_apply()
self.dialog_wait_close()
Expand Down
2 changes: 1 addition & 1 deletion test/verify/check-storage-resize
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class TestStorageResize(storagelib.StorageCase):

# Click on the card to check the label
b.click(self.card_row_col("LVM2 logical volumes", 1, 1))
b.wait_in_text(self.card_desc("ext4 filesystem", "Name"), "FSYS")
b.wait_text(self.card_desc("ext4 filesystem", "Name"), "FSYS")

# Grow the logical volume and let Cockpit grow the filesystem
m.execute("lvresize TEST/vol -L+100M")
Expand Down
18 changes: 9 additions & 9 deletions test/verify/check-storage-stratis
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class TestStorageStratis(storagelib.StorageCase):
b.wait_visible(self.card_row("Storage", name="pool0"))

b.click(self.card_row("Storage", name="pool0"))
b.wait_in_text(self.card_desc("Stratis pool", "Name"), "pool0")
b.wait_text(self.card_desc("Stratis pool", "Name"), "pool0")
b.wait_in_text(self.card_desc("Stratis pool", "Usage"), "8 GB")
b.wait_not_present('.pf-v5-c-alert')

Expand Down Expand Up @@ -157,7 +157,7 @@ class TestStorageStratis(storagelib.StorageCase):

# Rename one filesystem
b.click(self.card_row("Stratis filesystems", 1))
b.click(self.card_desc("Stratis filesystem", "Name") + " button")
b.click(self.card_desc_action("Stratis filesystem", "Name"))
self.dialog({'name': "fsys1-renamed"})
b.click(self.card_parent_link())
b.wait_text(self.card_row_col("Stratis filesystems", 1, 1), "fsys1-renamed")
Expand Down Expand Up @@ -261,9 +261,9 @@ class TestStorageStratis(storagelib.StorageCase):
b.wait_in_text(self.card_row("Stratis block devices", name=dev_5), "cache")

# Rename the pool
b.click(self.card_desc("Stratis pool", "Name") + " button")
b.click(self.card_desc_action("Stratis pool", "Name"))
self.dialog({'name': "pool0-renamed"})
b.wait_in_text(self.card_desc("Stratis pool", "Name"), "pool0-renamed")
b.wait_text(self.card_desc("Stratis pool", "Name"), "pool0-renamed")

# Create another filesystem
b.click(self.card_button("Stratis filesystems", "Create new filesystem"))
Expand Down Expand Up @@ -534,7 +534,7 @@ class TestStorageStratisReboot(storagelib.StorageCase):
self.dialog_set_val('passphrase', passphrase)
self.dialog_apply()
self.dialog_wait_close()
b.wait_in_text(self.card_desc("Encrypted Stratis pool", "Name"), "pool0")
b.wait_text(self.card_desc("Encrypted Stratis pool", "Name"), "pool0")

# Mount the filesystem
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), "/run/fsys1 (not mounted)")
Expand All @@ -548,7 +548,7 @@ class TestStorageStratisReboot(storagelib.StorageCase):
m.start_cockpit()
b.relogin()
b.enter_page("/storage")
b.wait_in_text(self.card_desc("Encrypted Stratis pool", "Name"), "pool0")
b.wait_text(self.card_desc("Encrypted Stratis pool", "Name"), "pool0")

# Filesystem should be mounted now
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), "/run/fsys1")
Expand Down Expand Up @@ -863,7 +863,7 @@ class TestStorageStratisNBDE(packagelib.PackageCase, storagelib.StorageCase):

b.click(self.card_row("Storage", name="pool0"))
b.wait_visible(self.card_desc("Encrypted Stratis pool", "Passphrase"))
b.wait_in_text(self.card_desc("Encrypted Stratis pool", "Keyserver"), "10.111.112.5")
b.wait_text(self.card_desc("Encrypted Stratis pool", "Keyserver"), "10.111.112.5")

b.assert_pixels(self.card("Encrypted Stratis pool"), "header",
ignore=['.pf-v5-c-description-list__group:contains(UUID)'])
Expand Down Expand Up @@ -933,7 +933,7 @@ class TestStorageStratisNBDE(packagelib.PackageCase, storagelib.StorageCase):
self.dialog_apply()
with b.wait_timeout(60):
self.dialog_wait_close()
b.wait_in_text(self.card_desc("Encrypted Stratis pool", "Keyserver"), "10.111.112.5")
b.wait_text(self.card_desc("Encrypted Stratis pool", "Keyserver"), "10.111.112.5")

# Remove the keyserver and add it back a second time, but try
# first with the wrong passphrase already in the keyring
Expand All @@ -956,7 +956,7 @@ class TestStorageStratisNBDE(packagelib.PackageCase, storagelib.StorageCase):
self.dialog_apply()
with b.wait_timeout(60):
self.dialog_wait_close()
b.wait_in_text(self.card_desc("Encrypted Stratis pool", "Keyserver"), "10.111.112.5")
b.wait_text(self.card_desc("Encrypted Stratis pool", "Keyserver"), "10.111.112.5")
m.execute("stratis key unset pool0")

# Create a mounted filesystem and reboot.
Expand Down
4 changes: 2 additions & 2 deletions test/verify/check-storage-vdo
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class TestStorageVDO(storagelib.StorageCase):
b.wait_not_present(self.card_row("LVM2 logical volumes", name=pool_name))
b.click(self.card_row("LVM2 logical volumes", 1))
# Volume card
b.wait_in_text(self.card_desc("LVM2 logical volume", "Name"), "vdo0")
b.wait_text(self.card_desc("LVM2 logical volume", "Name"), "vdo0")
b.wait_in_text(self.card_desc("LVM2 logical volume", "Size"), "10.0 GB")
# VDO pool card
b.wait_text(self.card_desc("LVM2 VDO pool", "Name"), pool_name)
Expand Down Expand Up @@ -148,7 +148,7 @@ class TestStorageVDO(storagelib.StorageCase):

b.click(self.card_row("LVM2 logical volumes", 1))
# Volume card
b.wait_in_text(self.card_desc("LVM2 logical volume", "Name"), "vdo0")
b.wait_text(self.card_desc("LVM2 logical volume", "Name"), "vdo0")
b.wait_in_text(self.card_desc("LVM2 logical volume", "Size"), "20.0 GB")
# VDO Pool tab
b.wait_in_text(self.card_desc("LVM2 VDO pool", "Size"), "6.00 GB")
Expand Down

0 comments on commit 0451240

Please sign in to comment.