def compare_capabilities(cache_device, core_device, cache, core, msg): if core is None: cli_messages.check_stderr_msg(msg, cli_messages.try_add_core_sector_size_mismatch) else: core_dev_sectors_num = \ disk_utils.get_size(core_device.get_device_id()) / disk_utils.get_block_size( core_device.get_device_id()) core_sectors_num = disk_utils.get_size(core.get_device_id()) / disk_utils.get_block_size( core.get_device_id()) if core_dev_sectors_num != core_sectors_num: TestRun.LOGGER.error( "Number of sectors in CAS device and attached core device is different.") cache.stop() return cas_capabilities = measure_capabilities(core) cache_dev_capabilities = measure_capabilities(cache_device) core_dev_capabilities = measure_capabilities(core_device) for (capability, method) in capabilities.items(): cas_val = cas_capabilities[capability] cache_val = cache_dev_capabilities[capability] core_val = core_dev_capabilities[capability] comparison_val = method(core_val, cache_val) if method is not None else core_val if comparison_val != cas_val: TestRun.LOGGER.error(f"Cas device {capability} is not set properly. Is: {cas_val}, " f"should be {comparison_val} (cache: {cache_val}, " f"core: {core_val})") continue TestRun.LOGGER.info(f"Cas device {capability} has proper value: {cas_val} " f"(cache: {cache_val}, core: {core_val})") cache.stop()
def compare_capabilities(cache_device, core_device, cache, core, msg): if core is None: cli_messages.check_stderr_msg( msg, cli_messages.try_add_core_sector_size_mismatch) else: core_dev_sectors_num = \ disk_utils.get_size(core_device.get_device_id()) / disk_utils.get_block_size( core_device.get_device_id()) core_sectors_num = disk_utils.get_size( core.get_device_id()) / disk_utils.get_block_size( core.get_device_id()) if core_dev_sectors_num != core_sectors_num: TestRun.LOGGER.error( "Number of sectors in CAS device and attached core device is different." ) cache.stop() return cas_capabilities = measure_capabilities(core) cache_dev_capabilities = measure_capabilities(cache_device) core_dev_capabilities = measure_capabilities(core_device) for (capability, method) in capabilities.items(): cas_val = cas_capabilities[capability] cache_val = cache_dev_capabilities[capability] core_val = core_dev_capabilities[capability] expected_val = method( core_val, cache_val) if method is not None else core_val if capability in ["max_sectors_kb", "max_hw_sectors_kb" ] and expected_val != cas_val: # On the newer kernels this trait is rounded. Instead of checking for # the current kernel version, assume that both values are acceptable. SECTOR_SHIFT = 9 lbs = measure_capabilities(core)["logical_block_size"] # The original uint is kb, but number of sectors is needed new_expected_val = expected_val * 2 round_val = lbs >> SECTOR_SHIFT new_expected_val -= new_expected_val % round_val # Restore the original unit expected_val = new_expected_val // 2 if expected_val != cas_val: TestRun.LOGGER.error( f"Cas device {capability} is not set properly. Is: {cas_val}, " f"should be {expected_val} (cache: {cache_val}, " f"core: {core_val})") continue TestRun.LOGGER.info( f"Cas device {capability} has proper value: {cas_val} " f"(cache: {cache_val}, core: {core_val})") cache.stop()
def discover_ssd_devices(block_devices, devices_res): ssd_count = int( TestRun.executor.run_expect_success( 'isdct show -intelssd | grep DevicePath | wc -l').stdout) for i in range(0, ssd_count): device_path = TestRun.executor.run_expect_success( f"isdct show -intelssd {i} | grep DevicePath").stdout.split()[2] dev = device_path.replace("/dev/", "") if dev not in block_devices: continue serial_number = TestRun.executor.run_expect_success( f"isdct show -intelssd {i} | grep SerialNumber").stdout.split( )[2].strip() if 'nvme' not in device_path: disk_type = 'sata' dev = find_sata_ssd_device_path(serial_number, block_devices) if dev is None: continue if "sg" in device_path: device_path = f"{dev}" elif TestRun.executor.run( f"isdct show -intelssd {i} | grep Optane").exit_code == 0: disk_type = 'optane' else: disk_type = 'nand' devices_res.append({ "type": disk_type, "path": resolve_to_by_id_link(device_path), "serial": serial_number, "blocksize": disk_utils.get_block_size(dev), "size": disk_utils.get_size(dev) }) block_devices.remove(dev)
def __init__(self, path): path = fs_utils.readlink(path) self.size = Size(disk_utils.get_size(path.replace('/dev/', '')), Unit.Byte) self.system_path = path self.filesystem = get_device_filesystem_type(path) self.mount_point = None
def discover_ssd_devices(block_devices, devices_res): ssd_count = int(get_command_output('isdct show -intelssd | grep DevicePath | wc -l')) for i in range(0, ssd_count): device_path = get_command_output(f"isdct show -intelssd {i} | grep DevicePath").split()[2] dev = device_path.replace('/dev/', '') serial_number = get_command_output( f"isdct show -intelssd {i} | grep SerialNumber").split()[2].strip() if 'nvme' not in device_path: disk_type = 'sata' dev = find_sata_ssd_device_path(serial_number, block_devices) if dev is None: continue if "sg" in device_path: device_path = f"/dev/{dev}" elif TestProperties.executor.execute( f"isdct show -intelssd {i} | grep Optane").exit_code == 0: disk_type = 'optane' else: disk_type = 'nand' devices_res.append({ "type": disk_type, "path": device_path, "serial": serial_number, "blocksize": disk_utils.get_block_size(dev), "size": disk_utils.get_size(dev)}) block_devices.remove(dev)
def discover_hdd_devices(block_devices, devices_res): for dev in block_devices: block_size = disk_utils.get_block_size(dev) if int(block_size) == 4096: disk_type = 'hdd4k' else: disk_type = 'hdd' devices_res.append({ "type": disk_type, "path": f"/dev/{dev}", "serial": get_command_output( f"sg_inq /dev/{dev} | grep 'Unit serial number'").split(': ')[1].strip(), "blocksize": block_size, "size": disk_utils.get_size(dev)}) block_devices.clear()
def discover_hdd_devices(block_devices, devices_res): for dev in block_devices: block_size = disk_utils.get_block_size(dev) if int(block_size) == 4096: disk_type = 'hdd4k' else: disk_type = 'hdd' devices_res.append({ "type": disk_type, "path": f"{resolve_to_by_id_link(dev)}", "serial": TestRun.executor.run_expect_success( f"sg_inq /dev/{dev} | grep -i 'serial number'").stdout.split( ': ')[1].strip(), "blocksize": block_size, "size": disk_utils.get_size(dev) }) block_devices.clear()
def __init__(self, path): self.size = Size(disk_utils.get_size(path.replace('/dev/', '')), Unit.Byte) self.system_path = path self.filesystem = None self.mount_point = None
def __init__(self, path): disk_utils.validate_dev_path(path) self.path = path self.size = Size(disk_utils.get_size(self.get_device_id()), Unit.Byte) self.filesystem = get_device_filesystem_type(self.get_device_id()) self.mount_point = None