From 87f68bb2f597563a5830d2f4bc47854231053f6c Mon Sep 17 00:00:00 2001 From: Katarzyna Lapinska Date: Fri, 15 Jan 2021 11:50:33 +0100 Subject: [PATCH] Fixes in tests and CAS API due to the change with by-id devices paths Signed-off-by: Katarzyna Lapinska --- test/functional/api/cas/cache.py | 3 +-- test/functional/api/cas/core.py | 6 +++--- test/functional/test-framework | 2 +- test/functional/tests/conftest.py | 9 +++++---- test/functional/tests/incremental_load/test_udev.py | 4 ++++ .../tests/initialize/test_clean_reboot.py | 2 -- .../tests/io_class/test_io_class_occupancy.py | 13 ++++++++----- .../tests/io_class/test_io_class_occupancy_load.py | 9 ++++----- .../io_class/test_io_class_occupancy_repart.py | 9 +++++++-- .../io_class/test_io_class_occupancy_resize.py | 10 ++++++---- .../recovery/test_recovery_all_options.py | 4 ---- .../recovery/test_recovery_flush_reset.py | 13 +++---------- 12 files changed, 42 insertions(+), 42 deletions(-) diff --git a/test/functional/api/cas/cache.py b/test/functional/api/cas/cache.py index 2798209..aa17e69 100644 --- a/test/functional/api/cas/cache.py +++ b/test/functional/api/cas/cache.py @@ -6,7 +6,6 @@ from api.cas.casadm_parser import * from api.cas.cli import * from api.cas.statistics import CacheStats, CacheIoClassStats -from storage_devices.device import Device from test_utils.os_utils import * @@ -24,7 +23,7 @@ class Cache: if output.exit_code == 0 and output.stdout.strip(): return output.stdout.split()[1] else: - raise Exception(f"There is no cache started on {self.cache_device.path}.") + raise Exception(f"There is no cache started on {self.cache_device.get_device_id()}.") def get_core_devices(self): return get_cores(self.cache_id) diff --git a/test/functional/api/cas/core.py b/test/functional/api/cas/core.py index b79157b..601975f 100644 --- a/test/functional/api/cas/core.py +++ b/test/functional/api/cas/core.py @@ -44,9 +44,9 @@ class Core(Device): output_lines = output.stdout.splitlines() for line in output_lines: split_line = line.split(',') - if (split_line[0] == "core" - and (split_line[2] == fs_utils.readlink(self.core_device.path) - or split_line[5] == self.path)): + if split_line[0] == "core" and ( + split_line[2] == os.path.join("/dev", self.core_device.get_device_id()) + or split_line[5] == self.path): return {"core_id": split_line[1], "core_device": split_line[2], "status": split_line[3], diff --git a/test/functional/test-framework b/test/functional/test-framework index 40c1eaa..0cef09b 160000 --- a/test/functional/test-framework +++ b/test/functional/test-framework @@ -1 +1 @@ -Subproject commit 40c1eaa5f9a16d563d906e0249b5c1416b723fae +Subproject commit 0cef09bf95a57c962aff5fc59603930142168c91 diff --git a/test/functional/tests/conftest.py b/test/functional/tests/conftest.py index c176d1b..659bdb4 100644 --- a/test/functional/tests/conftest.py +++ b/test/functional/tests/conftest.py @@ -188,18 +188,19 @@ def base_prepare(item): # stop only those RAIDs, which are comprised of test disks if all(map(lambda device: any(map(lambda disk_path: - disk_path in device.path, - [bd.path for bd in TestRun.dut.disks])), + disk_path in device.get_device_id(), + [bd.get_device_id() for bd in TestRun.dut.disks])), raid.array_devices)): raid.umount_all_partitions() raid.remove_partitions() raid.stop() for device in raid.array_devices: - Mdadm.zero_superblock(device.path) + Mdadm.zero_superblock(os.path.join('/dev', device.get_device_id())) + Udev.settle() for disk in TestRun.dut.disks: disk.umount_all_partitions() - Mdadm.zero_superblock(disk.path) + Mdadm.zero_superblock(os.path.join('/dev', disk.get_device_id())) TestRun.executor.run_expect_success("udevadm settle") disk.remove_partitions() create_partition_table(disk, PartitionTable.gpt) diff --git a/test/functional/tests/incremental_load/test_udev.py b/test/functional/tests/incremental_load/test_udev.py index 087d51b..32f38fc 100644 --- a/test/functional/tests/incremental_load/test_udev.py +++ b/test/functional/tests/incremental_load/test_udev.py @@ -137,7 +137,11 @@ def test_udev_raid_core(): cache_disk.create_partitions([Size(1, Unit.GibiByte)]) cache_dev = cache_disk.partitions[0] core_disk = TestRun.disks["core"] + core_disk.create_partitions([Size(2, Unit.GibiByte)]) + core_disk = core_disk.partitions[0] core_disk2 = TestRun.disks["core2"] + core_disk2.create_partitions([Size(2, Unit.GibiByte)]) + core_disk2 = core_disk2.partitions[0] with TestRun.step("Create RAID0 volume."): config = RaidConfiguration( diff --git a/test/functional/tests/initialize/test_clean_reboot.py b/test/functional/tests/initialize/test_clean_reboot.py index ddeda3b..102baca 100644 --- a/test/functional/tests/initialize/test_clean_reboot.py +++ b/test/functional/tests/initialize/test_clean_reboot.py @@ -38,7 +38,6 @@ def test_load_after_clean_shutdown(reboot_type, cache_mode, filesystem): cache_disk = TestRun.disks['cache'] cache_disk.create_partitions([Size(1, Unit.GibiByte)]) cache_dev = cache_disk.partitions[0] - cache_dev_link = cache_dev.get_device_link("/dev/disk/by-id") core_dev = TestRun.disks['core'] cache = casadm.start_cache(cache_dev, cache_mode, force=True) core = cache.add_core(core_dev) @@ -64,7 +63,6 @@ def test_load_after_clean_shutdown(reboot_type, cache_mode, filesystem): else: power_control = TestRun.plugin_manager.get_plugin('power_control') power_control.power_cycle() - cache_dev.path = cache_dev_link.get_target() with TestRun.step("Load cache."): casadm.load_cache(cache_dev) diff --git a/test/functional/tests/io_class/test_io_class_occupancy.py b/test/functional/tests/io_class/test_io_class_occupancy.py index e65d5ef..f2ed726 100644 --- a/test/functional/tests/io_class/test_io_class_occupancy.py +++ b/test/functional/tests/io_class/test_io_class_occupancy.py @@ -3,15 +3,18 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -from collections import namedtuple -from math import isclose - import pytest -from .io_class_common import * +from collections import namedtuple +from math import isclose +from api.cas.statistics import IoClassUsageStats +from api.cas import ioclass_config, casadm +from core.test_run import TestRun +from test_utils.size import Unit, Size +from tests.io_class.io_class_common import prepare, mountpoint, run_io_dir, \ + get_io_class_occupancy, ioclass_config_path, run_io_dir_read, get_io_class_usage from api.cas.cache_config import CacheMode, CacheLineSize from api.cas.ioclass_config import IoClass -from api.cas.statistics import IoClassUsageStats from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan from test_tools import fs_utils from test_tools.disk_utils import Filesystem diff --git a/test/functional/tests/io_class/test_io_class_occupancy_load.py b/test/functional/tests/io_class/test_io_class_occupancy_load.py index 45fc680..14f4a18 100644 --- a/test/functional/tests/io_class/test_io_class_occupancy_load.py +++ b/test/functional/tests/io_class/test_io_class_occupancy_load.py @@ -3,14 +3,13 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # +import pytest from collections import namedtuple from math import isclose - -import pytest - -from .io_class_common import * +from api.cas import ioclass_config, casadm +from tests.io_class.io_class_common import prepare, mountpoint, TestRun, Unit, \ + ioclass_config_path, run_io_dir, get_io_class_dirty, get_io_class_usage, get_io_class_occupancy from api.cas.cache_config import CacheMode, CacheLineSize -from api.cas.casadm_params import OutputFormat from api.cas.ioclass_config import IoClass from storage_devices.device import Device from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan diff --git a/test/functional/tests/io_class/test_io_class_occupancy_repart.py b/test/functional/tests/io_class/test_io_class_occupancy_repart.py index 5f2f97c..2eb7736 100644 --- a/test/functional/tests/io_class/test_io_class_occupancy_repart.py +++ b/test/functional/tests/io_class/test_io_class_occupancy_repart.py @@ -3,12 +3,17 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # +import pytest from collections import namedtuple from math import isclose -import pytest +from recordclass import recordclass -from .io_class_common import * +from api.cas import ioclass_config, casadm +from core.test_run_utils import TestRun +from test_utils.size import Unit, Size +from tests.io_class.io_class_common import prepare, mountpoint, ioclass_config_path, \ + get_io_class_occupancy, run_io_dir, run_io_dir_read from api.cas.cache_config import CacheMode, CacheLineSize from api.cas.ioclass_config import IoClass from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan diff --git a/test/functional/tests/io_class/test_io_class_occupancy_resize.py b/test/functional/tests/io_class/test_io_class_occupancy_resize.py index 84bc960..c647bbe 100644 --- a/test/functional/tests/io_class/test_io_class_occupancy_resize.py +++ b/test/functional/tests/io_class/test_io_class_occupancy_resize.py @@ -3,17 +3,19 @@ # SPDX-License-Identifier: BSD-3-Clause-Clear # -from recordclass import recordclass - import pytest - -from .io_class_common import * +from api.cas import ioclass_config, casadm +from core.test_run import TestRun +from test_utils.size import Unit, Size +from tests.io_class.io_class_common import mountpoint, prepare, ioclass_config_path, \ + get_io_class_occupancy, run_io_dir from api.cas.cache_config import CacheMode, CacheLineSize from api.cas.ioclass_config import IoClass from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan from test_tools import fs_utils from test_tools.disk_utils import Filesystem from test_utils.os_utils import sync, Udev +from recordclass import recordclass @pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand])) diff --git a/test/functional/tests/lazy_writes/recovery/test_recovery_all_options.py b/test/functional/tests/lazy_writes/recovery/test_recovery_all_options.py index 1154781..d5bb2ca 100644 --- a/test/functional/tests/lazy_writes/recovery/test_recovery_all_options.py +++ b/test/functional/tests/lazy_writes/recovery/test_recovery_all_options.py @@ -49,8 +49,6 @@ def test_recovery_all_options(cache_mode, cache_line_size, cleaning_policy, file core_disk.create_partitions([Size(2000, Unit.MebiByte)] * 2) cache_device = cache_disk.partitions[0] core_device = core_disk.partitions[0] - core_device_link = core_device.get_device_link("/dev/disk/by-id") - cache_device_link = cache_device.get_device_link("/dev/disk/by-id") test_file = File(os.path.join(mount_point, filename)) file_operation(test_file.full_path, pattern, ReadWrite.write) @@ -88,8 +86,6 @@ def test_recovery_all_options(cache_mode, cache_line_size, cleaning_policy, file core.unmount() TestRun.LOGGER.info(f"Number of dirty blocks in cache: {cache.get_dirty_blocks()}") power_cycle_dut() - cache_device.path = cache_device_link.get_target() - core_device.path = core_device_link.get_target() with TestRun.step("Try to start cache without load and force option."): try: diff --git a/test/functional/tests/lazy_writes/recovery/test_recovery_flush_reset.py b/test/functional/tests/lazy_writes/recovery/test_recovery_flush_reset.py index 1755f3d..be5f7b7 100644 --- a/test/functional/tests/lazy_writes/recovery/test_recovery_flush_reset.py +++ b/test/functional/tests/lazy_writes/recovery/test_recovery_flush_reset.py @@ -11,6 +11,7 @@ from core.test_run import TestRun from storage_devices.disk import DiskTypeSet, DiskType, DiskTypeLowerThan from test_tools.dd import Dd from test_tools.disk_utils import Filesystem +from test_tools.fs_utils import readlink from test_utils import os_utils from test_utils.os_utils import Udev from test_utils.output import CmdException @@ -43,8 +44,6 @@ def test_recovery_flush_reset_raw(cache_mode): core_disk.create_partitions([Size(16, Unit.GibiByte)] * 2) cache_device = cache_disk.partitions[0] core_device = core_disk.partitions[0] - core_device_link = core_device.get_device_link("/dev/disk/by-id") - cache_device_link = cache_device.get_device_link("/dev/disk/by-id") with TestRun.step("Create test files."): source_file, target_file = create_test_files(test_file_size) @@ -70,12 +69,10 @@ def test_recovery_flush_reset_raw(cache_mode): with TestRun.step("Hard reset DUT during data flushing."): power_cycle_dut(wait_for_flush_begin=True, core_device=core_device) - cache_device.path = cache_device_link.get_target() - core_device.path = core_device_link.get_target() with TestRun.step("Copy file from core and check if current md5sum is different than " "before restart."): - copy_file(source=core_device_link.get_target(), target=target_file.full_path, + copy_file(source=readlink(core_device.path), target=target_file.full_path, size=test_file_size, direct="iflag") compare_files(source_file, target_file, should_differ=True) @@ -92,7 +89,7 @@ def test_recovery_flush_reset_raw(cache_mode): with TestRun.step("Copy test file from core device to temporary location. " "Compare it with the first version – they should be the same."): - copy_file(source=core_device_link.get_target(), target=target_file.full_path, + copy_file(source=readlink(core_device.path), target=target_file.full_path, size=test_file_size, direct="iflag") compare_files(source_file, target_file) @@ -123,8 +120,6 @@ def test_recovery_flush_reset_fs(cache_mode, fs): core_disk.create_partitions([Size(16, Unit.GibiByte)] * 2) cache_device = cache_disk.partitions[0] core_device = core_disk.partitions[0] - core_device_link = core_device.get_device_link("/dev/disk/by-id") - cache_device_link = cache_device.get_device_link("/dev/disk/by-id") with TestRun.step(f"Create {fs} filesystem on core."): core_device.create_filesystem(fs) @@ -155,8 +150,6 @@ def test_recovery_flush_reset_fs(cache_mode, fs): with TestRun.step("Hard reset DUT during data flushing."): power_cycle_dut(True, core_device) - cache_device.path = cache_device_link.get_target() - core_device.path = core_device_link.get_target() with TestRun.step("Load cache."): cache = casadm.load_cache(cache_device)