File: check-storage-basic

package info (click to toggle)
cockpit 354-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 308,956 kB
  • sloc: javascript: 775,606; python: 40,351; ansic: 35,655; cpp: 11,117; sh: 3,511; makefile: 580; xml: 261
file content (93 lines) | stat: -rwxr-xr-x 3,803 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/python3 -cimport os, sys; os.execv(os.path.dirname(sys.argv[1]) + "/../common/pywrap", sys.argv)

# This file is part of Cockpit.
#
# Copyright (C) 2015 Red Hat, Inc.
#
# Cockpit is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Cockpit is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Cockpit; If not, see <https://www.gnu.org/licenses/>.

import storagelib
import testlib


@testlib.nondestructive
class TestStorageBasic(storagelib.StorageCase):

    def testBasic(self):
        m = self.machine
        b = self.browser

        self.login_and_go("/storage", superuser=False)
        self.allow_browser_errors("error: findmnt.*")

        create_dropdown = self.dropdown_toggle(self.card_header("Storage"))

        b.wait_visible(self.card("Storage"))
        b.wait_not_present(create_dropdown)

        b.relogin('/storage', superuser=True)

        b.wait_visible(create_dropdown)

        # Add a disk, partition it, format it, and finally remove it.
        disk = self.add_ram_disk()

        self.click_card_row("Storage", name=disk)
        b.wait_visible(self.card("Solid State Drive"))

        b.wait_text(self.card_desc("Solid State Drive", "Vendor"), "Linux")
        b.wait_in_text(self.card_desc("Solid State Drive", "Capacity"), "50 MiB")

        self.assertEqual(self.inode(b.text(self.card_desc("Solid State Drive", "Device file"))), self.inode(disk))

        m.execute(f'parted -s {disk} mktable gpt')
        m.execute(f'parted -s {disk} mkpart primary ext2 1M 8M')
        b.wait_text(self.card_row_col("GPT partitions", 1, 2), "Unformatted data")

        # create filesystem on the first partition
        # HACK - the block device might disappear briefly when udevd does its BLKRRPART.
        testlib.wait(lambda: m.execute(f'mke2fs {disk}1'), delay=1, tries=5)
        b.wait_text(self.card_row_col("GPT partitions", 1, 2), "ext2 filesystem")

        self.click_card_row("GPT partitions", 1)
        b.wait_text(self.card_desc("Partition", "Name"), "primary")
        b.assert_pixels(self.card("Partition"), "partition",
                        mock={"dt:contains('UUID') + dd": "a12978a1-5d6e-f24f-93de-11789977acde"})
        b.assert_pixels(self.card("ext2 filesystem"), "filesystem")

        b.go("#/")
        b.wait_visible(self.card("Storage"))
        b.wait_visible(self.card_row("Storage", name=disk))

        # Create a subvolume with a really long name to show
        # truncation in the pixel test.

        if b.pixels_label:
            long = "really-" * 15 + "long-name-that-will-be-truncated"
            m.execute(f"btrfs subvol create /{long}")
            self.addCleanup(m.execute, f"btrfs subvol delete /{long}")
            b.wait_visible(self.card_row("Storage", name=long))
        b.assert_pixels(self.card("Storage"), "overview",
                        # Usage numbers are not stable and also cause
                        # the table columns to shift. The usage bars
                        # are not stable but are always the same size,
                        # so it is good enough to ignore them.
                        mock={".usage-text": "---"},
                        ignore=[".usage-bar"])
        self.force_remove_disk(disk)
        b.wait_not_present(self.card_row("Storage", name=disk))


if __name__ == '__main__':
    testlib.test_main()