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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652
|
import unittest
import os
import re
import time
from contextlib import contextmanager
import overrides_hack
from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, TestTags, tag_test, run_command, required_plugins
import gi
gi.require_version('GLib', '2.0')
gi.require_version('BlockDev', '3.0')
from gi.repository import GLib, BlockDev
@contextmanager
def wait_for_action(action_name):
try:
yield
finally:
time.sleep(2)
action = True
while action:
with open("/proc/mdstat", "r") as f:
action = action_name in f.read()
if action:
print("Sleeping")
time.sleep(1)
@required_plugins(("mdraid",))
class MDTest(unittest.TestCase):
requested_plugins = BlockDev.plugin_specs_from_names(("mdraid",))
@classmethod
def setUpClass(cls):
if not BlockDev.is_initialized():
BlockDev.init(cls.requested_plugins, None)
else:
BlockDev.reinit(cls.requested_plugins, True, None)
class MDNoDevTestCase(MDTest):
@tag_test(TestTags.NOSTORAGE)
def test_plugin_version(self):
self.assertEqual(BlockDev.get_plugin_soname(BlockDev.Plugin.MDRAID), "libbd_mdraid.so.3")
@tag_test(TestTags.NOSTORAGE)
def test_get_superblock_size(self):
"""Verify that superblock size si calculated properly"""
# 2 MiB for versions <= 1.0
self.assertEqual(BlockDev.md_get_superblock_size(2 * 1024**3, "0.9"), 2 * 1024**2)
self.assertEqual(BlockDev.md_get_superblock_size(2 * 1024**3, "1.0"), 2 * 1024**2)
# no version, "default" or > 1.0
self.assertEqual(BlockDev.md_get_superblock_size(256 * 1024**3, None), 128 * 1024**2)
self.assertEqual(BlockDev.md_get_superblock_size(128 * 1024**3, None), 128 * 1024**2)
self.assertEqual(BlockDev.md_get_superblock_size(64 * 1024**3, "default"), 64 * 1024**2)
self.assertEqual(BlockDev.md_get_superblock_size(63 * 1024**3, "default"), 32 * 1024**2)
self.assertEqual(BlockDev.md_get_superblock_size(10 * 1024**3, "1.1"), 8 * 1024**2)
self.assertEqual(BlockDev.md_get_superblock_size(1 * 1024**3, "1.1"), 1 * 1024**2)
self.assertEqual(BlockDev.md_get_superblock_size(1023 * 1024**2, "1.2"), 1 * 1024**2)
self.assertEqual(BlockDev.md_get_superblock_size(512 * 1024**2, "1.2"), 1 * 1024**2)
# unsupported version -> default superblock size
self.assertEqual(BlockDev.md_get_superblock_size(257 * 1024**2, version="unknown version"),
2 * 1024**2)
@tag_test(TestTags.NOSTORAGE)
def test_canonicalize_uuid(self):
"""Verify that UUID canonicalization works as expected"""
self.assertEqual(BlockDev.md_canonicalize_uuid("3386ff85:f5012621:4a435f06:1eb47236"),
"3386ff85-f501-2621-4a43-5f061eb47236")
with self.assertRaisesRegex(GLib.GError, r'malformed or invalid'):
BlockDev.md_canonicalize_uuid("malformed-uuid-example")
@tag_test(TestTags.NOSTORAGE)
def test_get_md_uuid(self):
"""Verify that getting UUID in MD RAID format works as expected"""
self.assertEqual(BlockDev.md_get_md_uuid("3386ff85-f501-2621-4a43-5f061eb47236"),
"3386ff85:f5012621:4a435f06:1eb47236")
with self.assertRaisesRegex(GLib.GError, r'malformed or invalid'):
BlockDev.md_get_md_uuid("malformed-uuid-example")
class MDTestCase(MDTest):
_sparse_size = 10 * 1024**2
_num_devices = 2
loop_devs = []
dev_files = []
def setUp(self):
if os.uname()[-1] == "i686":
self.skipTest("Skipping hanging MD RAID tests on i686")
self.addCleanup(self._clean_up)
for i in range(self._num_devices):
dev_file = create_sparse_tempfile("md_test", self._sparse_size)
self.dev_files.append(dev_file)
try:
loop_dev = create_lio_device(self.dev_files[i])
self.loop_devs.append(loop_dev)
except RuntimeError as e:
raise RuntimeError("Failed to setup loop device for testing: %s" % e)
def _clean_up(self):
try:
BlockDev.md_deactivate("bd_test_md")
except:
pass
try:
BlockDev.md_deactivate(BlockDev.md_node_from_name("bd_test_md"))
except:
pass
for i in range(self._num_devices):
try:
BlockDev.md_destroy(self.loop_devs[i])
except:
pass
try:
BlockDev.md_deactivate("bd_test_md")
except:
pass
try:
BlockDev.md_deactivate(BlockDev.md_node_from_name("bd_test_md"))
except:
pass
for i in range(self._num_devices):
try:
delete_lio_device(self.loop_devs[i])
except RuntimeError:
# just move on, we can do no better here
pass
os.unlink(self.dev_files[i])
self.dev_files.clear()
self.loop_devs.clear()
class MDTestCreateDeactivateDestroy(MDTestCase):
@tag_test(TestTags.SLOW, TestTags.CORE)
def test_create_deactivate_destroy(self):
"""Verify that it is possible to create, deactivate and destroy an MD RAID"""
with self.assertRaises(GLib.GError):
BlockDev.md_create("bd_test_md2", "raid1",
["/non/existing/device", self.loop_devs[1]],
0, None, None)
with wait_for_action("resync"):
succ = BlockDev.md_create("bd_test_md", "raid1",
[self.loop_devs[0], self.loop_devs[1]],
0, None, None)
self.assertTrue(succ)
# newly created array should be 'clean'
state = BlockDev.md_get_status("bd_test_md")
self.assertEqual(state, "clean")
succ = BlockDev.md_deactivate("bd_test_md")
self.assertTrue(succ)
succ = BlockDev.md_destroy(self.loop_devs[0])
self.assertTrue(succ)
succ = BlockDev.md_destroy(self.loop_devs[1])
self.assertTrue(succ)
class MDTestCreateWithChunkSize(MDTestCase):
@tag_test(TestTags.SLOW)
def test_create_with_chunk_size(self):
"""Verify that it is possible to create and MD RAID with specific chunk size """
with wait_for_action("resync"):
succ = BlockDev.md_create("bd_test_md", "raid0",
[self.loop_devs[0], self.loop_devs[1]],
0, None, None, 512 * 1024)
self.assertTrue(succ)
ex_data = BlockDev.md_examine(self.loop_devs[0])
self.assertEqual(ex_data.chunk_size, 512 * 1024)
succ = BlockDev.md_deactivate("bd_test_md")
self.assertTrue(succ)
succ = BlockDev.md_destroy(self.loop_devs[0])
self.assertTrue(succ)
succ = BlockDev.md_destroy(self.loop_devs[1])
self.assertTrue(succ)
class MDTestActivateDeactivate(MDTestCase):
@tag_test(TestTags.SLOW, TestTags.CORE)
def test_activate_deactivate(self):
"""Verify that it is possible to activate and deactivate an MD RAID"""
succ = BlockDev.md_create("bd_test_md", "raid0",
[self.loop_devs[0], self.loop_devs[1]],
0, None, None)
self.assertTrue(succ)
with self.assertRaises(GLib.GError):
BlockDev.md_deactivate("non_existing_md")
succ = BlockDev.md_deactivate("bd_test_md")
self.assertTrue(succ)
with self.assertRaises(GLib.GError):
BlockDev.md_activate("bd_test_md",
["/non/existing/device", self.loop_devs[1]], None)
succ = BlockDev.md_activate("bd_test_md",
[self.loop_devs[0], self.loop_devs[1]], None)
self.assertTrue(succ)
# try to activate again, should not fail, just no-op
succ = BlockDev.md_activate("bd_test_md",
[self.loop_devs[0], self.loop_devs[1]], None)
self.assertTrue(succ)
# try to deactivate using the node instead of name
succ = BlockDev.md_deactivate(BlockDev.md_node_from_name("bd_test_md"))
self.assertTrue(succ)
# try to activate using full path, not just the name
# (it should work too and blivet does this)
succ = BlockDev.md_activate("/dev/md/bd_test_md",
[self.loop_devs[0], self.loop_devs[1]], None)
self.assertTrue(succ)
succ = BlockDev.md_deactivate("bd_test_md")
self.assertTrue(succ)
md_info = BlockDev.md_examine(self.loop_devs[0])
self.assertTrue(md_info)
self.assertTrue(md_info.uuid)
# try to activate with UUID and array name
succ = BlockDev.md_activate("bd_test_md", [self.loop_devs[0], self.loop_devs[1]], md_info.uuid)
self.assertTrue(succ)
succ = BlockDev.md_deactivate("bd_test_md")
self.assertTrue(succ)
# try to activate by UUID only: should work with member devices specified
succ = BlockDev.md_activate(None, [self.loop_devs[0], self.loop_devs[1]], md_info.uuid)
self.assertTrue(succ)
succ = BlockDev.md_deactivate("bd_test_md")
self.assertTrue(succ)
# as well as without them
succ = BlockDev.md_activate(None, None, md_info.uuid)
self.assertTrue(succ)
succ = BlockDev.md_deactivate("bd_test_md")
self.assertTrue(succ)
class MDTestNominateDenominate(MDTestCase):
_num_devices = 3
@tag_test(TestTags.SLOW)
def test_nominate_denominate(self):
"""Verify that it is possible to nominate and denominate an MD RAID device"""
with wait_for_action("resync"):
succ = BlockDev.md_create("bd_test_md", "raid1",
[self.loop_devs[0], self.loop_devs[1], self.loop_devs[2]],
1, None, None)
self.assertTrue(succ)
with wait_for_action("resync"):
succ = BlockDev.md_denominate(self.loop_devs[0])
self.assertTrue(succ)
with wait_for_action("resync"):
succ = BlockDev.md_nominate(self.loop_devs[0])
self.assertTrue(succ)
with wait_for_action("resync"):
succ = BlockDev.md_denominate(self.loop_devs[0])
self.assertTrue(succ)
with wait_for_action("resync"):
succ = BlockDev.md_nominate(self.loop_devs[0])
self.assertTrue(succ)
with wait_for_action("resync"):
succ = BlockDev.md_deactivate(BlockDev.md_node_from_name("bd_test_md"))
self.assertTrue(succ)
class MDTestAddRemove(MDTestCase):
_num_devices = 3
@tag_test(TestTags.SLOW)
def test_add_remove(self):
"""Verify that it is possible to add a device to and remove from an MD RAID"""
# the MD array doesn't exist yet
with self.assertRaises(GLib.GError):
BlockDev.md_add("bd_test_md", self.loop_devs[2], 0, None)
with wait_for_action("resync"):
succ = BlockDev.md_create("bd_test_md", "raid1",
[self.loop_devs[0], self.loop_devs[1]],
0, None, None)
self.assertTrue(succ)
with self.assertRaises(GLib.GError):
BlockDev.md_add("bd_test_md", "/non/existing/device", 0, None)
# add the device as a spare
succ = BlockDev.md_add("bd_test_md", self.loop_devs[2], 0, None)
self.assertTrue(succ)
md_info = BlockDev.md_detail("bd_test_md")
self.assertEqual(md_info.raid_devices, 2)
self.assertEqual(md_info.spare_devices, 1)
with self.assertRaises(GLib.GError):
BlockDev.md_add("bd_test_md", self.loop_devs[2], 0, None)
# now remove the spare device (should be possible without --fail)
with wait_for_action("resync"):
succ = BlockDev.md_remove("bd_test_md", self.loop_devs[2], False, None)
self.assertTrue(succ)
md_info = BlockDev.md_detail("bd_test_md")
self.assertEqual(md_info.raid_devices, 2)
self.assertEqual(md_info.spare_devices, 0)
# remove one of the original devices (with --fail enabled)
with wait_for_action("resync"):
succ = BlockDev.md_remove("bd_test_md", self.loop_devs[1], True, None)
self.assertTrue(succ)
md_info = BlockDev.md_detail("bd_test_md")
self.assertEqual(md_info.raid_devices, 2)
self.assertEqual(md_info.active_devices, 1)
self.assertEqual(md_info.spare_devices, 0)
# now try to add it back -- it should be re-added automatically as
# a RAID device, not a spare device
with wait_for_action("recovery"):
succ = BlockDev.md_add("bd_test_md", self.loop_devs[1], 0, None)
self.assertTrue(succ)
md_info = BlockDev.md_detail("bd_test_md")
self.assertEqual(md_info.raid_devices, 2)
self.assertEqual(md_info.active_devices, 2)
self.assertEqual(md_info.spare_devices, 0)
class MDTestExamineDetail(MDTestCase):
_num_devices = 3
@tag_test(TestTags.SLOW)
def test_examine_detail(self):
"""Verify that it is possible to get info about an MD RAID"""
with wait_for_action("resync"):
succ = BlockDev.md_create("bd_test_md", "raid1",
[self.loop_devs[0], self.loop_devs[1], self.loop_devs[2]],
1, None, None)
self.assertTrue(succ)
ex_data = BlockDev.md_examine(self.loop_devs[0])
# test that we got something
self.assertTrue(ex_data)
# verify some known data
self.assertEqual(ex_data.device, "/dev/md/bd_test_md")
self.assertEqual(ex_data.level, "raid1")
self.assertEqual(ex_data.num_devices, 2)
self.assertTrue(ex_data.name.endswith("bd_test_md"))
self.assertEqual(len(ex_data.metadata), 3)
self.assertLess(ex_data.size, (10 * 1024**2))
self.assertTrue(re.match(r'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}', ex_data.uuid))
de_data = BlockDev.md_detail("bd_test_md")
# test that we got something
self.assertTrue(de_data)
# verify some known data
self.assertEqual(de_data.device, "/dev/md/bd_test_md")
self.assertTrue(de_data.name.endswith("bd_test_md"))
self.assertEqual(len(de_data.metadata), 3)
self.assertEqual(de_data.level, "raid1")
self.assertEqual(de_data.raid_devices, 2)
self.assertEqual(de_data.total_devices, 3)
self.assertEqual(de_data.spare_devices, 1)
self.assertLess(de_data.array_size, (10 * 1024**2))
self.assertLess(de_data.use_dev_size, (10 * 1024**2))
if "JENKINS_HOME" not in os.environ:
# XXX: for some reason the RAID is in "active sync" when tests run in
# Jenkins
self.assertTrue(de_data.clean)
self.assertTrue(re.match(r'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}', de_data.uuid))
self.assertEqual(ex_data.uuid, de_data.uuid)
# try to get detail data with some different raid specification
node = BlockDev.md_node_from_name("bd_test_md")
de_data = BlockDev.md_detail("/dev/md/bd_test_md")
self.assertTrue(de_data)
de_data = BlockDev.md_detail(node)
self.assertTrue(de_data)
de_data = BlockDev.md_detail("/dev/%s" % node)
self.assertTrue(de_data)
class MDTestNameNodeBijection(MDTestCase):
@tag_test(TestTags.SLOW)
def test_name_node_bijection(self):
"""Verify that MD RAID node and name match each other"""
with wait_for_action("resync"):
succ = BlockDev.md_create("bd_test_md", "raid1",
[self.loop_devs[0], self.loop_devs[1]],
0, None, None)
self.assertTrue(succ)
node = BlockDev.md_node_from_name("bd_test_md")
self.assertEqual(BlockDev.md_name_from_node(node), "bd_test_md")
self.assertEqual(BlockDev.md_name_from_node("/dev/" + node), "bd_test_md")
with self.assertRaises(GLib.GError):
node = BlockDev.md_node_from_name("made_up_md")
with self.assertRaisesRegex(GLib.GError, r'No name'):
BlockDev.md_name_from_node("no_such_node")
succ = BlockDev.md_deactivate("bd_test_md")
self.assertTrue(succ)
succ = BlockDev.md_destroy(self.loop_devs[0])
self.assertTrue(succ)
succ = BlockDev.md_destroy(self.loop_devs[1])
self.assertTrue(succ)
class MDTestSetBitmapLocation(MDTestCase):
@tag_test(TestTags.SLOW, TestTags.UNSTABLE)
def test_set_bitmap_location(self):
"""Verify we can change bitmap location for an existing MD array"""
with wait_for_action("resync"):
succ = BlockDev.md_create("bd_test_md", "raid1",
[self.loop_devs[0], self.loop_devs[1]],
0, None, "none")
self.assertTrue(succ)
loc = BlockDev.md_get_bitmap_location("bd_test_md")
self.assertEqual(loc, "none")
BlockDev.md_deactivate("bd_test_md")
with wait_for_action("resync"):
succ = BlockDev.md_create("bd_test_md", "raid1",
[self.loop_devs[0], self.loop_devs[1]],
0, None, "internal")
self.assertTrue(succ)
loc = BlockDev.md_get_bitmap_location("bd_test_md")
self.assertEqual(loc, "+8")
succ = BlockDev.md_set_bitmap_location("bd_test_md", "none")
self.assertTrue(succ)
loc = BlockDev.md_get_bitmap_location("bd_test_md")
self.assertEqual(loc, "none")
succ = BlockDev.md_set_bitmap_location("bd_test_md", "internal")
self.assertTrue(succ)
loc = BlockDev.md_get_bitmap_location("bd_test_md")
self.assertEqual(loc, "+8")
# test some different name specifications
# (need to switch between internal and none because setting the same
# location multiple times results in an error)
succ = BlockDev.md_set_bitmap_location("/dev/md/bd_test_md", "none")
self.assertTrue(succ)
node = BlockDev.md_node_from_name("bd_test_md")
self.assertIsNotNone(node)
succ = BlockDev.md_set_bitmap_location(node, "internal")
self.assertTrue(succ)
succ = BlockDev.md_set_bitmap_location("/dev/%s" % node, "none")
self.assertTrue(succ)
# get_bitmap_location should accept name, node or path
loc = BlockDev.md_get_bitmap_location(node)
self.assertEqual(loc, "none")
loc = BlockDev.md_get_bitmap_location("/dev/%s" % node)
self.assertEqual(loc, "none")
loc = BlockDev.md_get_bitmap_location("/dev/md/bd_test_md")
self.assertEqual(loc, "none")
class MDTestRequestSyncAction(MDTestCase):
@tag_test(TestTags.SLOW)
def test_request_sync_action(self):
"""Verify we can request sync action on an existing MD array"""
with wait_for_action("resync"):
succ = BlockDev.md_create("bd_test_md", "raid1",
[self.loop_devs[0], self.loop_devs[1]],
0, None, None)
self.assertTrue(succ)
with wait_for_action("check"):
succ = BlockDev.md_request_sync_action("bd_test_md", "check")
node = BlockDev.md_node_from_name("bd_test_md")
with open("/sys/block/%s/md/last_sync_action" % node) as f:
action = f.read().strip()
self.assertEqual(action, "check")
class MDTestDDFRAID(MDTestCase):
_sparse_size = 50 * 1024**2
def _clean_up(self):
try:
BlockDev.md_deactivate("bd_test_ddf")
except:
pass
try:
BlockDev.md_deactivate(BlockDev.md_node_from_name("bd_test_ddf"))
except:
pass
super(MDTestDDFRAID, self)._clean_up()
def test_examine_ddf_container(self):
succ = BlockDev.md_create("bd_test_md", "container",
[self.loop_devs[0], self.loop_devs[1]],
0, "ddf", None)
self.assertTrue(succ)
# we cannot create the array with libblockdev because we cannot pass the --raid-devices option
ret, _out, err = run_command("mdadm --create /dev/md/bd_test_ddf --run --level=raid0 --raid-devices=2 /dev/md/bd_test_md")
self.assertEqual(ret, 0, msg="Failed to create RAID for DDF test: %s" % err)
edata = BlockDev.md_examine(self.loop_devs[0])
self.assertIsNotNone(edata)
self.assertIsNotNone(edata.uuid)
self.assertEqual(edata.level, "container")
self.assertEqual(edata.metadata, "ddf")
# ddf container detail
ddata = BlockDev.md_detail("bd_test_md")
self.assertIsNotNone(ddata)
self.assertIsNotNone(ddata.uuid)
self.assertEqual(ddata.uuid, edata.uuid)
self.assertEqual(ddata.level, "container")
self.assertEqual(ddata.metadata, "ddf")
# array detail
ddata = BlockDev.md_detail("bd_test_ddf")
self.assertIsNotNone(ddata)
self.assertEqual(ddata.level, "raid0")
self.assertEqual(ddata.container, "/dev/md/bd_test_md")
class FakeMDADMutilTest(MDTest):
def setUp(self):
super().setUp()
# we need to force the check now to make sure that libblockdev doesn't use
# the fake tools below to try to get mdadm version
BlockDev.md_is_tech_avail(BlockDev.MDTech.MDRAID, 0)
# no setUp nor tearDown needed, we are gonna use fake utils
@tag_test(TestTags.NOSTORAGE)
def test_fw_raid_uppercase_examine(self):
"""Verify that md_examine works with output using "RAID" instead of "Raid" and other quirks """
with fake_utils("tests/fake_utils/mdadm_fw_RAID_examine"):
ex_data = BlockDev.md_examine("fake_dev")
self.assertEqual(ex_data.level, "container")
self.assertEqual(ex_data.num_devices, 1)
self.assertEqual(ex_data.uuid, "b42756a2-37e4-3e47-674b-d1dd6e822145")
self.assertEqual(ex_data.device, None)
@tag_test(TestTags.NOSTORAGE)
def test_no_metadata_examine(self):
"""Verify that md_examine works as expected with no metadata spec"""
# shouldn't raise any exception
with fake_utils("tests/fake_utils/mdadm_no_metadata_examine"):
ex_data = BlockDev.md_examine("fake_dev")
self.assertIs(ex_data.metadata, None)
@tag_test(TestTags.NOSTORAGE)
def test_fw_raid_migrating(self):
"""Verify that md_examine works when array is migrating ("foo <-- bar" values in output) """
with fake_utils("tests/fake_utils/mdadm_fw_RAID_examine_migrate"):
ex_data = BlockDev.md_examine("fake_dev")
self.assertEqual(ex_data.chunk_size, 128 * 1024)
@tag_test(TestTags.NOSTORAGE)
def test_mdadm_name_extra_info(self):
"""Verify that md_examine and md_detail work with extra MD RAID name info"""
with fake_utils("tests/fake_utils/mdadm_extra_name_stuff"):
ex_data = BlockDev.md_examine("fake_dev")
detail_data = BlockDev.md_detail("fake_dev")
self.assertEqual(ex_data.name, "localhost:fedora")
self.assertEqual(detail_data.name, "localhost:fedora")
class MDDepsTest(MDTest):
@tag_test(TestTags.NOSTORAGE)
def test_missing_dependencies(self):
"""Verify that checking for technology support works as expected"""
with fake_utils("tests/fake_utils/mdraid_low_version/"):
# too low version of mdsetup available
with self.assertRaisesRegex(GLib.GError, "Too low version of mdadm"):
BlockDev.md_is_tech_avail(BlockDev.MDTech.MDRAID, 0)
with fake_path(all_but="mdadm"):
# no mdadm available
with self.assertRaisesRegex(GLib.GError, "The 'mdadm' utility is not available"):
BlockDev.md_is_tech_avail(BlockDev.MDTech.MDRAID, 0)
|