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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
#!/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 *
class TestStorageFormat(StorageCase):
def testFormatTooSmall(self):
m = self.machine
b = self.browser
self.login_and_go("/storage")
# Try to format a disk that is too small for XFS.
m.add_disk("5M", serial="DISK1")
b.wait_in_text("#drives", "DISK1")
b.click('#drives .sidepanel-row:contains("DISK1")')
b.wait_visible('#storage-detail')
self.content_head_action(1, "Format")
self.dialog_wait_open()
self.dialog_set_val("type", "xfs")
self.dialog_set_val("mount_point", "/foo")
self.dialog_set_val("mount_options.auto", False)
self.dialog_apply()
b.wait_in_text(".pf-c-modal-box__footer > div.pf-m-danger:nth-child(1)", "Error creating file system")
def testFormatTypes(self):
m = self.machine
b = self.browser
self.login_and_go("/storage")
m.add_disk("50M", serial="DISK1")
b.wait_in_text("#drives", "DISK1")
b.click('#drives .sidepanel-row:contains("DISK1")')
b.wait_visible('#storage-detail')
def check_type(type, label_limit, head_action=False):
if head_action:
self.content_head_action(1, "Format")
else:
self.content_dropdown_action(1, "Format")
self.dialog_wait_open()
self.dialog_set_val("type", type)
self.dialog_set_val("mount_point", "/foo")
self.dialog_set_val("mount_options.auto", False)
self.dialog_set_val("name", "X" * (label_limit + 1))
self.dialog_apply()
self.dialog_wait_error("name", "Name cannot be longer than %d characters" % label_limit)
self.dialog_set_val("name", "X" * label_limit)
self.dialog_apply()
self.dialog_wait_close()
self.content_row_wait_in_col(1, 1, type + " file system")
def check_unsupported_type(type):
self.content_dropdown_action(1, "Format")
self.dialog_wait_open()
b.wait_not_present('#dialog li[value=%s]' % type)
self.dialog_cancel()
self.dialog_wait_close()
check_type("xfs", 12, head_action=True)
check_type("ext4", 16)
check_type("vfat", 11)
if m.image in ["rhel-8-3", "rhel-8-3-distropkg", "rhel-8-4", "rhel-8-4-distropkg", "centos-8-stream"]:
check_unsupported_type("ntfs")
else:
check_type("ntfs", 128)
def testFormatCancel(self):
m = self.machine
b = self.browser
self.login_and_go("/storage")
b.wait_in_text("#drives", "VirtIO")
# Make a super slow block device so that we have enough
# chances to cancel the Format.
disk = self.add_ram_disk()
m.execute("""disk=%s; echo "0 `blockdev --getsz $disk` delay $disk 0 500" | dmsetup create superslow""" % disk)
b.click("#others .sidepanel-row:contains('/dev/mapper/superslow')")
b.wait_visible('#storage-detail')
self.content_head_action(1, "Format")
self.dialog_wait_open()
self.dialog_set_val("mount_point", "/foo")
self.dialog_apply()
b.wait_in_text("footer", "Creating filesystem on /dev/mapper/superslow")
self.dialog_cancel()
self.dialog_wait_close()
self.content_row_wait_in_col(1, 1, "Unrecognized data")
self.content_head_action(1, "Format")
self.dialog_wait_open()
self.dialog_set_val("erase", "zero")
self.dialog_set_val("mount_point", "/foo")
self.dialog_apply()
b.wait_in_text("footer", "Erasing /dev/mapper/superslow")
sit()
self.dialog_cancel()
self.dialog_wait_close()
self.content_row_wait_in_col(1, 1, "Unrecognized data")
if __name__ == '__main__':
test_main()
|