test-conftest: More readable RAID teardown

Signed-off-by: Kamil Gierszewski <kamil.gierszewski@huawei.com>
This commit is contained in:
Kamil Gierszewski 2024-11-06 14:00:14 +01:00
parent b8ccf403f0
commit bf7711354d
No known key found for this signature in database

View File

@ -172,16 +172,13 @@ def base_prepare(item):
if len(TestRun.disks): if len(TestRun.disks):
for raid in raids: for raid in raids:
# stop only those RAIDs, which are comprised of test disks # stop only those RAIDs, which are comprised of test disks
if all(map(lambda device: test_run_disk_ids = {dev.device_id for dev in TestRun.disks.values()}
any(map(lambda disk_path: if filter(lambda dev: dev.device_id in test_run_disk_ids, raid.array_devices):
disk_path in device.device_id,
[bd.device_id for bd in TestRun.dut.disks])),
raid.array_devices)):
raid.remove_partitions() raid.remove_partitions()
raid.unmount() raid.unmount()
raid.stop() raid.stop()
for device in raid.array_devices: for device in raid.array_devices:
Mdadm.zero_superblock(posixpath.join('/dev', device.get_device_id())) Mdadm.zero_superblock(posixpath.join("/dev", device.get_device_id()))
Udev.settle() Udev.settle()
RamDisk.remove_all() RamDisk.remove_all()