forked from cockpit-project/cockpit
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show the whole picture about multipath devices and don't let people mess with improperly configured ones. Fixes cockpit-project#2554
- Loading branch information
Showing
7 changed files
with
203 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# 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/>. | ||
|
||
from testlib import * | ||
from storagelib import * | ||
|
||
class TestStorage(StorageCase): | ||
def testBasic(self): | ||
m = self.machine | ||
b = self.browser | ||
|
||
def detail_row(index): | ||
return '#detail tr:nth-child(%s)' % index | ||
|
||
def detail_row_name(index): | ||
return '#detail tr:nth-child(%s) td:nth-child(1)' % index | ||
|
||
def detail_row_value(index): | ||
return '#detail tr:nth-child(%s) td:nth-child(2)' % index | ||
|
||
def wait_detail_row(index, name): | ||
b.wait_present(detail_row(index)) | ||
b.wait_text(detail_row_name(index), name) | ||
|
||
def check_free_block_devices(expected): | ||
blocks = b.eval_js ("return ph_texts('#dialog [data-field=\"disks\"] .checkbox')") | ||
if len(blocks) != len(expected): | ||
return False | ||
for i in range(len(expected)): | ||
if not expected[i] in blocks[i]: | ||
return False | ||
return True | ||
|
||
self.login_and_go("/storage/devices") | ||
b.wait_in_text("#drives", "VirtIO") | ||
|
||
b.eval_js(""" | ||
ph_texts = function (sel) { | ||
return $(sel).map(function (i, e) { return $(e).text(); }).get(); | ||
}""") | ||
|
||
# Add a disk | ||
disk = m.add_disk("10M", serial="MYSERIAL") | ||
|
||
b.wait_in_text("#drives", "MYSERIAL") | ||
b.click('tr:contains("MYSERIAL")') | ||
b.wait_visible('#storage-detail') | ||
wait_detail_row(5, "Device File") | ||
b.wait_text(detail_row_value(5), "/dev/sda") | ||
|
||
# Add another path to the same disk. The primary device file | ||
# should disappear and multipath devices should be listed. | ||
m.add_disk_path(disk) | ||
b.wait_text(detail_row_value(5), "-") | ||
wait_detail_row(6, "Multipath Devices") | ||
b.wait_in_text(detail_row_value(6), "/dev/sda") | ||
b.wait_in_text(detail_row_value(6), "/dev/sdb") | ||
|
||
# Check that neither is offered as a free block device | ||
b.go("/") | ||
b.wait_visible('#create-volume-group') | ||
b.click('#create-volume-group') | ||
self.dialog_wait_open() | ||
check_free_block_devices([]) | ||
self.dialog_cancel() | ||
self.dialog_wait_close() | ||
|
||
b.go("/sda") | ||
b.wait_visible('#storage-detail') | ||
|
||
# Switch on multipathd. A primary device should appear. | ||
m.execute("mpathconf --enable && systemctl restart multipathd") | ||
# HACK - https://bugzilla.redhat.com/show_bug.cgi?id=1254583 | ||
m.execute("udevadm trigger") | ||
b.wait_text(detail_row_value(5), "/dev/mapper/mpatha") | ||
|
||
# Check that (exactly) the primary device is offered as free | ||
b.go("/") | ||
b.wait_visible('#create-volume-group') | ||
b.click('#create-volume-group') | ||
self.dialog_wait_open() | ||
check_free_block_devices([ "/dev/mapper/mpatha" ]) | ||
self.dialog_cancel() | ||
self.dialog_wait_close() | ||
|
||
test_main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters