| 1 |
#!/usr/bin/python3 -cimport os, sys; os.execv(os.path.dirname(sys.argv[1]) + "/../common/pywrap", sys.argv) |
| 2 |
|
| 3 |
# |
| 4 |
# Copyright (C) 2015 Red Hat, Inc. |
| 5 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 |
|
| 7 |
|
| 8 |
import storagelib |
| 9 |
import testlib |
| 10 |
|
| 11 |
|
| 12 |
@testlib.nondestructive |
| 13 |
class TestStorageBasic(storagelib.StorageCase): |
| 14 |
|
| 15 |
def testBasic(self): |
| 16 |
m = self.machine |
| 17 |
b = self.browser |
| 18 |
|
| 19 |
self.login_and_go("/storage", superuser=False) |
| 20 |
self.allow_browser_errors("error: findmnt.*") |
| 21 |
|
| 22 |
create_dropdown = self.dropdown_toggle(self.card_header("Storage")) |
| 23 |
|
| 24 |
b.wait_visible(self.card("Storage")) |
| 25 |
b.wait_not_present(create_dropdown) |
| 26 |
|
| 27 |
b.relogin('/storage', superuser=True) |
| 28 |
|
| 29 |
b.wait_visible(create_dropdown) |
| 30 |
|
| 31 |
# Add a disk, partition it, format it, and finally remove it. |
| 32 |
disk = self.add_ram_disk() |
| 33 |
|
| 34 |
self.click_card_row("Storage", name=disk) |
| 35 |
b.wait_visible(self.card("Solid State Drive")) |
| 36 |
|
| 37 |
b.wait_text(self.card_desc("Solid State Drive", "Vendor"), "Linux") |
| 38 |
b.wait_in_text(self.card_desc("Solid State Drive", "Capacity"), "50 MiB") |
| 39 |
|
| 40 |
self.assertEqual(self.inode(b.text(self.card_desc("Solid State Drive", "Device file"))), self.inode(disk)) |
| 41 |
|
| 42 |
m.execute(f'parted -s {disk} mktable gpt') |
| 43 |
m.execute(f'parted -s {disk} mkpart primary ext2 1M 8M') |
| 44 |
b.wait_text(self.card_row_col("GPT partitions", 1, 2), "Unformatted data") |
| 45 |
|
| 46 |
# create filesystem on the first partition |
| 47 |
# HACK - the block device might disappear briefly when udevd does its BLKRRPART. |
| 48 |
testlib.wait(lambda: m.execute(f'mke2fs {disk}1'), delay=1, tries=5) |
| 49 |
b.wait_text(self.card_row_col("GPT partitions", 1, 2), "ext2 filesystem") |
| 50 |
|
| 51 |
self.click_card_row("GPT partitions", 1) |
| 52 |
b.wait_text(self.card_desc("Partition", "Name"), "primary") |
| 53 |
b.assert_pixels(self.card("Partition"), "partition", |
| 54 |
mock={"[data-test-desc-title='UUID'] [data-test-value='true']": "a12978a1-5d6e-f24f-93de-11789977acde"}) |
| 55 |
b.assert_pixels(self.card("ext2 filesystem"), "filesystem") |
| 56 |
|
| 57 |
b.go("#/") |
| 58 |
b.wait_visible(self.card("Storage")) |
| 59 |
b.wait_visible(self.card_row("Storage", name=disk)) |
| 60 |
|
| 61 |
# Create a subvolume with a really long name to show |
| 62 |
# truncation in the pixel test. |
| 63 |
|
| 64 |
if b.pixels_label: |
| 65 |
long = "really-" * 15 + "long-name-that-will-be-truncated" |
| 66 |
m.execute(f"btrfs subvol create /{long}") |
| 67 |
self.addCleanup(m.execute, f"btrfs subvol delete /{long}") |
| 68 |
b.wait_visible(self.card_row("Storage", name=long)) |
| 69 |
b.assert_pixels(self.card("Storage"), "overview", |
| 70 |
# Usage numbers are not stable and also cause |
| 71 |
# the table columns to shift. The usage bars |
| 72 |
# are not stable but are always the same size, |
| 73 |
# so it is good enough to ignore them. |
| 74 |
mock={".usage-text": "---"}, |
| 75 |
ignore=[".usage-bar"]) |
| 76 |
self.force_remove_disk(disk) |
| 77 |
b.wait_not_present(self.card_row("Storage", name=disk)) |
| 78 |
|
| 79 |
|
| 80 |
if __name__ == '__main__': |
| 81 |
testlib.test_main() |