test-conftest: Use cached device_ids + fix posix path

Signed-off-by: Kamil Gierszewski <kamil.gierszewski@huawei.com>
This commit is contained in:
Kamil Gierszewski 2024-11-04 14:00:13 +01:00
parent 4626d87471
commit ed85411750
No known key found for this signature in database
2 changed files with 21 additions and 22 deletions

View File

@ -174,8 +174,8 @@ def base_prepare(item):
# 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: if all(map(lambda device:
any(map(lambda disk_path: any(map(lambda disk_path:
disk_path in device.get_device_id(), disk_path in device.device_id,
[bd.get_device_id() for bd in TestRun.dut.disks])), [bd.device_id for bd in TestRun.dut.disks])),
raid.array_devices)): raid.array_devices)):
raid.remove_partitions() raid.remove_partitions()
raid.unmount() raid.unmount()

View File

@ -24,20 +24,19 @@ from test_utils.size import Size, Unit
@pytest.mark.require_plugin("scsi_debug") @pytest.mark.require_plugin("scsi_debug")
def test_device_capabilities(): def test_device_capabilities():
""" """
title: Test whether CAS device capabilities are properly set. title: Test whether CAS device capabilities are properly set.
description: | description: |
Test if CAS device takes into consideration differences between devices which are used to Test if CAS device takes into consideration differences between devices which are used to
create it. create it.
pass_criteria: pass_criteria:
- CAS device starts successfully using differently configured devices. - CAS device starts successfully using differently configured devices.
- CAS device capabilities are as expected. - CAS device capabilities are as expected.
""" """
core_device = TestRun.disks["core"]
core_device = TestRun.disks['core'] max_io_size_path = posixpath.join(
max_io_size_path = posixpath.join(disk_utils.get_sysfs_path(core_device.get_device_id()), disk_utils.get_sysfs_path(core_device.device_id), "queue/max_sectors_kb"
'queue/max_sectors_kb') )
default_max_io_size = fs_utils.read_file(max_io_size_path) default_max_io_size = fs_utils.read_file(max_io_size_path)
iteration_settings = [ iteration_settings = [
{"device": "SCSI-debug module", {"device": "SCSI-debug module",
"dev_size_mb": 1024, "logical_block_size": 512, "max_sectors_kb": 1024}, "dev_size_mb": 1024, "logical_block_size": 512, "max_sectors_kb": 1024},
@ -106,8 +105,8 @@ def create_scsi_debug_device(sector_size: int, physblk_exp: int, dev_size_mb=102
def prepare_cas_device(cache_device, core_device): def prepare_cas_device(cache_device, core_device):
cache = casadm.start_cache(cache_device, cache_line_size=CacheLineSize.LINE_64KiB, force=True) cache = casadm.start_cache(cache_device, cache_line_size=CacheLineSize.LINE_64KiB, force=True)
try: try:
cache_dev_bs = disk_utils.get_block_size(cache_device.get_device_id()) cache_dev_bs = disk_utils.get_block_size(cache_device.device_id)
core_dev_bs = disk_utils.get_block_size(core_device.get_device_id()) core_dev_bs = disk_utils.get_block_size(core_device.device_id)
core = cache.add_core(core_device) core = cache.add_core(core_device)
if cache_dev_bs > core_dev_bs: if cache_dev_bs > core_dev_bs:
TestRun.LOGGER.error( TestRun.LOGGER.error(
@ -147,8 +146,8 @@ capabilities = {"logical_block_size": max,
def measure_capabilities(dev): def measure_capabilities(dev):
dev_capabilities = {} dev_capabilities = {}
dev_id = dev.parent_device.get_device_id() if isinstance(dev, Partition) \ dev_id = dev.parent_device.device_id if isinstance(dev, Partition) \
else dev.get_device_id() else dev.device_id
for c in capabilities: for c in capabilities:
path = posixpath.join(disk_utils.get_sysfs_path(dev_id), 'queue', c) path = posixpath.join(disk_utils.get_sysfs_path(dev_id), 'queue', c)
command = f"cat {path}" command = f"cat {path}"
@ -167,10 +166,10 @@ def compare_capabilities(cache_device, core_device, cache, core, msg):
cli_messages.try_add_core_sector_size_mismatch) cli_messages.try_add_core_sector_size_mismatch)
else: else:
core_dev_sectors_num = \ core_dev_sectors_num = \
disk_utils.get_size(core_device.get_device_id()) / disk_utils.get_block_size( disk_utils.get_size(core_device.device_id) / disk_utils.get_block_size(
core_device.get_device_id()) core_device.device_id)
core_sectors_num = disk_utils.get_size(core.get_device_id()) / disk_utils.get_block_size( core_sectors_num = disk_utils.get_size(core.device_id) / disk_utils.get_block_size(
core.get_device_id()) core.device_id)
if core_dev_sectors_num != core_sectors_num: if core_dev_sectors_num != core_sectors_num:
TestRun.LOGGER.error( TestRun.LOGGER.error(
"Number of sectors in CAS device and attached core device is different.") "Number of sectors in CAS device and attached core device is different.")