File: check-storage-basic

package info (click to toggle)
cockpit 239-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 67,268 kB
  • sloc: javascript: 245,474; ansic: 72,273; python: 23,634; xml: 6,155; sh: 2,919; makefile: 923; sed: 5
file content (71 lines) | stat: -rwxr-xr-x 2,412 bytes parent folder | download
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
#!/usr/bin/python3

# 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 <http://www.gnu.org/licenses/>.

import parent
from storagelib import *
from testlib import *


@nondestructive
class TestStorageBasic(StorageCase):

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

        self.login_and_go("/storage", superuser=False)

        b.wait_visible("#devices")
        b.wait_not_present("#devices .pf-c-dropdown button")

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

        b.wait_visible("#devices .pf-c-dropdown button:not([disabled])")

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

        b.click('.sidepanel-row:contains("%s")' % disk)
        b.wait_visible('#storage-detail')
        self.content_row_wait_in_col(1, 1, "Unrecognized data")

        def info_field_value(name):
            return b.text('#detail-header dt:contains("%s") + dd' % name)

        self.assertEqual(self.inode(info_field_value("Device file")), self.inode(disk))

        m.execute('parted -s %s mktable gpt' % disk)
        m.execute('parted -s %s mkpart primary ext2 1M 8M' % disk)
        self.content_row_wait_in_col(1, 1, "Unrecognized data")
        self.content_tab_wait_in_info(1, 1, "Name", "primary")

        # create file system on the first partition
        # HACK - the block device might disappear briefly when udevd does its BLKRRPART.
        wait(lambda: m.execute('mke2fs %s1' % disk), delay=1, tries=5)
        self.content_row_wait_in_col(1, 1, "ext2 file system")

        b.go("#/")
        b.wait_visible('#storage')
        b.wait_in_text("#drives", disk)
        self.force_remove_disk(disk)
        b.wait_not_in_text("#drives", disk)


if __name__ == '__main__':
    test_main()