| 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 math |
| 9 |
import os |
| 10 |
import unittest |
| 11 |
|
| 12 |
import storagelib |
| 13 |
import testlib |
| 14 |
|
| 15 |
|
| 16 |
# We use basename a lot, let's reduce the noise |
| 17 |
def bn(path): |
| 18 |
return os.path.basename(path) |
| 19 |
|
| 20 |
|
| 21 |
@testlib.nondestructive |
| 22 |
class TestStorageLvm2(storagelib.StorageCase): |
| 23 |
|
| 24 |
def can_do_layouts(self): |
| 25 |
return self.storaged_version >= [2, 10] |
| 26 |
|
| 27 |
def skip_if_no_layouts(self): |
| 28 |
if not self.can_do_layouts(): |
| 29 |
raise unittest.SkipTest("raid layouts not supported") |
| 30 |
|
| 31 |
def testLvm(self): |
| 32 |
m = self.machine |
| 33 |
b = self.browser |
| 34 |
|
| 35 |
mount_point_one = "/run/one" |
| 36 |
mount_point_thin = "/run/thin" |
| 37 |
|
| 38 |
self.login_and_go("/storage") |
| 39 |
|
| 40 |
dev_1 = self.add_ram_disk() |
| 41 |
dev_2 = self.add_loopback_disk(name="loop10") |
| 42 |
b.wait_visible(self.card_row("Storage", name=dev_1)) |
| 43 |
b.wait_visible(self.card_row("Storage", name=dev_2)) |
| 44 |
|
| 45 |
# Create a volume group out of two disks |
| 46 |
m.execute(f"vgcreate TEST1 {dev_1} {dev_2}") |
| 47 |
# just in case the test fails |
| 48 |
self.addCleanupVG("TEST1") |
| 49 |
self.click_card_row("Storage", name="TEST1") |
| 50 |
b.wait_visible(self.card_row("LVM2 volume group", name=dev_1)) |
| 51 |
b.wait_visible(self.card_row("LVM2 volume group", name=dev_2)) |
| 52 |
|
| 53 |
# Create two logical volumes |
| 54 |
m.execute("lvcreate TEST1 -n one -L 20m") |
| 55 |
b.wait_visible(self.card_row("LVM2 logical volumes", name="one")) |
| 56 |
m.execute("lvcreate TEST1 -n two -L 20m") |
| 57 |
b.wait_visible(self.card_row("LVM2 logical volumes", name="two")) |
| 58 |
|
| 59 |
# Deactivate one |
| 60 |
m.execute("lvchange TEST1/one -a n") |
| 61 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 2), "Inactive logical volume") |
| 62 |
|
| 63 |
# and remove it |
| 64 |
m.execute("until lvremove -f TEST1/one; do sleep 5; done") |
| 65 |
b.wait_not_present(self.card_row("LVM2 logical volumes", name="one")) |
| 66 |
|
| 67 |
# remove a disk from the volume group |
| 68 |
m.execute(f"pvmove {dev_2} &>/dev/null || true") |
| 69 |
m.execute(f"vgreduce TEST1 {dev_2}") |
| 70 |
b.wait_not_present(self.card_row("LVM2 volume group", name=dev_2)) |
| 71 |
|
| 72 |
# The remaining lone disk is not removable |
| 73 |
self.check_dropdown_action_disabled(self.card_row("LVM2 volume group", name=dev_1), "Remove", "Last cannot be removed") |
| 74 |
|
| 75 |
# Thin volumes |
| 76 |
m.execute("lvcreate TEST1 --thinpool pool -L 20m") |
| 77 |
b.wait_visible(self.card_row("LVM2 logical volumes", name="pool")) |
| 78 |
m.execute("lvcreate -T TEST1/pool -n thin -V 100m") |
| 79 |
b.wait_visible(self.card_row("LVM2 logical volumes", name="thin")) |
| 80 |
self.click_card_row("LVM2 logical volumes", name="pool") |
| 81 |
b.wait_visible(self.card_row("Thinly provisioned LVM2 logical volumes", name="thin")) |
| 82 |
|
| 83 |
m.execute("dd if=/dev/urandom of=/dev/mapper/TEST1-thin bs=1M count=10 status=none") |
| 84 |
b.wait_text(self.card_desc("Pool for thinly provisioned LVM2 logical volumes", "Data used"), "50%") |
| 85 |
m.execute("until lvremove -f TEST1/thin; do sleep 5; done") |
| 86 |
b.wait_text(self.card_desc("Pool for thinly provisioned LVM2 logical volumes", "Data used"), "0%") |
| 87 |
|
| 88 |
# remove the volume group |
| 89 |
b.go("#/") |
| 90 |
m.execute("vgremove -f TEST1") |
| 91 |
b.wait_visible(self.card("Storage")) |
| 92 |
b.wait_not_present(self.card_row("Storage", name="TEST1")) |
| 93 |
|
| 94 |
# Wipe the disks and make sure lvmetad forgets about them. This |
| 95 |
# might help with reusing it in the second half of this test. |
| 96 |
# |
| 97 |
# HACK - the pvscan is necessary because of |
| 98 |
# https://bugzilla.redhat.com/show_bug.cgi?id=1063813 |
| 99 |
# |
| 100 |
m.execute(f"wipefs -a {dev_1} {dev_2}") |
| 101 |
m.execute(f"pvscan --cache {dev_1} {dev_2}") |
| 102 |
|
| 103 |
# create volume group in the UI |
| 104 |
|
| 105 |
self.dialog_with_retry(trigger=lambda: self.click_devices_dropdown("Create LVM2 volume group"), |
| 106 |
expect=lambda: (self.dialog_is_present('disks', dev_1) and |
| 107 |
self.dialog_is_present('disks', dev_2) and |
| 108 |
self.dialog_check({"name": "vgroup0"})), |
| 109 |
values={"disks": {dev_1: True, |
| 110 |
dev_2: True}}) |
| 111 |
|
| 112 |
# just in case the test fails |
| 113 |
self.addCleanupVG("vgroup0") |
| 114 |
b.wait_visible(self.card_row("Storage", name="vgroup0")) |
| 115 |
|
| 116 |
# Check that the next name is "vgroup1" |
| 117 |
self.click_devices_dropdown("Create LVM2 volume group") |
| 118 |
self.dialog_wait_open() |
| 119 |
self.dialog_wait_val("name", "vgroup1") |
| 120 |
self.dialog_cancel() |
| 121 |
self.dialog_wait_close() |
| 122 |
|
| 123 |
self.click_card_row("Storage", name="vgroup0") |
| 124 |
|
| 125 |
# create a logical volume |
| 126 |
b.click(self.card_button("LVM2 logical volumes", "Create new logical volume")) |
| 127 |
self.dialog(expect={"name": "lvol0"}, |
| 128 |
values={"purpose": "block", |
| 129 |
"size": 20}) |
| 130 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 1), "lvol0") |
| 131 |
|
| 132 |
# check that the next default name is "lvol1" |
| 133 |
b.click(self.card_button("LVM2 logical volumes", "Create new logical volume")) |
| 134 |
self.dialog_wait_open() |
| 135 |
self.dialog_wait_val("name", "lvol1") |
| 136 |
self.dialog_cancel() |
| 137 |
self.dialog_wait_close() |
| 138 |
|
| 139 |
# rename lvol0 |
| 140 |
self.click_card_row("LVM2 logical volumes", 1) |
| 141 |
b.click(self.card_desc_action("LVM2 logical volume", "Name")) |
| 142 |
self.dialog_wait_open() |
| 143 |
self.dialog({"name": "lvol1"}) |
| 144 |
b.wait_text(self.card_desc("LVM2 logical volume", "Name"), "lvol1") |
| 145 |
|
| 146 |
if self.can_do_layouts(): |
| 147 |
# check that it is stored on dev_2 |
| 148 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Physical volumes"), bn(dev_2)) |
| 149 |
|
| 150 |
# grow it |
| 151 |
b.click(self.card_button("LVM2 logical volume", "Grow")) |
| 152 |
self.dialog({"size": 30}) |
| 153 |
|
| 154 |
# format and mount it |
| 155 |
self.click_card_dropdown("Unformatted data", "Format") |
| 156 |
self.dialog({"type": "ext4", |
| 157 |
"mount_point": mount_point_one}) |
| 158 |
self.wait_mounted("ext4 filesystem") |
| 159 |
self.assert_in_configuration("/dev/vgroup0/lvol1", "fstab", "dir", mount_point_one) |
| 160 |
b.wait_in_text(self.card_desc("ext4 filesystem", "Mount point"), mount_point_one) |
| 161 |
|
| 162 |
# unmount it |
| 163 |
b.click(self.card_button("ext4 filesystem", "Unmount")) |
| 164 |
self.confirm() |
| 165 |
self.wait_not_mounted("ext4 filesystem") |
| 166 |
|
| 167 |
# shrink it, this time with a filesystem. |
| 168 |
b.click(self.card_button("LVM2 logical volume", "Shrink")) |
| 169 |
self.dialog({"size": 10}) |
| 170 |
|
| 171 |
# delete it |
| 172 |
self.click_card_dropdown("LVM2 logical volume", "Delete") |
| 173 |
self.confirm() |
| 174 |
b.wait_visible(self.card("LVM2 logical volumes")) |
| 175 |
b.wait_not_present(self.card_row("LVM2 logical volumes", name="lvol1")) |
| 176 |
self.assertEqual(m.execute(f"grep {mount_point_one} /etc/fstab || true"), "") |
| 177 |
|
| 178 |
# remove disk2 |
| 179 |
self.click_dropdown(self.card_row("LVM2 volume group", name=dev_2), "Remove") |
| 180 |
b.wait_not_present(self.card_row("LVM2 volume group", name=dev_2)) |
| 181 |
b.wait_in_text(self.card_desc("LVM2 volume group", "Capacity"), "50.3 MB") |
| 182 |
|
| 183 |
# loopback needs a explicit trigger... |
| 184 |
m.execute("udevadm trigger") |
| 185 |
|
| 186 |
# create thin pool and volume |
| 187 |
# the pool will be maximum size, 50.3 MB |
| 188 |
b.click(self.card_button("LVM2 logical volumes", "Create new logical volume")) |
| 189 |
self.dialog(expect={"size": 50.3}, |
| 190 |
values={"purpose": "pool", |
| 191 |
"name": "pool", |
| 192 |
"size": 38}) |
| 193 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 1), "pool") |
| 194 |
|
| 195 |
self.click_dropdown(self.card_row("LVM2 logical volumes", 1), |
| 196 |
"Create new thinly provisioned logical volume") |
| 197 |
self.dialog(expect={"name": "lvol0"}, |
| 198 |
values={"name": "thin", |
| 199 |
"size": 50}) |
| 200 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 2, 1), "thin") |
| 201 |
|
| 202 |
# add a disk and resize the pool |
| 203 |
b.click(self.card_button("LVM2 volume group", "Add physical volume")) |
| 204 |
self.dialog_wait_open() |
| 205 |
self.dialog_set_val('disks', {dev_2: True}) |
| 206 |
self.dialog_apply() |
| 207 |
self.dialog_wait_close() |
| 208 |
b.wait_visible(self.card_row("LVM2 volume group", name=dev_2)) |
| 209 |
# this is sometimes 96, sometimes 100 MB |
| 210 |
cap = self.card_desc("LVM2 volume group", "Capacity") |
| 211 |
b.wait_js_func("(sel => { const c = Number(ph_text(sel).split(' ')[0]); return c >= 96 && c <= 101 })", cap) |
| 212 |
|
| 213 |
self.click_card_row("LVM2 logical volumes", name="pool") |
| 214 |
b.click(self.card_button("Pool for thinly provisioned LVM2 logical volumes", "Grow")) |
| 215 |
self.dialog({"size": 70}) |
| 216 |
|
| 217 |
# use almost all of the pool by erasing the thin volume |
| 218 |
self.click_card_row("Thinly provisioned LVM2 logical volumes", 1) |
| 219 |
self.click_card_dropdown("Unformatted data", "Format") |
| 220 |
self.dialog({"erase.on": True, |
| 221 |
"type": "ext4", |
| 222 |
"mount_point": mount_point_thin}) |
| 223 |
self.assert_in_configuration("/dev/vgroup0/thin", "fstab", "dir", mount_point_thin) |
| 224 |
b.click(self.card_parent_link()) |
| 225 |
b.wait_text(self.card_row_col("Thinly provisioned LVM2 logical volumes", 1, 3), mount_point_thin) |
| 226 |
|
| 227 |
# Unmount to prevent unstable usage numbers from failing the pixel test |
| 228 |
self.click_dropdown(self.card_row("Thinly provisioned LVM2 logical volumes", 1), |
| 229 |
"Unmount") |
| 230 |
self.confirm() |
| 231 |
|
| 232 |
b.assert_pixels('body', "pool-page", |
| 233 |
ignore=[self.card_desc("Pool for thinly provisioned LVM2 logical volumes", "Data used"), |
| 234 |
self.card_desc("Pool for thinly provisioned LVM2 logical volumes", "Metadata used")]) |
| 235 |
|
| 236 |
# remove pool |
| 237 |
self.click_card_dropdown("Pool for thinly provisioned LVM2 logical volumes", "Delete") |
| 238 |
self.confirm() |
| 239 |
b.wait_visible(self.card("LVM2 logical volumes")) |
| 240 |
b.wait_not_present(self.card_row("LVM2 logical volumes", name="pool")) |
| 241 |
self.assertEqual(m.execute(f"grep {mount_point_thin} /etc/fstab || true"), "") |
| 242 |
|
| 243 |
# make another logical volume and format it, just so that we |
| 244 |
# can see whether deleting the volume group will clean it all |
| 245 |
# up. |
| 246 |
b.click(self.card_button("LVM2 logical volumes", "Create new logical volume")) |
| 247 |
self.dialog(expect={"name": "lvol0"}, |
| 248 |
values={"purpose": "block"}) |
| 249 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 1), "lvol0") |
| 250 |
self.click_card_row("LVM2 logical volumes", 1) |
| 251 |
self.click_card_dropdown("Unformatted data", "Format") |
| 252 |
self.dialog({"type": "ext4", |
| 253 |
"mount_point": mount_point_one}) |
| 254 |
self.assert_in_configuration("/dev/vgroup0/lvol0", "fstab", "dir", mount_point_one) |
| 255 |
b.click(self.card_parent_link()) |
| 256 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 2), "ext4 filesystem") |
| 257 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 3), mount_point_one) |
| 258 |
|
| 259 |
b.wait_visible(self.card_row_col("LVM2 logical volumes", 1, 4) + " .usage-bar[role=progressbar]") |
| 260 |
b.assert_pixels('body', "page", |
| 261 |
# Usage numbers are not stable and also cause |
| 262 |
# the table columns to shift. The usage bars |
| 263 |
# are not stable but are always the same size, |
| 264 |
# so it is good enough to ignore them. |
| 265 |
mock={self.card_desc("LVM2 volume group", "UUID"): "a12978a1-5d6e-f24f-93de-11789977acde", |
| 266 |
".usage-text": "---"}, |
| 267 |
ignore=[".usage-bar"]) |
| 268 |
|
| 269 |
# rename volume group |
| 270 |
b.click(self.card_desc_action("LVM2 volume group", "Name")) |
| 271 |
self.dialog_wait_open() |
| 272 |
# No warning about the rootfs should be displayed |
| 273 |
b.wait_visible("#dialog button.apply.pf-m-primary") |
| 274 |
b.wait_not_in_text("#dialog", "This volume group contains the root filesystem.") |
| 275 |
self.dialog_set_val("name", "vgroup1") |
| 276 |
self.dialog_apply() |
| 277 |
self.dialog_wait_close() |
| 278 |
|
| 279 |
# remove volume group |
| 280 |
self.click_card_dropdown("LVM2 volume group", "Delete") |
| 281 |
self.confirm() |
| 282 |
b.wait_visible(self.card("Storage")) |
| 283 |
b.wait_not_present(self.card_row("Storage", name="vgroup1")) |
| 284 |
self.assertEqual(m.execute(f"grep {mount_point_thin} /etc/fstab || true"), "") |
| 285 |
|
| 286 |
def testUnpartitionedSpace(self): |
| 287 |
m = self.machine |
| 288 |
b = self.browser |
| 289 |
|
| 290 |
self.login_and_go("/storage") |
| 291 |
|
| 292 |
disk1 = self.add_ram_disk() |
| 293 |
disk2 = self.add_loopback_disk() |
| 294 |
b.wait_visible(self.card_row("Storage", name=disk1)) |
| 295 |
b.wait_visible(self.card_row("Storage", name=disk2)) |
| 296 |
|
| 297 |
# Put a partition table on disk1 and disk2 |
| 298 |
m.execute(f'parted -s {disk1} mktable gpt') |
| 299 |
m.execute(f'parted -s {disk2} mktable gpt') |
| 300 |
|
| 301 |
# Create a volume group out of disk1 |
| 302 |
self.dialog_with_retry(trigger=lambda: self.click_devices_dropdown('Create LVM2 volume group'), |
| 303 |
expect=lambda: self.dialog_is_present('disks', disk1) and |
| 304 |
self.dialog_is_present('disks', "unpartitioned space on Linux"), |
| 305 |
values={"disks": {disk1: True}}) |
| 306 |
|
| 307 |
self.click_card_row("Storage", name="vgroup0") |
| 308 |
|
| 309 |
# Check the we are really using a partition on disk1 now |
| 310 |
b.wait_in_text(self.card_row_col("LVM2 volume group", 1, 2), "Partition - Linux") |
| 311 |
|
| 312 |
# Add the unused space of disk2 |
| 313 |
self.dialog_with_retry(trigger=lambda: b.click(self.card_button("LVM2 volume group", |
| 314 |
"Add physical volume")), |
| 315 |
expect=lambda: self.dialog_is_present( |
| 316 |
'disks', "unpartitioned space on " + disk2), |
| 317 |
values={"disks": {disk2: True}}) |
| 318 |
b.wait_in_text(self.card_row_col("LVM2 volume group", 1, 2), "Partition - Block device") |
| 319 |
|
| 320 |
def testSnapshots(self): |
| 321 |
m = self.machine |
| 322 |
b = self.browser |
| 323 |
|
| 324 |
self.login_and_go("/storage") |
| 325 |
|
| 326 |
disk = self.add_ram_disk(100) |
| 327 |
b.wait_visible(self.card_row("Storage", name=disk)) |
| 328 |
|
| 329 |
m.execute(f"vgcreate TEST {disk}") |
| 330 |
|
| 331 |
self.addCleanupVG("TEST") |
| 332 |
self.click_card_row("Storage", name="TEST") |
| 333 |
|
| 334 |
# Create a thinpool and a thin volume in it |
| 335 |
|
| 336 |
m.execute("lvcreate TEST --thinpool pool -L 10m") |
| 337 |
m.execute("lvcreate -T TEST/pool -n thin -V 30m") |
| 338 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 2, 1), "thin") |
| 339 |
|
| 340 |
# Create a logical volume and take a snapshot of it. We will |
| 341 |
# later check that the snapshot isn't shown. |
| 342 |
|
| 343 |
m.execute("lvcreate TEST -n lvol0 -L 10m") |
| 344 |
m.execute("lvcreate -s -n snap0 -L 10m TEST/lvol0") |
| 345 |
|
| 346 |
# the above lvol0 will be the new first entry in the table, so |
| 347 |
# TEST/thin moves to he third row |
| 348 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 1), "lvol0") |
| 349 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 2, 1), "pool") |
| 350 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 3, 1), "thin") |
| 351 |
|
| 352 |
# Take a snapshot of the thin volume and check that it appears |
| 353 |
|
| 354 |
self.click_dropdown(self.card_row("LVM2 logical volumes", 3), "Create snapshot") |
| 355 |
self.dialog({"name": "mysnapshot"}) |
| 356 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 3, 1), "mysnapshot") |
| 357 |
|
| 358 |
# Now check that the traditional snapshot is not shown. We do |
| 359 |
# this here to be sure that Cockpit is fully caught up and has |
| 360 |
# actually ignored it instead of just not having gotten around |
| 361 |
# to showing it. |
| 362 |
|
| 363 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 1), "lvol0") |
| 364 |
b.wait_not_present(self.card_row("LVM2 logical volumes", name="snap0")) |
| 365 |
|
| 366 |
def testRaid(self): |
| 367 |
b = self.browser |
| 368 |
|
| 369 |
self.skip_if_no_layouts() |
| 370 |
|
| 371 |
self.login_and_go("/storage") |
| 372 |
|
| 373 |
disk1 = self.add_ram_disk() |
| 374 |
disk2 = self.add_loopback_disk(name="loop10") |
| 375 |
disk3 = self.add_loopback_disk(name="loop11") |
| 376 |
disk4 = self.add_loopback_disk(name="loop12") |
| 377 |
|
| 378 |
# Make a volume group with four physical volumes |
| 379 |
|
| 380 |
with b.wait_timeout(60): |
| 381 |
self.dialog_with_retry(trigger=lambda: self.click_devices_dropdown("Create LVM2 volume group"), |
| 382 |
expect=lambda: (self.dialog_is_present('disks', disk1) and |
| 383 |
self.dialog_is_present('disks', disk2) and |
| 384 |
self.dialog_is_present('disks', disk3) and |
| 385 |
self.dialog_is_present('disks', disk4) and |
| 386 |
self.dialog_check({"name": "vgroup0"})), |
| 387 |
values={"disks": {disk1: True, |
| 388 |
disk2: True, |
| 389 |
disk3: True, |
| 390 |
disk4: True}}) |
| 391 |
|
| 392 |
self.addCleanupVG("vgroup0") |
| 393 |
|
| 394 |
# Make a raid5 on three PVs, using about half of each |
| 395 |
|
| 396 |
self.click_card_row("Storage", name="vgroup0") |
| 397 |
b.click(self.card_button("LVM2 logical volumes", "Create new logical volume")) |
| 398 |
self.dialog_wait_open() |
| 399 |
self.dialog_wait_val("name", "lvol0") |
| 400 |
self.dialog_set_val("purpose", "block") |
| 401 |
self.dialog_set_val("layout", "raid5") |
| 402 |
self.dialog_set_val("pvs", {disk1: False}) |
| 403 |
self.dialog_set_val("size", 40) |
| 404 |
b.assert_pixels("#dialog", "create-raid5") |
| 405 |
self.dialog_apply() |
| 406 |
self.dialog_wait_close() |
| 407 |
|
| 408 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 1), "lvol0") |
| 409 |
self.click_card_row("LVM2 logical volumes", 1) |
| 410 |
|
| 411 |
b.wait_text(self.card_desc("LVM2 logical volume", "Layout"), "Distributed parity (RAID 5)") |
| 412 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk2)) |
| 413 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk3)) |
| 414 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk4)) |
| 415 |
|
| 416 |
b.assert_pixels(self.card("LVM2 logical volume"), "raid5-card") |
| 417 |
|
| 418 |
# Make linear volume to fully use second PV |
| 419 |
|
| 420 |
b.click(self.card_parent_link()) |
| 421 |
b.click(self.card_button("LVM2 logical volumes", "Create new logical volume")) |
| 422 |
self.dialog(expect={"name": "lvol1"}, |
| 423 |
values={"purpose": "block", |
| 424 |
"layout": "linear", |
| 425 |
"pvs": {disk1: False, disk3: False, disk4: False}}) |
| 426 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 2, 1), "lvol1") |
| 427 |
self.click_card_row("LVM2 logical volumes", 2) |
| 428 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Physical volumes"), bn(disk2)) |
| 429 |
|
| 430 |
b.click(self.card_parent_link()) |
| 431 |
self.click_card_row("LVM2 logical volumes", 1) |
| 432 |
|
| 433 |
# Grow raid5 to about maximum |
| 434 |
b.click(self.card_button("LVM2 logical volume", "Grow")) |
| 435 |
self.dialog_wait_open() |
| 436 |
self.dialog_set_val("size", 80) |
| 437 |
b.assert_pixels("#dialog", "grow-raid5") |
| 438 |
self.dialog_apply() |
| 439 |
self.dialog_wait_close() |
| 440 |
|
| 441 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk1)) |
| 442 |
|
| 443 |
# Check that each PV is used exactly once. |
| 444 |
card = self.card("LVM2 logical volume") |
| 445 |
b.wait_count(card + f" .storage-stripe-pv-box-dev:contains('{bn(disk2)}')", 1) |
| 446 |
b.wait_count(card + f" .storage-stripe-pv-box-dev:contains('{bn(disk3)}')", 1) |
| 447 |
b.wait_count(card + f" .storage-stripe-pv-box-dev:contains('{bn(disk4)}')", 1) |
| 448 |
b.wait_count(card + f" .storage-stripe-pv-box-dev:contains('{bn(disk1)}')", 1) |
| 449 |
|
| 450 |
b.wait_not_in_text(card, "synchronized") |
| 451 |
b.assert_pixels(card, "raid5-card2") |
| 452 |
|
| 453 |
def testBrokenLinear(self): |
| 454 |
b = self.browser |
| 455 |
|
| 456 |
self.skip_if_no_layouts() |
| 457 |
|
| 458 |
self.login_and_go("/storage") |
| 459 |
|
| 460 |
disk1 = self.add_ram_disk() |
| 461 |
disk2 = self.add_loopback_disk() |
| 462 |
disk3 = self.add_loopback_disk() |
| 463 |
|
| 464 |
# Make a volume group with three physical volumes |
| 465 |
|
| 466 |
with b.wait_timeout(60): |
| 467 |
self.dialog_with_retry(trigger=lambda: self.click_devices_dropdown("Create LVM2 volume group"), |
| 468 |
expect=lambda: (self.dialog_is_present('disks', disk1) and |
| 469 |
self.dialog_is_present('disks', disk2) and |
| 470 |
self.dialog_is_present('disks', disk3) and |
| 471 |
self.dialog_check({"name": "vgroup0"})), |
| 472 |
values={"disks": {disk1: True, |
| 473 |
disk2: True, |
| 474 |
disk3: True}}) |
| 475 |
|
| 476 |
self.addCleanupVG("vgroup0") |
| 477 |
|
| 478 |
# Make a linear volume on two of them |
| 479 |
|
| 480 |
self.click_card_row("Storage", name="vgroup0") |
| 481 |
b.click(self.card_button("LVM2 logical volumes", "Create new logical volume")) |
| 482 |
self.dialog(expect={"name": "lvol0"}, |
| 483 |
values={"purpose": "block", |
| 484 |
"layout": "linear", |
| 485 |
"pvs": {disk2: False}}) |
| 486 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 1), "lvol0") |
| 487 |
self.click_card_row("LVM2 logical volumes", 1) |
| 488 |
|
| 489 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Physical volumes"), bn(disk1)) |
| 490 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Physical volumes"), bn(disk3)) |
| 491 |
|
| 492 |
# Kill one PV |
| 493 |
|
| 494 |
self.force_remove_disk(disk1) |
| 495 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Physical volumes"), |
| 496 |
"This logical volume has lost some of its physical volumes and can no longer be used.") |
| 497 |
b.wait_not_in_text(self.card_desc("LVM2 logical volume", "Physical volumes"), bn(disk1)) |
| 498 |
|
| 499 |
b.click(self.card_parent_link()) |
| 500 |
b.wait_in_text(".pf-v6-c-alert", "This volume group is missing some physical volumes.") |
| 501 |
b.wait_visible(self.card_desc_action("LVM2 volume group", "Name") + ":disabled") |
| 502 |
b.wait_visible(self.card_row("LVM2 logical volumes", name="lvol0") + ' .ct-icon-times-circle') |
| 503 |
|
| 504 |
# Dismiss alert, this will delete the volume |
| 505 |
|
| 506 |
b.click(".pf-v6-c-alert button:contains('Dismiss')") |
| 507 |
self.dialog_wait_open() |
| 508 |
b.wait_in_text("#dialog", "vgroup0/lvol0") |
| 509 |
self.dialog_apply() |
| 510 |
self.dialog_wait_close() |
| 511 |
|
| 512 |
b.wait_not_present(".pf-v6-c-alert") |
| 513 |
b.wait_not_present(self.card_row("LVM2 logical volumes", name="lvol0")) |
| 514 |
|
| 515 |
def testMaxLayoutSizes(self): |
| 516 |
b = self.browser |
| 517 |
|
| 518 |
self.skip_if_no_layouts() |
| 519 |
|
| 520 |
# Make sure that Cockpit gets the computation of the maximum |
| 521 |
# size right. |
| 522 |
|
| 523 |
self.login_and_go("/storage") |
| 524 |
|
| 525 |
disk1 = self.add_loopback_disk(name="loop10") |
| 526 |
disk2 = self.add_loopback_disk(name="loop11") |
| 527 |
disk3 = self.add_loopback_disk(name="loop12") |
| 528 |
disk4 = self.add_loopback_disk(name="loop13") |
| 529 |
disk5 = self.add_loopback_disk(name="loop14") |
| 530 |
disk6 = self.add_loopback_disk(name="loop15") |
| 531 |
|
| 532 |
with b.wait_timeout(60): |
| 533 |
self.dialog_with_retry(trigger=lambda: self.click_devices_dropdown("Create LVM2 volume group"), |
| 534 |
expect=lambda: (self.dialog_is_present('disks', disk1) and |
| 535 |
self.dialog_is_present('disks', disk2) and |
| 536 |
self.dialog_is_present('disks', disk3) and |
| 537 |
self.dialog_is_present('disks', disk4) and |
| 538 |
self.dialog_is_present('disks', disk5) and |
| 539 |
self.dialog_is_present('disks', disk6) and |
| 540 |
self.dialog_check({"name": "vgroup0"})), |
| 541 |
values={"disks": {disk1: True, |
| 542 |
disk2: True, |
| 543 |
disk3: True, |
| 544 |
disk4: True, |
| 545 |
disk5: True, |
| 546 |
disk6: True}}) |
| 547 |
self.addCleanupVG("vgroup0") |
| 548 |
self.click_card_row("Storage", name="vgroup0") |
| 549 |
|
| 550 |
b.wait_visible(self.card_row("LVM2 volume group", name=disk1)) |
| 551 |
b.wait_visible(self.card_row("LVM2 volume group", name=disk2)) |
| 552 |
b.wait_visible(self.card_row("LVM2 volume group", name=disk3)) |
| 553 |
b.wait_visible(self.card_row("LVM2 volume group", name=disk4)) |
| 554 |
b.wait_visible(self.card_row("LVM2 volume group", name=disk5)) |
| 555 |
b.wait_visible(self.card_row("LVM2 volume group", name=disk6)) |
| 556 |
|
| 557 |
def mb(size): |
| 558 |
if size < 100e6: |
| 559 |
return str(round(size / 1e6, 1)) + " MB" |
| 560 |
else: |
| 561 |
return str(round(size / 1e6)) + " MB" |
| 562 |
|
| 563 |
def test(layout, expected_size): |
| 564 |
b.click(self.card_button("LVM2 logical volumes", "Create new logical volume")) |
| 565 |
self.dialog_wait_open() |
| 566 |
self.dialog_wait_val("name", "lvol0") |
| 567 |
self.dialog_set_val("purpose", "block") |
| 568 |
self.dialog_set_val("layout", layout) |
| 569 |
if layout == "raid10": |
| 570 |
self.dialog_set_val("pvs", {disk6: False}) |
| 571 |
self.dialog_apply() |
| 572 |
self.dialog_wait_error("pvs", "an even number") |
| 573 |
self.dialog_set_val("pvs", {disk6: True}) |
| 574 |
self.dialog_apply() |
| 575 |
self.dialog_wait_close() |
| 576 |
|
| 577 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 1), "lvol0") |
| 578 |
self.click_card_row("LVM2 logical volumes", 1) |
| 579 |
|
| 580 |
field = "Physical volumes" if layout.startswith("linear") else "Stripes" |
| 581 |
|
| 582 |
b.wait_in_text(self.card_desc("LVM2 logical volume", field), bn(disk1)) |
| 583 |
b.wait_in_text(self.card_desc("LVM2 logical volume", field), bn(disk2)) |
| 584 |
b.wait_in_text(self.card_desc("LVM2 logical volume", field), bn(disk3)) |
| 585 |
b.wait_in_text(self.card_desc("LVM2 logical volume", field), bn(disk4)) |
| 586 |
b.wait_in_text(self.card_desc("LVM2 logical volume", field), bn(disk5)) |
| 587 |
b.wait_in_text(self.card_desc("LVM2 logical volume", field), bn(disk6)) |
| 588 |
|
| 589 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Size"), mb(expected_size)) |
| 590 |
|
| 591 |
self.click_card_dropdown("LVM2 logical volume", "Delete") |
| 592 |
with b.wait_timeout(60): |
| 593 |
self.confirm() |
| 594 |
b.wait_visible(self.card("LVM2 logical volumes")) |
| 595 |
b.wait_not_present(self.card_row("LVM2 logical volumes", name="lvol0")) |
| 596 |
|
| 597 |
ext_size = 4 * 1024 * 1024 |
| 598 |
pv_size = math.floor(50e6 / ext_size) * ext_size |
| 599 |
n_pvs = 6 |
| 600 |
|
| 601 |
test("linear", n_pvs * pv_size) |
| 602 |
test("raid0", n_pvs * pv_size) |
| 603 |
test("raid1", pv_size - ext_size) |
| 604 |
test("raid10", (n_pvs / 2) * (pv_size - ext_size)) |
| 605 |
test("raid5", (n_pvs - 1) * (pv_size - ext_size)) |
| 606 |
test("raid6", (n_pvs - 2) * (pv_size - ext_size)) |
| 607 |
|
| 608 |
def testMaxLayoutGrowth(self): |
| 609 |
b = self.browser |
| 610 |
|
| 611 |
self.skip_if_no_layouts() |
| 612 |
|
| 613 |
# Make sure that Cockpit gets the computation of the maximum |
| 614 |
# size right when growing a logical volume. |
| 615 |
|
| 616 |
self.login_and_go("/storage") |
| 617 |
|
| 618 |
disk1 = self.add_loopback_disk(name="loop10") |
| 619 |
disk2 = self.add_loopback_disk(name="loop11") |
| 620 |
disk3 = self.add_loopback_disk(name="loop12") |
| 621 |
disk4 = self.add_loopback_disk(name="loop13") |
| 622 |
disk5 = self.add_loopback_disk(name="loop14") |
| 623 |
disk6 = self.add_loopback_disk(name="loop15") |
| 624 |
|
| 625 |
with b.wait_timeout(60): |
| 626 |
self.dialog_with_retry(trigger=lambda: self.click_devices_dropdown("Create LVM2 volume group"), |
| 627 |
expect=lambda: (self.dialog_is_present('disks', disk1) and |
| 628 |
self.dialog_is_present('disks', disk2) and |
| 629 |
self.dialog_is_present('disks', disk3) and |
| 630 |
self.dialog_is_present('disks', disk4) and |
| 631 |
self.dialog_is_present('disks', disk5) and |
| 632 |
self.dialog_is_present('disks', disk6) and |
| 633 |
self.dialog_check({"name": "vgroup0"})), |
| 634 |
values={"disks": {disk1: True, |
| 635 |
disk2: True, |
| 636 |
disk3: True, |
| 637 |
disk4: True, |
| 638 |
disk5: True, |
| 639 |
disk6: True}}) |
| 640 |
self.addCleanupVG("vgroup0") |
| 641 |
self.click_card_row("Storage", name="vgroup0") |
| 642 |
|
| 643 |
b.wait_visible(self.card_row("LVM2 volume group", name=disk1)) |
| 644 |
b.wait_visible(self.card_row("LVM2 volume group", name=disk2)) |
| 645 |
b.wait_visible(self.card_row("LVM2 volume group", name=disk3)) |
| 646 |
b.wait_visible(self.card_row("LVM2 volume group", name=disk4)) |
| 647 |
b.wait_visible(self.card_row("LVM2 volume group", name=disk5)) |
| 648 |
b.wait_visible(self.card_row("LVM2 volume group", name=disk6)) |
| 649 |
|
| 650 |
def mb(size): |
| 651 |
if size < 100e6: |
| 652 |
return str(round(size / 1e6, 1)) + " MB" |
| 653 |
else: |
| 654 |
return str(round(size / 1e6)) + " MB" |
| 655 |
|
| 656 |
def test(layout, expected_size): |
| 657 |
b.click(self.card_button("LVM2 logical volumes", "Create new logical volume")) |
| 658 |
self.dialog(expect={"name": "lvol0"}, |
| 659 |
values={"purpose": "block", |
| 660 |
"layout": layout, |
| 661 |
"size": round(expected_size / 2e6)}) |
| 662 |
|
| 663 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 1), "lvol0") |
| 664 |
self.click_card_row("LVM2 logical volumes", 1) |
| 665 |
|
| 666 |
field = "Stripes" |
| 667 |
|
| 668 |
b.wait_in_text(self.card_desc("LVM2 logical volume", field), bn(disk1)) |
| 669 |
b.wait_in_text(self.card_desc("LVM2 logical volume", field), bn(disk2)) |
| 670 |
b.wait_in_text(self.card_desc("LVM2 logical volume", field), bn(disk3)) |
| 671 |
b.wait_in_text(self.card_desc("LVM2 logical volume", field), bn(disk4)) |
| 672 |
b.wait_in_text(self.card_desc("LVM2 logical volume", field), bn(disk5)) |
| 673 |
b.wait_in_text(self.card_desc("LVM2 logical volume", field), bn(disk6)) |
| 674 |
|
| 675 |
# Grow to max with default pvs |
| 676 |
b.click(self.card_button("LVM2 logical volume", "Grow")) |
| 677 |
self.dialog_wait_open() |
| 678 |
slider = self.dialog_field("size") + " .pf-v6-c-slider .pf-v6-c-slider__rail" |
| 679 |
width = b.call_js_func('(function (sel) { return ph_find(sel).offsetWidth; })', slider) |
| 680 |
b.mouse(slider, "click", width, 0) |
| 681 |
self.dialog_apply() |
| 682 |
self.dialog_wait_close() |
| 683 |
|
| 684 |
card = self.card("LVM2 logical volume") |
| 685 |
b.wait_count(card + f" .storage-stripe-pv-box-dev:contains('{bn(disk1)}')", 1) |
| 686 |
b.wait_count(card + f" .storage-stripe-pv-box-dev:contains('{bn(disk2)}')", 1) |
| 687 |
b.wait_count(card + f" .storage-stripe-pv-box-dev:contains('{bn(disk3)}')", 1) |
| 688 |
b.wait_count(card + f" .storage-stripe-pv-box-dev:contains('{bn(disk4)}')", 1) |
| 689 |
b.wait_count(card + f" .storage-stripe-pv-box-dev:contains('{bn(disk5)}')", 1) |
| 690 |
b.wait_count(card + f" .storage-stripe-pv-box-dev:contains('{bn(disk6)}')", 1) |
| 691 |
|
| 692 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Size"), mb(expected_size)) |
| 693 |
|
| 694 |
self.click_card_dropdown("LVM2 logical volume", "Delete") |
| 695 |
with b.wait_timeout(60): |
| 696 |
self.confirm() |
| 697 |
b.wait_visible(self.card("LVM2 logical volumes")) |
| 698 |
b.wait_not_present(self.card_row("LVM2 logical volumes", name="lvol0")) |
| 699 |
|
| 700 |
ext_size = 4 * 1024 * 1024 |
| 701 |
pv_size = math.floor(50e6 / ext_size) * ext_size |
| 702 |
n_pvs = 6 |
| 703 |
|
| 704 |
test("raid0", n_pvs * pv_size) |
| 705 |
test("raid1", pv_size - ext_size) |
| 706 |
test("raid10", (n_pvs / 2) * (pv_size - ext_size)) |
| 707 |
test("raid5", (n_pvs - 1) * (pv_size - ext_size)) |
| 708 |
test("raid6", (n_pvs - 2) * (pv_size - ext_size)) |
| 709 |
|
| 710 |
@testlib.skipImage("No targetd in Arch Linux", "arch") |
| 711 |
def testDegradation(self): |
| 712 |
b = self.browser |
| 713 |
|
| 714 |
self.skip_if_no_layouts() |
| 715 |
|
| 716 |
# Make one (very small) logical volume for each RAID type and |
| 717 |
# then break them. |
| 718 |
|
| 719 |
self.login_and_go("/storage") |
| 720 |
|
| 721 |
disk1 = self.add_targetd_loopback_disk(index=1, size=100) |
| 722 |
disk2 = self.add_targetd_loopback_disk(index=2, size=100) |
| 723 |
disk3 = self.add_targetd_loopback_disk(index=3, size=100) |
| 724 |
disk4 = self.add_targetd_loopback_disk(index=4, size=100) |
| 725 |
disk5 = self.add_targetd_loopback_disk(index=5, size=100) |
| 726 |
|
| 727 |
with b.wait_timeout(60): |
| 728 |
self.dialog_with_retry(trigger=lambda: self.click_devices_dropdown("Create LVM2 volume group"), |
| 729 |
expect=lambda: (self.dialog_is_present('disks', disk1) and |
| 730 |
self.dialog_is_present('disks', disk2) and |
| 731 |
self.dialog_is_present('disks', disk3) and |
| 732 |
self.dialog_is_present('disks', disk4) and |
| 733 |
self.dialog_is_present('disks', disk5) and |
| 734 |
self.dialog_check({"name": "vgroup0"})), |
| 735 |
values={"disks": {disk1: True, |
| 736 |
disk2: True, |
| 737 |
disk3: True, |
| 738 |
disk4: True, |
| 739 |
disk5: True}}) |
| 740 |
self.addCleanupVG("vgroup0") |
| 741 |
self.click_card_row("Storage", name="vgroup0") |
| 742 |
|
| 743 |
def create(row, layout, expected_name): |
| 744 |
b.click(self.card_button("LVM2 logical volumes", "Create new logical volume")) |
| 745 |
self.dialog_wait_open() |
| 746 |
self.dialog_wait_val("name", expected_name) |
| 747 |
self.dialog_set_val("layout", layout) |
| 748 |
if layout == "raid10": |
| 749 |
self.dialog_set_val("pvs", {disk5: False}) |
| 750 |
elif layout == "linear": |
| 751 |
self.dialog_set_val("pvs", {disk2: False, disk3: False, disk4: False, disk5: False}) |
| 752 |
self.dialog_set_val("size", 10) |
| 753 |
self.dialog_apply() |
| 754 |
self.dialog_wait_close() |
| 755 |
b.wait_text(self.card_row_col("LVM2 logical volumes", row, 1), expected_name) |
| 756 |
|
| 757 |
create(1, "linear", "lvol0") |
| 758 |
create(2, "raid0", "lvol1") |
| 759 |
create(3, "raid1", "lvol2") |
| 760 |
create(4, "raid10", "lvol3") |
| 761 |
create(5, "raid5", "lvol4") |
| 762 |
create(6, "raid6", "lvol5") |
| 763 |
|
| 764 |
def wait_msg(row, msg): |
| 765 |
self.click_card_row("LVM2 logical volumes", row) |
| 766 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Physical volumes" if row == 1 else "Stripes"), |
| 767 |
msg) |
| 768 |
b.click(self.card_parent_link()) |
| 769 |
|
| 770 |
def wait_partial(row): |
| 771 |
wait_msg(row, "This logical volume has lost some of its physical volumes and can no longer be used.") |
| 772 |
|
| 773 |
def wait_degraded(row): |
| 774 |
wait_msg(row, "This logical volume has lost some of its physical volumes but has not lost any data yet.") |
| 775 |
|
| 776 |
def wait_maybe_partial(row): |
| 777 |
wait_msg(row, "This logical volume has lost some of its physical volumes but might not have lost any data yet.") |
| 778 |
|
| 779 |
self.force_remove_disk(disk1) |
| 780 |
|
| 781 |
wait_partial(1) # linear is broken now |
| 782 |
wait_partial(2) # striped as well |
| 783 |
wait_degraded(3) # mirror is fine |
| 784 |
wait_degraded(4) # striped mirror as well |
| 785 |
wait_degraded(5) # raid5 and ... |
| 786 |
wait_degraded(6) # ... raid6 are doing their job |
| 787 |
|
| 788 |
self.force_remove_disk(disk2) |
| 789 |
|
| 790 |
wait_degraded(3) # mirror is still fine |
| 791 |
wait_maybe_partial(4) # striped mirror is not sure anymore |
| 792 |
wait_partial(5) # raid5 is now toast |
| 793 |
wait_degraded(6) # but raid6 still hangs on |
| 794 |
|
| 795 |
self.force_remove_disk(disk3) |
| 796 |
|
| 797 |
wait_degraded(3) # mirror is _still_ fine |
| 798 |
wait_partial(4) # striped mirror has lost more than half and is kaputt |
| 799 |
wait_partial(6) # raid6 is finally toast as well |
| 800 |
|
| 801 |
def testLvmOnLuks(self): |
| 802 |
b = self.browser |
| 803 |
m = self.machine |
| 804 |
|
| 805 |
self.skip_if_no_layouts() |
| 806 |
|
| 807 |
# Make sure that Cockpit either gets the layout description |
| 808 |
# right for encrypted physical volumes, or doesn't show any |
| 809 |
# layout (for older versions of UDisks2 without |
| 810 |
# https://github.com/storaged-project/udisks/pull/1206. |
| 811 |
|
| 812 |
self.login_and_go("/storage") |
| 813 |
|
| 814 |
disk = self.add_ram_disk() |
| 815 |
disk2 = self.add_loopback_disk() |
| 816 |
|
| 817 |
b.wait_visible(self.card_row("Storage", name=disk2)) |
| 818 |
m.execute(f"echo einszweidrei | cryptsetup luksFormat --pbkdf-memory 32768 {disk}") |
| 819 |
m.execute(f"echo einszweidrei | cryptsetup luksOpen {disk} dm-test") |
| 820 |
self.addCleanup(m.execute, "cryptsetup close dm-test || true") |
| 821 |
m.execute(f"vgcreate vgroup0 /dev/mapper/dm-test {disk2}") |
| 822 |
self.addCleanupVG("vgroup0") |
| 823 |
m.execute("lvcreate vgroup0 -n lvol0 -l100%FREE") |
| 824 |
|
| 825 |
self.click_card_row("Storage", name="lvol0") |
| 826 |
if (self.storaged_version < [2, 11]): |
| 827 |
# "Physical volumes" should not be displayed since we |
| 828 |
# might miss the encrypted ones dues to a bug in UDisks2. |
| 829 |
b.wait_text(self.card_desc("LVM2 logical volume", "Name"), "lvol0") |
| 830 |
b.wait_not_present(self.card_desc("LVM2 logical volume", "Physical volumes")) |
| 831 |
else: |
| 832 |
# We should have both disks listed as physical volumes |
| 833 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Physical volumes"), bn(disk)) |
| 834 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Physical volumes"), bn(disk2)) |
| 835 |
|
| 836 |
def testUnsupportedPartitions(self): |
| 837 |
b = self.browser |
| 838 |
m = self.machine |
| 839 |
|
| 840 |
self.login_and_go("/storage") |
| 841 |
|
| 842 |
dev_1 = self.add_ram_disk(100) |
| 843 |
m.execute(f"vgcreate vgroup0 {dev_1}") |
| 844 |
self.addCleanupVG("vgroup0") |
| 845 |
m.execute("lvcreate vgroup0 -n lvol0 -l100%FREE") |
| 846 |
m.execute("parted /dev/vgroup0/lvol0 -s mktable gpt mkpart primary ext2 1M 50M") |
| 847 |
self.addCleanup(m.execute, "parted /dev/vgroup0/lvol0 -s mktable gpt; wipefs -a /dev/vgroup0/lvol0") |
| 848 |
|
| 849 |
b.wait_text(self.card_row_col("Storage", row_name="lvol0", col_index=3), "GPT partitions") |
| 850 |
self.click_card_row("Storage", name="lvol0") |
| 851 |
b.wait_in_text(self.card("GPT partitions"), "Partitions are not supported on this block device.") |
| 852 |
|
| 853 |
# Neither the partition nor the free space should be offered |
| 854 |
# for creating new things. |
| 855 |
|
| 856 |
b.click(self.card_parent_link()) |
| 857 |
b.click(self.card_parent_link()) |
| 858 |
self.click_devices_dropdown("Create LVM2 volume group") |
| 859 |
b.wait_in_text("#dialog", "No disks are available") |
| 860 |
|
| 861 |
|
| 862 |
class TestStorageLvm2Destructive(storagelib.StorageCase): |
| 863 |
|
| 864 |
def can_do_layouts(self): |
| 865 |
return self.storaged_version >= [2, 10] |
| 866 |
|
| 867 |
def skip_if_no_layouts(self): |
| 868 |
if not self.can_do_layouts(): |
| 869 |
raise unittest.SkipTest("raid layouts not supported") |
| 870 |
|
| 871 |
# This is only "destructive" because of |
| 872 |
# |
| 873 |
# https://bugzilla.redhat.com/show_bug.cgi?id=2256432 |
| 874 |
# |
| 875 |
# We can't revocer the machine after that bug has hit us. |
| 876 |
|
| 877 |
def testRaidRepair(self): |
| 878 |
b = self.browser |
| 879 |
m = self.machine |
| 880 |
|
| 881 |
self.skip_if_no_layouts() |
| 882 |
|
| 883 |
self.login_and_go("/storage") |
| 884 |
|
| 885 |
disk1 = self.add_ram_disk() |
| 886 |
disk2 = self.add_loopback_disk(name="loop10") |
| 887 |
disk3 = self.add_loopback_disk(name="loop11") |
| 888 |
disk4 = self.add_loopback_disk(name="loop12") |
| 889 |
|
| 890 |
# Make a volume group with three physical volumes |
| 891 |
|
| 892 |
with b.wait_timeout(60): |
| 893 |
self.dialog_with_retry(trigger=lambda: self.click_devices_dropdown("Create LVM2 volume group"), |
| 894 |
expect=lambda: (self.dialog_is_present('disks', disk1) and |
| 895 |
self.dialog_is_present('disks', disk2) and |
| 896 |
self.dialog_is_present('disks', disk3) and |
| 897 |
self.dialog_check({"name": "vgroup0"})), |
| 898 |
values={"disks": {disk1: True, |
| 899 |
disk2: True, |
| 900 |
disk3: True}}) |
| 901 |
|
| 902 |
self.addCleanupVG("vgroup0") |
| 903 |
|
| 904 |
# Make a raid5 on the three PVs |
| 905 |
|
| 906 |
self.click_card_row("Storage", name="vgroup0") |
| 907 |
b.click(self.card_button("LVM2 logical volumes", "Create new logical volume")) |
| 908 |
self.dialog(expect={"name": "lvol0"}, |
| 909 |
values={"purpose": "block", |
| 910 |
"layout": "raid5"}) |
| 911 |
b.wait_text(self.card_row_col("LVM2 logical volumes", 1, 1), "lvol0") |
| 912 |
self.click_card_row("LVM2 logical volumes", 1) |
| 913 |
|
| 914 |
b.wait_text(self.card_desc("LVM2 logical volume", "Layout"), "Distributed parity (RAID 5)") |
| 915 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk1)) |
| 916 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk2)) |
| 917 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk3)) |
| 918 |
|
| 919 |
# Kill one PV |
| 920 |
|
| 921 |
self.force_remove_disk(disk1) |
| 922 |
|
| 923 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), |
| 924 |
"This logical volume has lost some of its physical volumes but has not lost any data yet.") |
| 925 |
b.wait_not_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk1)) |
| 926 |
|
| 927 |
b.click(self.card_parent_link()) |
| 928 |
b.wait_in_text(".pf-v6-c-alert", "This volume group is missing some physical volumes.") |
| 929 |
b.wait_visible(self.card_desc_action("LVM2 volume group", "Name") + ":disabled") |
| 930 |
b.wait_visible(self.card_row("LVM2 logical volumes", name="lvol0") + ' .ct-icon-exclamation-triangle') |
| 931 |
|
| 932 |
# Repair with fourth |
| 933 |
|
| 934 |
self.click_card_row("LVM2 logical volumes", 1) |
| 935 |
b.click(self.card_button("LVM2 logical volume", "Repair")) |
| 936 |
self.dialog_wait_open() |
| 937 |
b.wait_in_text("#dialog", "There is not enough space available") |
| 938 |
self.dialog_cancel() |
| 939 |
self.dialog_wait_close() |
| 940 |
|
| 941 |
b.click(self.card_parent_link()) |
| 942 |
b.click(self.card_button("LVM2 volume group", "Add physical volume")) |
| 943 |
self.dialog_wait_open() |
| 944 |
self.dialog_set_val('disks', {disk4: True}) |
| 945 |
self.dialog_apply() |
| 946 |
self.dialog_wait_close() |
| 947 |
b.wait_visible(self.card_row("LVM2 volume group", name=disk4)) |
| 948 |
self.click_card_row("LVM2 logical volumes", 1) |
| 949 |
|
| 950 |
b.click(self.card_button("LVM2 logical volume", "Repair")) |
| 951 |
self.dialog_wait_open() |
| 952 |
self.dialog_apply() |
| 953 |
self.dialog_wait_error("pvs", "An additional 46.1 MB must be selected") |
| 954 |
self.dialog_set_val("pvs", {disk4: True}) |
| 955 |
self.dialog_apply() |
| 956 |
try: |
| 957 |
self.dialog_wait_close() # wait for repair to finish |
| 958 |
except testlib.Error: |
| 959 |
# Produce evidence of lvconvert hanging, so that our maughties can match on it |
| 960 |
print(m.execute("for p in $(pgrep lvm); do cat /proc/$p/stack; done")) |
| 961 |
raise |
| 962 |
|
| 963 |
b.wait_not_in_text(self.card_desc("LVM2 logical volume", "Stripes"), |
| 964 |
"This logical volume has lost some") |
| 965 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Stripes"), bn(disk4)) |
| 966 |
|
| 967 |
# Dismiss alert |
| 968 |
|
| 969 |
b.click(self.card_parent_link()) |
| 970 |
b.wait_visible(self.card_row("LVM2 logical volumes", name="lvol0")) |
| 971 |
b.wait_not_present(self.card_row("LVM2 logical volumes", name="lvol0") + ' .ct-icon-exclamation-triangle') |
| 972 |
|
| 973 |
b.click(".pf-v6-c-alert button:contains('Dismiss')") |
| 974 |
self.dialog({}) |
| 975 |
b.wait_not_present(".pf-v6-c-alert") |
| 976 |
|
| 977 |
|
| 978 |
if __name__ == '__main__': |
| 979 |
testlib.test_main() |