From 14475bd0d70224adfc3e507eb1ba6ec45c69af06 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 30 Oct 2023 12:20:49 +0200 Subject: [PATCH] WIP - cleanup 3 --- pkg/storaged/pages/lvm2-volume-group.jsx | 2 +- test/verify/check-storage-ignored | 7 ++-- test/verify/check-storage-luks | 10 +++--- test/verify/check-storage-lvm2 | 8 ++--- test/verify/check-storage-mdraid | 2 +- test/verify/check-storage-mounting | 45 +++++++++++++++--------- test/verify/check-storage-resize | 2 -- test/verify/check-storage-swap | 5 +-- 8 files changed, 45 insertions(+), 36 deletions(-) diff --git a/pkg/storaged/pages/lvm2-volume-group.jsx b/pkg/storaged/pages/lvm2-volume-group.jsx index 55d8300be418..f390c86af8b8 100644 --- a/pkg/storaged/pages/lvm2-volume-group.jsx +++ b/pkg/storaged/pages/lvm2-volume-group.jsx @@ -61,7 +61,7 @@ const _ = cockpit.gettext; export function lvm2_delete_logical_volume_dialog(lvol, page) { const vgroup = client.vgroups[lvol.VolumeGroup]; const block = client.lvols_block[lvol.path]; - const usage = get_active_usage(client, block ? block.path : null, _("delete")); + const usage = get_active_usage(client, block ? block.path : lvol.path, _("delete")); if (usage.Blocking) { dialog_open({ diff --git a/test/verify/check-storage-ignored b/test/verify/check-storage-ignored index 11e16eb77d70..d16d0c3e6007 100755 --- a/test/verify/check-storage-ignored +++ b/test/verify/check-storage-ignored @@ -30,15 +30,12 @@ class TestStorageIgnored(storagelib.StorageCase): self.login_and_go("/storage") disk = self.add_loopback_disk() - b.wait_visible(self.card_row("Storage", location=disk)) b.click(self.card_row("Storage", location=disk)) b.wait_visible(self.card("Block device")) - b.click(self.card_row("Content", 1)) - b.wait_visible(self.card("Unformatted data")) - 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.click(self.card_row("Content", 1)) + b.wait_in_text(self.card_desc("ext2 filesystem", "Name"), "TESTLABEL") # Hide it via a udev rule. m.write("/run/udev/rules.d/99-ignore.rules", diff --git a/test/verify/check-storage-luks b/test/verify/check-storage-luks index 5baacd53a6c8..cc60d7a32e6d 100755 --- a/test/verify/check-storage-luks +++ b/test/verify/check-storage-luks @@ -433,14 +433,15 @@ class TestStorageLuksDestructive(storagelib.StorageCase): dev = "/dev/sda" m.add_disk("50M", serial="MYDISK") - b.click(self.card_row("Storage", name=dev)) + b.click(self.card_row("Storage", location=dev)) - b.click(self.card_button("Unformatted data", "Format")) + b.click(self.card_button("Content", "Format as filesystem")) self.dialog({"type": "ext4", "crypto": self.default_crypto_type, "passphrase": "vainu-reku-toma-rolle-kaja", "passphrase2": "vainu-reku-toma-rolle-kaja", "mount_point": "/run/foo"}) + b.click(self.card_row("Content", 1)) self.wait_mounted("ext4 filesystem (encrypted)") self.setup_systemd_password_agent("vainu-reku-toma-rolle-kaja") @@ -480,9 +481,9 @@ class TestStorageNBDE(storagelib.StorageCase, packagelib.PackageCase): # Add a disk and format it with luks dev = "/dev/sda" m.add_disk("50M", serial="MYDISK") - b.click(self.card_row("Storage", name=dev)) + b.click(self.card_row("Storage", location=dev)) - b.click(self.card_button("Unformatted data", "Format")) + b.click(self.card_button("Content", "Format as filesystem")) self.dialog({"type": "ext4", "crypto": self.default_crypto_type, "name": "ENCRYPTED", @@ -490,6 +491,7 @@ class TestStorageNBDE(storagelib.StorageCase, packagelib.PackageCase): "passphrase": "vainu-reku-toma-rolle-kaja", "passphrase2": "vainu-reku-toma-rolle-kaja"}, secondary=True) + b.click(self.card_row("Content", 1)) self.wait_not_mounted("Filesystem (encrypted)") b.wait_in_text(self.card_desc("Encryption", "Options"), "nofail") diff --git a/test/verify/check-storage-lvm2 b/test/verify/check-storage-lvm2 index 74198f1b9457..5b4ebcfd87b3 100755 --- a/test/verify/check-storage-lvm2 +++ b/test/verify/check-storage-lvm2 @@ -882,7 +882,7 @@ class TestStorageLvm2(storagelib.StorageCase): self.login_and_go("/storage") disk = self.add_loopback_disk() - b.wait_in_text("#others", disk) + b.wait_visible(self.card_row("Storage", location=disk)) m.execute(f"echo einszweidrei | cryptsetup luksFormat --pbkdf-memory 32768 {disk}") m.execute(f"echo einszweidrei | cryptsetup luksOpen {disk} dm-test") self.addCleanup(m.execute, "cryptsetup close dm-test || true") @@ -890,10 +890,8 @@ class TestStorageLvm2(storagelib.StorageCase): self.addCleanup(m.execute, "vgremove --force vgroup0 2>/dev/null || true") m.execute("lvcreate vgroup0 -n lvol0 -l100%FREE") - b.wait_in_text("#devices", "vgroup0") - b.click('#devices .sidepanel-row:contains("vgroup0")') - - self.content_tab_wait_in_info(1, 1, "Physical volumes", bn(disk)) + b.click(self.card_row("Storage", name="lvol0")) + b.wait_in_text(self.card_desc("Logical volume", "Physical volumes"), bn(disk)) if __name__ == '__main__': diff --git a/test/verify/check-storage-mdraid b/test/verify/check-storage-mdraid index e0bd70b07577..c535e604be51 100755 --- a/test/verify/check-storage-mdraid +++ b/test/verify/check-storage-mdraid @@ -232,7 +232,7 @@ class TestStorageMdRaid(storagelib.StorageCase): b.click(self.card_row("Disks", name=disk2)) b.click(self.card_desc("RAID disk", "Stored on") + " button") b.click(self.card_button("Content", "Erase")) - b.wait_in_text('#dialog', "remove from RAID, initialize") + b.wait_in_text('#dialog', "remove from RAID, erase") self.dialog_apply() self.dialog_wait_close() diff --git a/test/verify/check-storage-mounting b/test/verify/check-storage-mounting index 942913297d0d..533673948c0d 100755 --- a/test/verify/check-storage-mounting +++ b/test/verify/check-storage-mounting @@ -39,7 +39,7 @@ class TestStorageMounting(storagelib.StorageCase): # Format it - b.clicks(self.dropdown_action(self.card_row("Content", 1), "Format")) + b.click(self.card_button("Content", "Format as filesystem")) self.dialog_wait_open() self.dialog_set_val("type", "ext4") self.dialog_set_val("name", "FILESYSTEM") @@ -137,17 +137,18 @@ ExecStart=/usr/bin/sleep infinity # Add a disk disk = self.add_ram_disk() - b.click(self.card_row("Storage", name=disk)) + b.click(self.card_row("Storage", location=disk)) # Format it - b.click(self.card_button("Unformatted data", "Format")) + b.click(self.card_button("Content", "Format as filesystem")) self.dialog_wait_open() self.dialog_set_val("type", "ext4") self.dialog_set_val("name", "FILESYSTEM") self.dialog_set_val("mount_point", "/run/foo") self.dialog_apply() self.dialog_wait_close() + b.click(self.card_row("Content", 1)) b.wait_in_text(self.card_desc("ext4 filesystem", "Name"), "FILESYSTEM") b.wait_in_text(self.card_desc("ext4 filesystem", "Mount point"), "/run/foo") @@ -229,12 +230,13 @@ ExecStart=/usr/bin/sleep infinity self.login_and_go("/storage") disk = self.add_ram_disk() - b.click(self.card_row("Storage", name=disk)) + b.click(self.card_row("Storage", location=disk)) - b.click(self.card_button("Unformatted data", "Format")) + b.click(self.card_button("Content", "Format as filesystem")) self.dialog({"type": "ext4", "mount_point": "/run/foo"}, secondary=True) + b.click(self.card_row("Content", 1)) b.wait_in_text(self.card_desc("ext4 filesystem", "Mount point"), "The filesystem is not mounted") self.assertIn("noauto", m.execute("findmnt --fstab -n -o OPTIONS /run/foo")) @@ -284,9 +286,9 @@ ExecStart=/usr/bin/sleep infinity self.login_and_go("/storage") disk = self.add_ram_disk() - b.click(self.card_row("Storage", name=disk)) + b.click(self.card_row("Storage", location=disk)) - b.click(self.card_button("Unformatted data", "Format")) + b.click(self.card_button("Content", "Format as filesystem")) self.dialog({"type": "ext4", "mount_point": "/foo", "at_boot": "local", @@ -294,6 +296,7 @@ ExecStart=/usr/bin/sleep infinity "passphrase": "foobarfoo", "passphrase2": "foobarfoo"}, secondary=True) + b.click(self.card_row("Content", 1)) b.wait_in_text(self.card_desc("Filesystem (encrypted)", "Mount point"), "The filesystem is not mounted") self.assertIn("noauto", m.execute("findmnt --fstab -n -o OPTIONS /foo")) self.assert_in_configuration(disk, "crypttab", "options", "noauto") @@ -343,11 +346,11 @@ class TestStorageMountingLUKS(storagelib.StorageCase): # Add a disk disk = self.add_ram_disk() - b.click(self.card_row("Storage", name=disk)) + b.click(self.card_row("Storage", location=disk)) # Format it with encryption - b.click(self.card_button("Unformatted data", "Format")) + b.click(self.card_button("Content", "Format as filesystem")) self.dialog_wait_open() self.dialog_set_val("type", "ext4") self.dialog_set_val("name", "FILESYSTEM") @@ -359,6 +362,7 @@ class TestStorageMountingLUKS(storagelib.StorageCase): self.dialog_set_val("at_boot", "netdev") self.dialog_apply() self.dialog_wait_close() + b.click(self.card_row("Content", 1)) b.wait_in_text(self.card_desc("ext4 filesystem (encrypted)", "Name"), "FILESYSTEM") b.wait_in_text(self.card_desc("ext4 filesystem (encrypted)", "Mount point"), "/run/foo") @@ -426,24 +430,27 @@ class TestStorageMountingLUKS(storagelib.StorageCase): # Quickly make two logical volumes disk = self.add_ram_disk() - b.wait_visible(self.card_row("Storage", name=disk)) + b.wait_visible(self.card_row("Storage", location=disk)) m.execute(f"vgcreate test {disk}; lvcreate test -n one -L 20M; lvcreate test -n two -L 20M") b.click(self.card_row("Storage", name="test")) b.wait_text(self.card_row_col("Logical volumes", 1, 1), "one") b.wait_text(self.card_row_col("Logical volumes", 2, 1), "two") # Encrypt and format the first and give it /run/data as the mount point - b.clicks(self.dropdown_action(self.card_row("Logical volumes", 1), "Format")) + b.click(self.card_row("Logical volumes", 1)) + b.click(self.card_button("Unformatted data", "Format")) self.dialog({"type": "ext4", "crypto": self.default_crypto_type, "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.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") # Format the second and also try to use /run/data as the mount point - b.clicks(self.dropdown_action(self.card_row("Logical volumes", 2), "Format")) + b.click(self.card_row("Logical volumes", 2)) + b.click(self.card_button("Unformatted data", "Format")) self.dialog_wait_open() self.dialog_set_val("type", "ext4") self.dialog_set_val("mount_point", "/run/data") @@ -454,12 +461,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") # Format the first and re-use /run/data as the mount point. # This should be allowed. - b.clicks(self.dropdown_action(self.card_row("Logical volumes", 1), "Format")) + 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.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") @@ -471,15 +481,16 @@ class TestStorageMountingLUKS(storagelib.StorageCase): # Add a disk and format it with luks and a filesystem, but with "Never unlock at boot" disk = self.add_ram_disk() - b.click(self.card_row("Storage", name=disk)) + b.click(self.card_row("Storage", location=disk)) - b.click(self.card_button("Unformatted data", "Format")) + b.click(self.card_button("Content", "Format as filesystem")) self.dialog({"type": "ext4", "crypto": self.default_crypto_type, "passphrase": "vainu-reku-toma-rolle-kaja", "passphrase2": "vainu-reku-toma-rolle-kaja", "at_boot": "never", "mount_point": "/run/foo"}) + b.click(self.card_row("Content", 1)) b.wait_in_text(self.card_desc("ext4 filesystem (encrypted)", "Mount point"), "never mount at boot") # The filesystem should be mounted but have the "noauto" @@ -607,11 +618,13 @@ class TestStorageMountingLUKS(storagelib.StorageCase): self.dialog({"passphrase": "vainu-reku-toma-rolle-kaja"}) b.wait_text(self.card_row_col("Partitions", 2, 3), "/run/foo/bar") - b.click(self.card_button("Partitions", "Create partition table")) + b.click(self.card_button("Partitions", "Erase")) self.dialog_wait_open() b.wait_text("#dialog tbody:nth-of-type(1) td[data-label=Location]", "/run/foo/bar") b.wait_text("#dialog tbody:nth-of-type(2) td[data-label=Location]", "/run/foo") self.dialog_apply() + b.click(self.card_button("Content", "Create partition table")) + self.confirm() b.wait_text(self.card_row_col("Partitions", 1, 1), "Free space") diff --git a/test/verify/check-storage-resize b/test/verify/check-storage-resize index cf38fe2b7fa7..3633de701dd6 100755 --- a/test/verify/check-storage-resize +++ b/test/verify/check-storage-resize @@ -145,8 +145,6 @@ class TestStorageResize(storagelib.StorageCase): m = self.machine b = self.browser - m.upload(["/home/mvo/work/cockpit/dist/storaged"], "/usr/share/cockpit") - if self.storaged_version < [2, 7, 6]: # No Filesystem.Size property raise unittest.SkipTest("UDisks2 too old") diff --git a/test/verify/check-storage-swap b/test/verify/check-storage-swap index 7b73eb751249..a71ff4521a2a 100755 --- a/test/verify/check-storage-swap +++ b/test/verify/check-storage-swap @@ -31,10 +31,11 @@ class TestStorageswap(storagelib.StorageCase): self.login_and_go("/storage") disk = self.add_ram_disk() - b.click(self.card_row("Storage", name=disk)) + b.click(self.card_row("Storage", location=disk)) - b.wait_visible(self.card("Unformatted data")) + b.wait_in_text(self.card("Content"), "Drive is not formatted") m.execute(f"mkswap {disk}") + b.click(self.card_row("Content", 1)) b.wait_visible(self.card("Swap")) b.wait_text(self.card_desc("Swap", "Used"), "-")