Debian Codegraph @

test/verify/check-storage-multipath

raw
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.skipImage("No support for multipath", "debian-*", "ubuntu-*", "arch")
13 @testlib.skipImage("multipath support not installed", "*-bootc")
14 class TestStorageMultipath(storagelib.StorageCase):
15
16 def testBasic(self):
17 m = self.machine
18 b = self.browser
19
20 def check_free_block_devices(expected):
21 blocks = list(b.eval_js("ph_texts('#dialog [data-field=\"disks\"] .select-space-details')"))
22 self.assertEqual(len(blocks), len(expected))
23 for i in range(len(expected)):
24 self.assertIn(expected[i], blocks[i])
25
26 # At least on Fedora 27, multipath only looks at SCSI_IDENT_
27 # and ID_WWN properties, so we install a custom udev rule to
28 # set ID_WWN to something that can identify multipathed devices.
29 #
30 m.write("/etc/udev/rules.d/99-fake-wwn.rules", 'SUBSYSTEM=="block", ENV{ID_WWN}="$env{ID_SCSI_SERIAL}"\n')
31 m.execute("udevadm control --reload")
32 m.execute("udevadm trigger")
33
34 self.login_and_go("/storage")
35
36 b.eval_js("""
37 ph_texts = function (sel) {
38 return ph_select(sel).map(function (e) { return e.textContent });
39 }""")
40
41 # Add a disk
42 info1 = m.add_disk("10M", serial="MYSERIAL")
43 dev1 = "/dev/" + info1["dev"]
44
45 self.click_card_row("Storage", name=dev1)
46 b.wait_text(self.card_desc("Hard Disk Drive", "Device file"), dev1)
47
48 # Add another disk with the same serial, which fools
49 # multipathd into treating it as another path to the first
50 # disk. Since we never actually write to it, this is fine.
51
52 # The primary device file should disappear and multipathed
53 # devices should be listed.
54 info2 = m.add_disk("10M", serial="MYSERIAL")
55 dev2 = "/dev/" + info2["dev"]
56
57 b.wait_text(self.card_desc("Hard Disk Drive", "Device file"), "-")
58 b.wait_in_text(self.card_desc("Hard Disk Drive", "Multipathed devices"), dev1)
59 b.wait_in_text(self.card_desc("Hard Disk Drive", "Multipathed devices"), dev2)
60
61 # Check that only one is offered as a free block device
62 b.go("#/")
63 self.click_dropdown(self.card_header("Storage"), "Create LVM2 volume group")
64 self.dialog_wait_open()
65 check_free_block_devices(["/dev/sda"])
66 self.dialog_cancel()
67 self.dialog_wait_close()
68
69 # Switch on multipathd. A primary device should appear.
70
71 b.wait_visible(".pf-m-danger:contains('There are devices with multiple paths on the system, but')")
72 b.click("button:contains('Start multipath')")
73 b.wait_not_present(".pf-m-danger:contains('There are devices with multiple paths on the system, but')")
74 b.wait_visible(self.card_row("Storage", name="/dev/mapper/mpatha"))
75
76 # Check that (exactly) the primary device is offered as free
77 self.click_dropdown(self.card_header("Storage"), "Create LVM2 volume group")
78 self.dialog_wait_open()
79 check_free_block_devices(["/dev/mapper/mpatha"])
80 self.dialog_cancel()
81 self.dialog_wait_close()
82
83
84 if __name__ == '__main__':
85 testlib.test_main()