Skip to content

Commit

Permalink
WIP - cleanup 3
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer committed Oct 30, 2023
1 parent 17c4894 commit 14475bd
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 36 deletions.
2 changes: 1 addition & 1 deletion pkg/storaged/pages/lvm2-volume-group.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
7 changes: 2 additions & 5 deletions test/verify/check-storage-ignored
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 6 additions & 4 deletions test/verify/check-storage-luks
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -480,16 +481,17 @@ 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",
"mount_point": mount_point_secret,
"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")
Expand Down
8 changes: 3 additions & 5 deletions test/verify/check-storage-lvm2
Original file line number Diff line number Diff line change
Expand Up @@ -882,18 +882,16 @@ 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")
m.execute("vgcreate vgroup0 /dev/mapper/dm-test")
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__':
Expand Down
2 changes: 1 addition & 1 deletion test/verify/check-storage-mdraid
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
45 changes: 29 additions & 16 deletions test/verify/check-storage-mounting
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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"))

Expand Down Expand Up @@ -284,16 +286,17 @@ 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",
"crypto": "luks1",
"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")
Expand Down Expand Up @@ -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")
Expand All @@ -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")

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

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


Expand Down
2 changes: 0 additions & 2 deletions test/verify/check-storage-resize
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 3 additions & 2 deletions test/verify/check-storage-swap
Original file line number Diff line number Diff line change
Expand Up @@ -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"), "-")

Expand Down

0 comments on commit 14475bd

Please sign in to comment.