diff --git a/test/functional/api/cas/cache.py b/test/functional/api/cas/cache.py index e12b77177..247d2ba9d 100644 --- a/test/functional/api/cas/cache.py +++ b/test/functional/api/cas/cache.py @@ -50,7 +50,7 @@ def __get_cache_device(self) -> Device | None: if not cache: return None - if cache["device_path"] is "-": + if cache["device_path"] == "-": return None return Device(path=cache["device_path"]) diff --git a/test/functional/api/cas/cas_packaging.py b/test/functional/api/cas/cas_packaging.py index ae90c5c05..9e784eafd 100644 --- a/test/functional/api/cas/cas_packaging.py +++ b/test/functional/api/cas/cas_packaging.py @@ -1,6 +1,6 @@ # # Copyright(c) 2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -49,7 +49,7 @@ def create( arch: str = "", source: bool = False, ): - TestRun.LOGGER.info(f"Creating Open CAS RPM packages") + TestRun.LOGGER.info("Creating Open CAS RPM packages") self.packages_dir = ( packages_dir or self.packages_dir or os.path.join(sources_dir, "packages") @@ -79,7 +79,7 @@ def create( arch: str = "", source: bool = False, ): - TestRun.LOGGER.info(f"Creating Open CAS DEB packages") + TestRun.LOGGER.info("Creating Open CAS DEB packages") self.packages_dir = ( packages_dir or self.packages_dir or os.path.join(sources_dir, "packages") diff --git a/test/functional/api/cas/cli.py b/test/functional/api/cas/cli.py index b933b65b6..0eb732e5b 100644 --- a/test/functional/api/cas/cli.py +++ b/test/functional/api/cas/cli.py @@ -447,7 +447,7 @@ def script_try_add_cmd(cache_id: str, core_dev: str, core_id: str) -> str: command = " --script --add-core --try-add" command += " --cache-id " + cache_id command += " --core-device " + core_dev - command += f" --core-id " + core_id + command += "--core-id " + core_id return casadm_bin + command diff --git a/test/functional/tests/512b/test_different_io_sizes_support.py b/test/functional/tests/512b/test_different_io_sizes_support.py index e3f1ee088..4cb18e39a 100644 --- a/test/functional/tests/512b/test_different_io_sizes_support.py +++ b/test/functional/tests/512b/test_different_io_sizes_support.py @@ -55,7 +55,7 @@ def test_support_different_io_size(cache_mode): core.create_filesystem(Filesystem.xfs) core.mount(mountpoint) - with TestRun.step(f"Run fio"): + with TestRun.step("Run fio"): bs_list = [Size(x, Unit.KibiByte) for x in block_sizes] fio = ( diff --git a/test/functional/tests/basic/test_basic.py b/test/functional/tests/basic/test_basic.py index 0e19843ba..e00d05609 100644 --- a/test/functional/tests/basic/test_basic.py +++ b/test/functional/tests/basic/test_basic.py @@ -51,7 +51,7 @@ def test_cas_version(): with TestRun.step("Compare cmd and file versions"): if not all(file_cas_version == cmd_cas_version for cmd_cas_version in cmd_cas_versions): - TestRun.LOGGER.error(f"Cmd and file versions doesn't match") + TestRun.LOGGER.error("Cmd and file versions doesn't match") @pytest.mark.CI diff --git a/test/functional/tests/cache_ops/test_attach_detach.py b/test/functional/tests/cache_ops/test_attach_detach.py index 718c24e23..9c172b2f7 100644 --- a/test/functional/tests/cache_ops/test_attach_detach.py +++ b/test/functional/tests/cache_ops/test_attach_detach.py @@ -14,7 +14,6 @@ from api.cas.cli import attach_cache_cmd from api.cas.cli_messages import check_stderr_msg, attach_with_existing_metadata from connection.utils.output import CmdException -from core.test_run import TestRun from core.test_run_utils import TestRun from storage_devices.disk import DiskTypeSet, DiskType, DiskTypeLowerThan from storage_devices.nullblk import NullBlk @@ -225,7 +224,7 @@ def test_stop_cache_during_attach(cache_mode): core_dev.create_partitions([Size(2, Unit.GibiByte)]) core_dev = core_dev.partitions[0] - with TestRun.step(f"Start cache and add core"): + with TestRun.step("Start cache and add core"): cache = casadm.start_cache(cache_dev, force=True, cache_mode=cache_mode) cache.add_core(core_dev) @@ -259,4 +258,4 @@ def _get_random_uniq_cache_line_size(cache_line_size) -> CacheLineSize: def _get_random_uniq_cache_mode(cache_mode) -> CacheMode: - return random.choice([c for c in list(CacheMode) if c is not cache_mode]) \ No newline at end of file + return random.choice([c for c in list(CacheMode) if c is not cache_mode]) diff --git a/test/functional/tests/cache_ops/test_dynamic_cache_mode_switching.py b/test/functional/tests/cache_ops/test_dynamic_cache_mode_switching.py index 9330ff94f..42e828df7 100644 --- a/test/functional/tests/cache_ops/test_dynamic_cache_mode_switching.py +++ b/test/functional/tests/cache_ops/test_dynamic_cache_mode_switching.py @@ -61,7 +61,7 @@ def test_cache_stop_and_load(cache_mode): core_dev = TestRun.disks["core"] core_dev.create_partitions([Size(2, Unit.GibiByte)]) - with TestRun.step(f"Disable udev"): + with TestRun.step("Disable udev"): Udev.disable() with TestRun.step(f"Start cache in {cache_mode[0]} mode"): diff --git a/test/functional/tests/cache_ops/test_multistream_seq_cutoff.py b/test/functional/tests/cache_ops/test_multistream_seq_cutoff.py index 2473762f2..9dce244ca 100644 --- a/test/functional/tests/cache_ops/test_multistream_seq_cutoff.py +++ b/test/functional/tests/cache_ops/test_multistream_seq_cutoff.py @@ -57,7 +57,7 @@ def test_multistream_seq_cutoff_functional(streams_number, threshold): with TestRun.step("Disable udev"): Udev.disable() - with TestRun.step(f"Start cache in Write-Back cache mode"): + with TestRun.step("Start cache in Write-Back cache mode"): cache_disk = TestRun.disks["cache"] core_disk = TestRun.disks["core"] cache = casadm.start_cache(cache_disk, CacheMode.WB, force=True) @@ -154,16 +154,16 @@ def test_multistream_seq_cutoff_stress_raw(streams_seq_rand): cache_disk.create_partitions([Size(1.5, Unit.GibiByte)]) - with TestRun.step(f"Disable udev"): + with TestRun.step("Disable udev"): Udev.disable() - with TestRun.step(f"Start cache in Write-Back mode and add core"): + with TestRun.step("Start cache in Write-Back mode and add core"): cache = casadm.start_cache( cache_dev=cache_disk.partitions[0], cache_mode=CacheMode.WB, force=True ) core = cache.add_core(core_disk) - with TestRun.step(f"Set seq-cutoff policy to always and threshold to 512KiB"): + with TestRun.step("Set seq-cutoff policy to always and threshold to 512KiB"): core.set_seq_cutoff_policy(SeqCutOffPolicy.always) core.set_seq_cutoff_threshold(Size(512, Unit.KibiByte)) diff --git a/test/functional/tests/cache_ops/test_seq_cutoff.py b/test/functional/tests/cache_ops/test_seq_cutoff.py index c6d542c1b..ae76a292c 100644 --- a/test/functional/tests/cache_ops/test_seq_cutoff.py +++ b/test/functional/tests/cache_ops/test_seq_cutoff.py @@ -312,7 +312,7 @@ def test_seq_cutoff_thresh(cache_line_size, io_dir, policy, verify_type): with TestRun.step("Disable udev"): Udev.disable() - with TestRun.step(f"Start cache and add core"): + with TestRun.step("Start cache and add core"): cache = casadm.start_cache( cache_dev=cache_part, force=True, @@ -396,7 +396,7 @@ def test_seq_cutoff_thresh_fill(cache_line_size, io_dir): with TestRun.step("Disable udev"): Udev.disable() - with TestRun.step(f"Start cache and add core"): + with TestRun.step("Start cache and add core"): cache = casadm.start_cache( cache_dev=cache_part, force=True, diff --git a/test/functional/tests/cli/test_cleaning_policy.py b/test/functional/tests/cli/test_cleaning_policy.py index 4ebfd005e..b0f47801e 100644 --- a/test/functional/tests/cli/test_cleaning_policy.py +++ b/test/functional/tests/cli/test_cleaning_policy.py @@ -9,7 +9,6 @@ from core.test_run_utils import TestRun from type_def.size import Size, Unit -from core.test_run import TestRun from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan from test_tools.fio.fio import Fio from test_tools.fio.fio_param import ReadWrite, IoEngine @@ -47,7 +46,7 @@ def test_cleaning_policy_change(): with TestRun.step("Disable udev"): Udev.disable() - with TestRun.step(f"Start cache in Write-Back mode and set cleaning policy to NOP"): + with TestRun.step("Start cache in Write-Back mode and set cleaning policy to NOP"): cache = casadm.start_cache(cache_dev, cache_mode=CacheMode.WB, force=True) cache.set_cleaning_policy(CleaningPolicy.nop) diff --git a/test/functional/tests/cli/test_cli_detached_cache.py b/test/functional/tests/cli/test_cli_detached_cache.py index ac6d98f2f..0eec58a22 100644 --- a/test/functional/tests/cli/test_cli_detached_cache.py +++ b/test/functional/tests/cli/test_cli_detached_cache.py @@ -233,7 +233,7 @@ def test_detached_cache_permitted_cli_management(): tested_cmd = cli.attach_cache_cmd(cache_device.path, str(cache.cache_id)) TestRun.LOGGER.info(f"Verify {tested_cmd}") TestRun.executor.run_expect_success(tested_cmd) - TestRun.LOGGER.info(f"Detach cache after successfully executed attach command") + TestRun.LOGGER.info("Detach cache after successfully executed attach command") cache.detach() tested_cmd = cli.stop_cmd(str(cache.cache_id)) diff --git a/test/functional/tests/cli/test_cli_standby.py b/test/functional/tests/cli/test_cli_standby.py index 7ad84b0ac..cfcd65b05 100644 --- a/test/functional/tests/cli/test_cli_standby.py +++ b/test/functional/tests/cli/test_cli_standby.py @@ -371,7 +371,7 @@ def test_activate_without_detach(): with TestRun.step("Verify if cache is in standby state after failed activation"): caches = casadm_parser.get_caches() if len(caches) < 1: - TestRun.LOGGER.error(f'Cache not present in system') + TestRun.LOGGER.error("Cache not present in system") else: cache_status = caches[0].get_status() if cache_status != CacheStatus.standby: @@ -453,7 +453,7 @@ def test_activate_neg_cache_line_size(): with TestRun.step("Detach standby cache instance"): standby_cache.standby_detach() - with TestRun.step(f"Copy changed metadata to the standby instance"): + with TestRun.step("Copy changed metadata to the standby instance"): Dd().input(md_dump.full_path).output(standby_cache_dev.path).run() sync() @@ -635,7 +635,7 @@ def test_standby_activate_with_corepool(): cache_line_size=cache_line_size, force=True) - with TestRun.step(f"Copy changed metadata to the standby instance"): + with TestRun.step("Copy changed metadata to the standby instance"): Dd().input(active_cache_dev.path).output(f"/dev/{cache_exp_obj_name}").run() with TestRun.step("Detach standby cache instance"): diff --git a/test/functional/tests/cli/test_manual_flush.py b/test/functional/tests/cli/test_manual_flush.py index 4b1b9dc60..6ea4782c0 100644 --- a/test/functional/tests/cli/test_manual_flush.py +++ b/test/functional/tests/cli/test_manual_flush.py @@ -10,7 +10,6 @@ from core.test_run_utils import TestRun from storage_devices.device import Device from type_def.size import Size, Unit -from core.test_run import TestRun from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan from test_tools.fio.fio import Fio from test_tools.fio.fio_param import ReadWrite, IoEngine diff --git a/test/functional/tests/cli/test_seq_cutoff_settings.py b/test/functional/tests/cli/test_seq_cutoff_settings.py index f76b94a1e..687f718b9 100644 --- a/test/functional/tests/cli/test_seq_cutoff_settings.py +++ b/test/functional/tests/cli/test_seq_cutoff_settings.py @@ -130,9 +130,9 @@ def test_seq_cutoff_set_get_policy_cache(policy): cache.set_seq_cutoff_policy(policy) for i in TestRun.iteration(range(0, len(cores)), "Verifying if proper policy was set"): - with TestRun.step(f"Check if proper sequential cutoff policy was set for core"): + with TestRun.step("Check if proper sequential cutoff policy was set for core"): if cores[i].get_seq_cut_off_policy() != policy: - TestRun.fail(f"Wrong core sequential cutoff policy: " + TestRun.fail("Wrong core sequential cutoff policy: " f"{cores[i].get_seq_cut_off_policy()} " f"should be {policy}") @@ -186,7 +186,7 @@ def test_seq_cutoff_policy_load(): enumerate(cores[:-1]), "Check if proper policies have been loaded" ): - with TestRun.step(f"Check if proper sequential cutoff policy was loaded"): + with TestRun.step("Check if proper sequential cutoff policy was loaded"): if cores[i].get_seq_cut_off_policy() != policies[i]: TestRun.fail(f"Wrong sequential cutoff policy loaded: " f"{cores[i].get_seq_cut_off_policy()} " @@ -239,8 +239,8 @@ def test_seq_cutoff_set_invalid_threshold(threshold): not in output.stderr: TestRun.fail("Command succeeded (should fail)!") - with TestRun.step(f"Setting cache sequential cutoff threshold " - f"to value passed as a float"): + with TestRun.step("Setting cache sequential cutoff threshold " + "to value passed as a float"): command = set_param_cutoff_cmd( cache_id=str(cache.cache_id), core_id=str(core.core_id), threshold=str(_threshold.get_value(Unit.KiloByte))) diff --git a/test/functional/tests/conftest.py b/test/functional/tests/conftest.py index dbb560e81..8ffa1e252 100644 --- a/test/functional/tests/conftest.py +++ b/test/functional/tests/conftest.py @@ -212,9 +212,9 @@ def base_prepare(item): create_partition_table(disk, PartitionTable.gpt) TestRun.usr.already_updated = True - TestRun.LOGGER.add_build_info(f"Commit hash:") + TestRun.LOGGER.add_build_info("Commit hash:") TestRun.LOGGER.add_build_info(f"{git.get_current_commit_hash()}") - TestRun.LOGGER.add_build_info(f"Commit message:") + TestRun.LOGGER.add_build_info("Commit message:") TestRun.LOGGER.add_build_info(f"{git.get_current_commit_message()}") diff --git a/test/functional/tests/data_integrity/test_data_integrity_12h.py b/test/functional/tests/data_integrity/test_data_integrity_12h.py index 179c0f43b..24e34b4d5 100644 --- a/test/functional/tests/data_integrity/test_data_integrity_12h.py +++ b/test/functional/tests/data_integrity/test_data_integrity_12h.py @@ -1,6 +1,6 @@ # # Copyright(c) 2019-2021 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -57,9 +57,9 @@ def prepare(cache_mode): cache_device = cache_device.partitions[0] core_device = core_device.partitions[0] - TestRun.LOGGER.info(f"Starting cache") + TestRun.LOGGER.info("Starting cache") cache = casadm.start_cache(cache_device, cache_mode, force=True) - TestRun.LOGGER.info(f"Adding core device") + TestRun.LOGGER.info("Adding core device") core = casadm.add_core(cache, core_dev=core_device) return cache, core diff --git a/test/functional/tests/data_integrity/test_data_integrity_unplug.py b/test/functional/tests/data_integrity/test_data_integrity_unplug.py index a1bd03239..93a758aac 100644 --- a/test/functional/tests/data_integrity/test_data_integrity_unplug.py +++ b/test/functional/tests/data_integrity/test_data_integrity_unplug.py @@ -271,7 +271,7 @@ def gen_csums(dev_path, seqno, pattern, csums, csums_rev): for j in range(num_jobs): for b in range(job_workset_blocks): - if pattern[j][b] != -1 and not pattern[j][b] in csums[j]: + if pattern[j][b] != -1 and pattern[j][b] not in csums[j]: csums[j][pattern[j][b]] = cs[j][b] csums_rev[cs[j][b]] = get_data_name(j, b, pattern[j][b]) diff --git a/test/functional/tests/example/example_test.py b/test/functional/tests/example/example_test.py index fac56cc62..c8160feaa 100644 --- a/test/functional/tests/example/example_test.py +++ b/test/functional/tests/example/example_test.py @@ -1,6 +1,6 @@ # # Copyright(c) 2019-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -293,4 +293,4 @@ def test_lvm_example(): if lvm not in lvms: TestRun.LOGGER.error(f"Created LVM {lvm.volume_name} not discovered in system!") - TestRun.LOGGER.info(f"Created LVMs present in the system.") + TestRun.LOGGER.info("Created LVMs present in the system.") diff --git a/test/functional/tests/failover_standby/test_cache_activation_perf.py b/test/functional/tests/failover_standby/test_cache_activation_perf.py index 59ad23021..a2b54f7f2 100644 --- a/test/functional/tests/failover_standby/test_cache_activation_perf.py +++ b/test/functional/tests/failover_standby/test_cache_activation_perf.py @@ -1,6 +1,6 @@ # # Copyright(c) 2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # from datetime import timedelta, datetime @@ -66,7 +66,7 @@ def test_cache_activation_time(prefill): cache.set_seq_cutoff_policy(SeqCutOffPolicy.never) cache.set_cleaning_policy(CleaningPolicy.nop) - with TestRun.step(f"Pre-filling the cache with dirty data to target threshold"): + with TestRun.step("Pre-filling the cache with dirty data to target threshold"): if prefill is True: TestRun.LOGGER.info(f"Target prefill threshold: {prefill_threshold}%") @@ -85,7 +85,7 @@ def test_cache_activation_time(prefill): .run() ) else: - TestRun.LOGGER.info(f"Target prefill threshold: 0% - prefill skipped") + TestRun.LOGGER.info("Target prefill threshold: 0% - prefill skipped") with TestRun.step("Check usage statistics after pre-fill"): stats = cache.get_statistics(percentage_val=True) @@ -116,7 +116,7 @@ def test_cache_activation_time(prefill): cache_id=current_cache_id) with TestRun.step("verify cache exported object has appeared"): - output = TestRun.executor.run_expect_success(f"ls -la /dev/ | grep cas-cache-1") + output = TestRun.executor.run_expect_success("ls -la /dev/ | grep cas-cache-1") if output.stdout[0] != "b": TestRun.fail("The cache exported object is not a block device") @@ -135,7 +135,7 @@ def test_cache_activation_time(prefill): standby_cache.standby_detach() with TestRun.step("Verify exp. obj. disappeared"): - TestRun.executor.run_expect_fail(f"ls -la /dev/ | grep cas-cache-1") + TestRun.executor.run_expect_fail("ls -la /dev/ | grep cas-cache-1") with TestRun.step("Activate passive cache and measure the activation time"): start_time = datetime.now() diff --git a/test/functional/tests/failover_standby/test_failover_advanced.py b/test/functional/tests/failover_standby/test_failover_advanced.py index 486dc9be0..2c29c6658 100644 --- a/test/functional/tests/failover_standby/test_failover_advanced.py +++ b/test/functional/tests/failover_standby/test_failover_advanced.py @@ -1,6 +1,6 @@ # # Copyright(c) 2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -278,7 +278,7 @@ def test_failover_during_background_cleaning(cache_mode, cls, cleaning_policy, n if dirty_after_cleaning < 20: TestRun.LOGGER.exception("Not enough dirty data") - with TestRun.step(f"Power off the main DUT"), TestRun.use_dut(primary_node): + with TestRun.step("Power off the main DUT"), TestRun.use_dut(primary_node): timed_async_power_cycle() with TestRun.step("Stop cache DRBD on the secondary node"), TestRun.use_dut(secondary_node): @@ -529,7 +529,7 @@ def test_failover_during_dirty_flush(cache_mode, cls, num_iterations): if dirty_after_cleaning < 20: TestRun.LOGGER.exception("Not enough dirty data") - with TestRun.step(f"Power off the main DUT"), TestRun.use_dut(primary_node): + with TestRun.step("Power off the main DUT"), TestRun.use_dut(primary_node): timed_async_power_cycle() with TestRun.step("Stop cache DRBD on the secondary node"), TestRun.use_dut(secondary_node): @@ -819,7 +819,7 @@ def test_failover_during_io_with_eviction(cache_mode, cls, cleaning_policy, num_ TestRun.LOGGER.info(f"Read miss change: {read_misses_before} -> {read_misses_after}") if read_misses_after <= read_misses_before: - TestRun.LOGGER.exception(f"Expected read misses increase was not registered") + TestRun.LOGGER.exception("Expected read misses increase was not registered") with TestRun.step( "Verify pass-through I/O statistic is not being incremented" @@ -830,9 +830,9 @@ def test_failover_during_io_with_eviction(cache_mode, cls, cleaning_policy, num_ TestRun.LOGGER.info(f"PT reads requests change: {pt_reads_before} -> {pt_reads_after}") if pt_reads_before != pt_reads_after: - TestRun.LOGGER.exception(f"Unexpected increase in PT statistics") + TestRun.LOGGER.exception("Unexpected increase in PT statistics") - with TestRun.step(f"Power off the main DUT"), TestRun.use_dut(primary_node): + with TestRun.step("Power off the main DUT"), TestRun.use_dut(primary_node): timed_async_power_cycle() with TestRun.step("Stop cache DRBD on the secondary node"), TestRun.use_dut(secondary_node): @@ -931,7 +931,7 @@ def test_failover_io_long(cls, cleaning_policy, num_iterations): prepare_devices(TestRun.duts) primary_node, secondary_node = TestRun.duts - with TestRun.step(f"Create mount point"): + with TestRun.step("Create mount point"): mountpoint = "/tmp/standby_io_test_mount_point" for dut in TestRun.duts: with TestRun.use_dut(secondary_node): @@ -999,7 +999,7 @@ def test_failover_io_long(cls, cleaning_policy, num_iterations): ): core.create_filesystem(Filesystem.xfs) - with TestRun.step(f"Mount file system"), TestRun.use_dut(primary_node): + with TestRun.step("Mount file system"), TestRun.use_dut(primary_node): core.mount(mountpoint) with TestRun.step("Prepare fio command"), TestRun.use_dut(primary_node): @@ -1043,12 +1043,12 @@ def test_failover_io_long(cls, cleaning_policy, num_iterations): with TestRun.step("Calculate checksum of fio test file(s)"), TestRun.use_dut(primary_node): checksum1 = File(file_path).md5sum() - with TestRun.step(f"Switch back to the WB cache mode without flush"), TestRun.use_dut( + with TestRun.step("Switch back to the WB cache mode without flush"), TestRun.use_dut( primary_node ): primary_node.cache.set_cache_mode(CacheMode.WB, flush=False) - with TestRun.step(f"Power off the main DUT"), TestRun.use_dut(primary_node): + with TestRun.step("Power off the main DUT"), TestRun.use_dut(primary_node): power_control = TestRun.plugin_manager.get_plugin("power_control") power_control.power_cycle(wait_for_connection=False) @@ -1070,7 +1070,7 @@ def test_failover_io_long(cls, cleaning_policy, num_iterations): ), TestRun.use_dut(secondary_node): secondary_node.cache.standby_activate(secondary_node.cache_dev) - with TestRun.step(f"Mount file system"), TestRun.use_dut(secondary_node): + with TestRun.step("Mount file system"), TestRun.use_dut(secondary_node): core.mount(mountpoint) with TestRun.step("Calculate checksum of CAS exported object"), TestRun.use_dut( diff --git a/test/functional/tests/failover_standby/test_failover_multihost.py b/test/functional/tests/failover_standby/test_failover_multihost.py index 383c0fe3e..bb42d9fa4 100644 --- a/test/functional/tests/failover_standby/test_failover_multihost.py +++ b/test/functional/tests/failover_standby/test_failover_multihost.py @@ -1,6 +1,6 @@ # # Copyright(c) 2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies +# Copyright(c) 2024-2025 Huawei Technologies # SPDX-License-Identifier: BSD-3-Clause # @@ -255,9 +255,6 @@ def test_functional_activate_twice_new_host(filesystem): with TestRun.step("Prepare DUTs"): prepare_devices(TestRun.duts) primary_node, secondary_node = TestRun.duts - extra_init_config_flags = ( - f"cache_line_size={str(cls.value.value//1024)},target_failover_state=standby" - ) # THIS IS WHERE THE REAL TEST STARTS TestRun.LOGGER.start_group( @@ -489,14 +486,14 @@ def failover_sequence(standby_node, drbd_resource, filesystem, core): TestRun.executor.run_expect_success(f"ls -la /dev/ | grep cas{cache_id}-1") if filesystem: - with TestRun.use_dut(standby_node), TestRun.step(f"Mount core"): + with TestRun.use_dut(standby_node), TestRun.step("Mount core"): TestRun.executor.run(f"rm -rf {mountpoint}") create_directory(path=mountpoint) core.mount(mountpoint) def postfailover_check(new_primary_node, data_path, core_md5, cache_stats): - with TestRun.use_dut(new_primary_node), TestRun.step(f"Make sure the usage stats are correct"): + with TestRun.use_dut(new_primary_node), TestRun.step("Make sure the usage stats are correct"): failover_cache_stats = new_primary_node.cache.get_statistics().usage_stats if cache_stats.dirty != failover_cache_stats.dirty: TestRun.LOGGER.error( @@ -524,7 +521,7 @@ def new_failover_instance(new_secondary_node, drbd_resource, *, autoload): ): caches = get_caches() if len(caches) < 1: - TestRun.LOGGER.error(f"Cache not present in system") + TestRun.LOGGER.error("Cache not present in system") else: cache_status = caches[0].get_status() if cache_status != CacheStatus.standby: diff --git a/test/functional/tests/fault_injection/test_cache_insert_error.py b/test/functional/tests/fault_injection/test_cache_insert_error.py index 901af08a7..94485a8c5 100644 --- a/test/functional/tests/fault_injection/test_cache_insert_error.py +++ b/test/functional/tests/fault_injection/test_cache_insert_error.py @@ -175,7 +175,7 @@ def test_cache_write_lazy_insert_error(cache_mode, block_size): .total_errors() ) if fio_errors == 0: - TestRun.fail(f"No I/O ended with error") + TestRun.fail("No I/O ended with error") with TestRun.step("Check error statistics and state on cache"): stats = cache.get_statistics() diff --git a/test/functional/tests/fault_injection/test_error_device_as_cache.py b/test/functional/tests/fault_injection/test_error_device_as_cache.py index 15e7d99fe..208fc4d06 100644 --- a/test/functional/tests/fault_injection/test_error_device_as_cache.py +++ b/test/functional/tests/fault_injection/test_error_device_as_cache.py @@ -61,7 +61,7 @@ def test_error_device_as_cache_clean_wt(cache_line_size): cache.set_seq_cutoff_policy(SeqCutOffPolicy.never) cache.set_cleaning_policy(CleaningPolicy.nop) - with TestRun.step(f"Add core"): + with TestRun.step("Add core"): core = cache.add_core(core_dev=core_device.partitions[0]) with TestRun.step("Disable udev"): @@ -186,7 +186,7 @@ def test_error_device_as_cache_clean_wa(cache_line_size): cache.set_seq_cutoff_policy(SeqCutOffPolicy.never) cache.set_cleaning_policy(CleaningPolicy.nop) - with TestRun.step(f"Add core"): + with TestRun.step("Add core"): core = cache.add_core(core_dev=core_device.partitions[0]) with TestRun.step("Disable udev"): @@ -312,7 +312,7 @@ def test_error_device_as_cache_dirty(cache_mode, cache_line_size): cache.set_seq_cutoff_policy(SeqCutOffPolicy.never) cache.set_cleaning_policy(CleaningPolicy.nop) - with TestRun.step(f"Add core"): + with TestRun.step("Add core"): cores = [cache.add_core(core_dev=core) for core in core_parts] with TestRun.step("Disable udev"): diff --git a/test/functional/tests/fault_injection/test_fault_injection_many_to_one.py b/test/functional/tests/fault_injection/test_fault_injection_many_to_one.py index 21684ef12..5ef27efff 100644 --- a/test/functional/tests/fault_injection/test_fault_injection_many_to_one.py +++ b/test/functional/tests/fault_injection/test_fault_injection_many_to_one.py @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -277,7 +277,8 @@ def test_one_core_fail_dirty(): .input("/dev/urandom") .output(core1.path) .oflag("direct") - ).run() + ) + dd.run() cache_occupancy_before = cache.get_statistics(percentage_val=True).usage_stats.occupancy cache_dirty_blocks_before = cache.get_dirty_blocks() if cache_occupancy_before != 100: diff --git a/test/functional/tests/fault_injection/test_fault_injection_opencas_load.py b/test/functional/tests/fault_injection/test_fault_injection_opencas_load.py index 8aaf03551..292fd3556 100644 --- a/test/functional/tests/fault_injection/test_fault_injection_opencas_load.py +++ b/test/functional/tests/fault_injection/test_fault_injection_opencas_load.py @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies +# Copyright(c) 2024-2025 Huawei Technologies # SPDX-License-Identifier: BSD-3-Clause # @@ -45,7 +45,7 @@ def test_stop_no_flush_load_cache(cache_mode): with TestRun.step("Add core to cache."): core = cache.add_core(core_part) - with TestRun.step(f"Create test file in mount point of exported object and check its md5 sum."): + with TestRun.step("Create test file in mount point of exported object and check its md5 sum."): test_file_size = Size(48, Unit.MebiByte) test_file = create_random_test_file(test_file_path, test_file_size) test_file_md5_before = test_file.md5sum() diff --git a/test/functional/tests/fault_injection/test_fault_injection_standby.py b/test/functional/tests/fault_injection/test_fault_injection_standby.py index 01053a371..908ca1672 100644 --- a/test/functional/tests/fault_injection/test_fault_injection_standby.py +++ b/test/functional/tests/fault_injection/test_fault_injection_standby.py @@ -1,6 +1,6 @@ # # Copyright(c) 2019-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies +# Copyright(c) 2024-2025 Huawei Technologies # SPDX-License-Identifier: BSD-3-Clause # @@ -47,8 +47,6 @@ def test_activate_corrupted(): cache_id = 1 cls = CacheLineSize.LINE_32KiB md_dump = prepare_md_dump(cache_device, core_device, cls, cache_id) - dmesg_out = TestRun.executor.run_expect_success("dmesg").stdout - superblock_size = get_md_section_size("Super block config", dmesg_out) with TestRun.step("Prepare standby instance"): cache = casadm.standby_init( @@ -61,15 +59,15 @@ def test_activate_corrupted(): with TestRun.step(f"Corrupt {block_size} on the offset {offset*block_size}"): corrupted_md = prepare_corrupted_md(md_dump, offset, block_size) - with TestRun.step(f"Copy corrupted metadata to the passive instance"): + with TestRun.step("Copy corrupted metadata to the passive instance"): Dd().input(corrupted_md.full_path).output(f"/dev/cas-cache-{cache_id}").run() sync() - with TestRun.step(f"Standby detach"): + with TestRun.step("Standby detach"): cache.standby_detach() with TestRun.step("Try to activate cache instance"): - output = TestRun.executor.run( + TestRun.executor.run( standby_activate_cmd(cache_dev=cache_device.path, cache_id=str(cache_id)) ) @@ -105,13 +103,11 @@ def test_load_corrupted(): cache_id = 1 cls = CacheLineSize.LINE_32KiB md_dump = prepare_md_dump(cache_device, core_device, cls, cache_id) - dmesg_out = TestRun.executor.run_expect_success("dmesg").stdout - superblock_size = get_md_section_size("Super block config", dmesg_out) with TestRun.step(f"Corrupt {block_size} on the offset {offset*block_size}"): corrupted_md = prepare_corrupted_md(md_dump, offset, block_size) - with TestRun.step(f"Copy corrupted metadata to the cache-to-be device"): + with TestRun.step("Copy corrupted metadata to the cache-to-be device"): Dd().input(corrupted_md.full_path).output(cache_device.path).run() sync() @@ -151,8 +147,6 @@ def test_activate_corrupted_after_dump(): cache_id = 1 cls = CacheLineSize.LINE_32KiB md_dump = prepare_md_dump(cache_device, core_device, cls, cache_id) - dmesg_out = TestRun.executor.run_expect_success("dmesg").stdout - superblock_size = get_md_section_size("Super block config", dmesg_out) with TestRun.step("Prepare standby instance"): cache = casadm.standby_init( @@ -162,22 +156,22 @@ def test_activate_corrupted_after_dump(): force=True, ) - with TestRun.step(f"Populate the passive instance with valid metadata"): + with TestRun.step("Populate the passive instance with valid metadata"): Dd().input(md_dump.full_path).output(f"/dev/cas-cache-{cache_id}").run() sync() - with TestRun.step(f"Standby detach"): + with TestRun.step("Standby detach"): cache.standby_detach() with TestRun.step(f"Corrupt {block_size} on the offset {offset*block_size}"): corrupted_md = prepare_corrupted_md(md_dump, offset, block_size) - with TestRun.step(f"Copy corrupted metadata to the passive instance"): + with TestRun.step("Copy corrupted metadata to the passive instance"): Dd().input(corrupted_md.full_path).output(cache_device.path).run() sync() with TestRun.step("Try to activate cache instance"): - output = TestRun.executor.run( + TestRun.executor.run( standby_activate_cmd(cache_dev=cache_device.path, cache_id=str(cache_id)) ) diff --git a/test/functional/tests/fault_injection/test_fault_injection_standby_core.py b/test/functional/tests/fault_injection/test_fault_injection_standby_core.py index b0bc4b9cc..5900195ba 100644 --- a/test/functional/tests/fault_injection/test_fault_injection_standby_core.py +++ b/test/functional/tests/fault_injection/test_fault_injection_standby_core.py @@ -1,6 +1,6 @@ # # Copyright(c) 2019-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies +# Copyright(c) 2024-2025 Huawei Technologies # SPDX-License-Identifier: BSD-3-Clause # @@ -141,7 +141,7 @@ def test_activate_incomplete_cache(): cache = casadm.standby_load(cache_dev) with TestRun.step("Verify if the cache exported object appeared in the system"): - output = TestRun.executor.run_expect_success(f"ls -la /dev/ | grep cas-cache-1") + output = TestRun.executor.run_expect_success("ls -la /dev/ | grep cas-cache-1") if output.stdout[0] != "b": TestRun.fail("The cache exported object is not a block device") @@ -243,7 +243,6 @@ def test_activate_neg_core_size(): core_disk.create_partitions([core_part_size]) cache_dev = cache_disk.partitions[0] core_dev = core_disk.partitions[0] - core_dev_path = core_dev.path with TestRun.step("Start a regular cache instance with a core"): cache = casadm.start_cache(cache_dev, force=True) @@ -260,7 +259,7 @@ def test_activate_neg_core_size(): cache = casadm.standby_load(cache_dev) with TestRun.step("Verify if the cache exported object appeared in the system"): - output = TestRun.executor.run_expect_success(f"ls -la /dev/ | grep cas-cache-1") + output = TestRun.executor.run_expect_success("ls -la /dev/ | grep cas-cache-1") if output.stdout[0] != "b": TestRun.fail("The cache exported object is not a block device") diff --git a/test/functional/tests/fault_injection/test_fault_injection_with_mounted_core.py b/test/functional/tests/fault_injection/test_fault_injection_with_mounted_core.py index cc0abd09d..51eaacf7e 100644 --- a/test/functional/tests/fault_injection/test_fault_injection_with_mounted_core.py +++ b/test/functional/tests/fault_injection/test_fault_injection_with_mounted_core.py @@ -45,7 +45,7 @@ def test_load_cache_with_mounted_core(): core = cache.add_core(core_part) core.mount(mount_point) - with TestRun.step(f"Create test file in mount point of exported object and check its md5 sum."): + with TestRun.step("Create test file in mount point of exported object and check its md5 sum."): test_file = create_random_test_file(test_file_path) test_file_md5_before = test_file.md5sum() diff --git a/test/functional/tests/fault_injection/test_fault_power_reboot.py b/test/functional/tests/fault_injection/test_fault_power_reboot.py index 104a9a436..cd2dbcb5c 100644 --- a/test/functional/tests/fault_injection/test_fault_power_reboot.py +++ b/test/functional/tests/fault_injection/test_fault_power_reboot.py @@ -41,7 +41,7 @@ def test_fault_power_reboot(): core_dev = core_disk.partitions[0] cache = casadm.start_cache(cache_dev, force=True) - core = cache.add_core(core_dev) + cache.add_core(core_dev) with TestRun.step("Mark log lines for later validation of new entries."): last_read_line = 1 @@ -65,8 +65,8 @@ def test_fault_power_reboot(): with TestRun.step("Start cache with load."): try: - cache = casadm.load_cache(cache_dev) - TestRun.LOGGER.info(f"Cache device loaded correctly (as expected).") + casadm.load_cache(cache_dev) + TestRun.LOGGER.info("Cache device loaded correctly (as expected).") except CmdException as e: TestRun.LOGGER.error(f"Failed to load cache device. Exception: {e.output}") @@ -78,7 +78,7 @@ def test_fault_power_reboot(): time.sleep(wait_long_time) result = check_log(last_read_line, cli_messages.reinitialize_with_force_or_recovery) if not result: - TestRun.LOGGER.error(f"Haven't found expected message in the log.") + TestRun.LOGGER.error("Haven't found expected message in the log.") def check_log(last_read_line, expected_message): diff --git a/test/functional/tests/incremental_load/test_inactive_cores.py b/test/functional/tests/incremental_load/test_inactive_cores.py index 8e4fb4452..e40bbc312 100644 --- a/test/functional/tests/incremental_load/test_inactive_cores.py +++ b/test/functional/tests/incremental_load/test_inactive_cores.py @@ -8,8 +8,7 @@ from api.cas import casadm from api.cas.cache_config import CacheMode -from api.cas.casadm_parser import get_cas_devices_dict, get_inactive_cores -from api.cas.core import Core, CoreStatus +from api.cas.casadm_parser import get_inactive_cores from core.test_run import TestRun from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan from test_tools.dd import Dd diff --git a/test/functional/tests/initialize/test_recovery.py b/test/functional/tests/initialize/test_recovery.py index c77309ae4..37116023a 100644 --- a/test/functional/tests/initialize/test_recovery.py +++ b/test/functional/tests/initialize/test_recovery.py @@ -1,6 +1,6 @@ # # Copyright(c) 2019-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -83,7 +83,7 @@ def test_recover_cache_verify_core_device(filesystem): if len(get_caches()) > 0: TestRun.fail("CAS failed to stop cache") if not check_stderr_msg(output, stop_cache_errors): - TestRun.fail(f"Wrong error message during cache stop") + TestRun.fail("Wrong error message during cache stop") with TestRun.step("Plug cache device"): cache_device.plug_all() @@ -168,7 +168,7 @@ def test_recover_cache_verify_exp_obj(filesystem): if len(get_caches()) > 0: TestRun.fail("CAS failed to stop cache") if not check_stderr_msg(output, stop_cache_errors): - TestRun.fail(f"Wrong error message during cache stop") + TestRun.fail("Wrong error message during cache stop") with TestRun.step("Plug cache device"): cache_device.plug_all() diff --git a/test/functional/tests/initialize/test_simulation_startup.py b/test/functional/tests/initialize/test_simulation_startup.py index b40ccfec9..bc82d6e49 100644 --- a/test/functional/tests/initialize/test_simulation_startup.py +++ b/test/functional/tests/initialize/test_simulation_startup.py @@ -75,7 +75,7 @@ def test_simulation_startup_from_config(): TestRun.executor.run_expect_success(ctl_stop()) with TestRun.step("Trigger udev"): - TestRun.executor.run_expect_success(f"udevadm trigger") + TestRun.executor.run_expect_success("udevadm trigger") with TestRun.step("Verify if cache is working"): caches = casadm_parser.get_caches() diff --git a/test/functional/tests/initialize/test_startup_init_config.py b/test/functional/tests/initialize/test_startup_init_config.py index 60fafa052..96872ae44 100644 --- a/test/functional/tests/initialize/test_startup_init_config.py +++ b/test/functional/tests/initialize/test_startup_init_config.py @@ -184,7 +184,7 @@ def test_cas_startup_lazy(): core_disk.create_partitions([Size(200, Unit.MebiByte)] * 4) with TestRun.step( - f"Add a cache configuration with cache device with `lazy_startup` flag" + "Add a cache configuration with cache device with `lazy_startup` flag" ): init_conf = InitConfig() init_conf.add_cache( @@ -196,7 +196,7 @@ def test_cas_startup_lazy(): expected_core_pool_paths = set(c.path for c in core_disk.partitions[:2]) with TestRun.step( - f"Add a cache configuration with core device with `lazy_startup` flag" + "Add a cache configuration with core device with `lazy_startup` flag" ): init_conf.add_cache(2, cache_disk.partitions[1]) init_conf.add_core(2, 1, core_disk.partitions[2]) @@ -212,7 +212,7 @@ def test_cas_startup_lazy(): inactive_core_path = core_disk.partitions[3].path with TestRun.step( - f"Start and stop all the configurations using the casctl utility" + "Start and stop all the configurations using the casctl utility" ): output = casctl.init(True) if output.exit_code != 0: @@ -226,7 +226,7 @@ def test_cas_startup_lazy(): ): Udev.disable() - with TestRun.step(f"Remove one cache partition and one core partition"): + with TestRun.step("Remove one cache partition and one core partition"): cache_disk.remove_partition(cache_disk.partitions[0]) core_disk.remove_partition(core_disk.partitions[3]) @@ -298,7 +298,7 @@ def test_cas_startup_negative_missing_core(): core_disk.create_partitions([Size(200, Unit.MebiByte)] * 4) with TestRun.step( - f"Add a cache configuration with cache device with `lazy_startup` flag" + "Add a cache configuration with cache device with `lazy_startup` flag" ): init_conf = InitConfig() init_conf.add_cache( @@ -308,7 +308,7 @@ def test_cas_startup_negative_missing_core(): init_conf.add_core(1, 2, core_disk.partitions[1]) with TestRun.step( - f"Add a cache configuration with core device with `lazy_startup` flag" + "Add a cache configuration with core device with `lazy_startup` flag" ): init_conf.add_cache(2, cache_disk.partitions[1]) init_conf.add_core(2, 1, core_disk.partitions[2]) @@ -319,7 +319,7 @@ def test_cas_startup_negative_missing_core(): sync() with TestRun.step( - f"Start and stop all the configurations using the casctl utility" + "Start and stop all the configurations using the casctl utility" ): output = casctl.init(True) if output.exit_code != 0: @@ -333,7 +333,7 @@ def test_cas_startup_negative_missing_core(): ): Udev.disable() - with TestRun.step(f"Remove core partition"): + with TestRun.step("Remove core partition"): core_disk.remove_partition(core_disk.partitions[0]) escape = EmergencyEscape() @@ -375,7 +375,7 @@ def test_cas_startup_negative_missing_cache(): core_disk.create_partitions([Size(200, Unit.MebiByte)] * 4) with TestRun.step( - f"Add a cache configuration with cache device with `lazy_startup` flag" + "Add a cache configuration with cache device with `lazy_startup` flag" ): init_conf = InitConfig() init_conf.add_cache( @@ -385,7 +385,7 @@ def test_cas_startup_negative_missing_cache(): init_conf.add_core(1, 2, core_disk.partitions[1]) with TestRun.step( - f"Add a cache configuration with core devices with `lazy_startup` flag" + "Add a cache configuration with core devices with `lazy_startup` flag" ): init_conf.add_cache(2, cache_disk.partitions[1]) init_conf.add_core( @@ -398,7 +398,7 @@ def test_cas_startup_negative_missing_cache(): sync() with TestRun.step( - f"Start and stop all the configurations using the casctl utility" + "Start and stop all the configurations using the casctl utility" ): output = casctl.init(True) if output.exit_code != 0: @@ -412,7 +412,7 @@ def test_cas_startup_negative_missing_cache(): ): Udev.disable() - with TestRun.step(f"Remove second cache partition"): + with TestRun.step("Remove second cache partition"): cache_disk.remove_partition(cache_disk.partitions[1]) escape = EmergencyEscape() @@ -458,7 +458,7 @@ def test_failover_config_startup(): core_disk.create_partitions([Size(200, Unit.MebiByte)]) with TestRun.step( - f"Add a cache configuration with cache device with " + "Add a cache configuration with cache device with " "`target_failover_state=active` flag and a core" ): init_conf = InitConfig() @@ -470,7 +470,7 @@ def test_failover_config_startup(): active_core_device_path = core_disk.partitions[0].path with TestRun.step( - f"Add a cache configuration with cache device with " + "Add a cache configuration with cache device with " "`target_failover_state=failover` flag" ): init_conf.add_cache( @@ -483,7 +483,7 @@ def test_failover_config_startup(): sync() with TestRun.step( - f"Start and stop all the configurations using the casctl utility" + "Start and stop all the configurations using the casctl utility" ): output = casctl.init(True) if output.exit_code != 0: @@ -566,7 +566,7 @@ def test_failover_config_startup_negative(): cache_disk = TestRun.disks["cache"] cache_disk.create_partitions([Size(200, Unit.MebiByte)]) - with TestRun.step(f"Add a cache configuration with standby cache"): + with TestRun.step("Add a cache configuration with standby cache"): init_conf = InitConfig() init_conf.add_cache( 1, @@ -577,7 +577,7 @@ def test_failover_config_startup_negative(): sync() with TestRun.step( - f"Start and stop all the configurations using the casctl utility" + "Start and stop all the configurations using the casctl utility" ): output = casctl.init(True) if output.exit_code != 0: @@ -591,7 +591,7 @@ def test_failover_config_startup_negative(): ): Udev.disable() - with TestRun.step(f"Remove second cache partition"): + with TestRun.step("Remove second cache partition"): cache_disk.remove_partition(cache_disk.partitions[0]) escape = EmergencyEscape() @@ -685,7 +685,7 @@ def test_lazy_startup_core_path_by_id(cache_mode, reboot_type): with TestRun.step("Check if cache is not running"): if len(casadm_parser.get_caches()) > 0: - TestRun.fail(f"Cache is running after system startup but it shouldn't.") + TestRun.fail("Cache is running after system startup but it shouldn't.") with TestRun.step("Check if all cores are detached"): listed_cores = casadm_parser.get_cas_devices_dict().get("core_pool") diff --git a/test/functional/tests/io/test_attach_detach_during_io.py b/test/functional/tests/io/test_attach_detach_during_io.py index 5931648a6..98ef54341 100644 --- a/test/functional/tests/io/test_attach_detach_during_io.py +++ b/test/functional/tests/io/test_attach_detach_during_io.py @@ -10,7 +10,6 @@ from api.cas.cache_config import CacheMode from api.cas.casadm import start_cache -from core.test_run import TestRun from core.test_run_utils import TestRun from storage_devices.disk import DiskTypeSet, DiskType, DiskTypeLowerThan from test_tools.fio.fio import Fio @@ -76,13 +75,14 @@ def test_attach_detach_during_io(cache_mode): time.sleep(5) with TestRun.step("Randomly detach and attach cache during I/O"): + cache_to_attach = cache_dev while TestRun.executor.check_if_process_exists(fio_pid): time.sleep(random.randint(2, 10)) cache.detach() if cache.get_statistics().error_stats.cache.total != 0.0: TestRun.LOGGER.error( - f"Cache error(s) occurred after " + "Cache error(s) occurred after " f"{cache_to_attach} detach" ) time.sleep(5) diff --git a/test/functional/tests/io/trim/test_trim.py b/test/functional/tests/io/trim/test_trim.py index 7ee8b9888..b98260e4e 100644 --- a/test/functional/tests/io/trim/test_trim.py +++ b/test/functional/tests/io/trim/test_trim.py @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -116,7 +116,7 @@ def test_trim_propagation(): - No data corruption after power failure. """ - with TestRun.step(f"Create partitions"): + with TestRun.step("Create partitions"): TestRun.disks["ssd1"].create_partitions([Size(43, Unit.MegaByte)]) TestRun.disks["ssd2"].create_partitions([Size(512, Unit.KiloByte)]) @@ -128,17 +128,17 @@ def test_trim_propagation(): if not check_if_device_supports_trim(core_dev): raise Exception("Core device doesn't support discards") - with TestRun.step(f"Disable udev"): + with TestRun.step("Disable udev"): Udev.disable() - with TestRun.step(f"Prepare cache instance in WB with one core"): + with TestRun.step("Prepare cache instance in WB with one core"): cache = casadm.start_cache(cache_dev, CacheMode.WB, force=True) core = cache.add_core(core_dev) cache.set_cleaning_policy(CleaningPolicy.nop) cache.set_seq_cutoff_policy(SeqCutOffPolicy.never) cache.purge_cache() - with TestRun.step(f"Fill exported object with dirty data"): + with TestRun.step("Fill exported object with dirty data"): core_size_4k = core.get_statistics().config_stats.core_size.get_value(Unit.Blocks4096) core_size_4k = int(core_size_4k) @@ -154,7 +154,7 @@ def test_trim_propagation(): f"actual value {dirty_4k}" ) - with TestRun.step(f"Discard 4k of data on exported object"): + with TestRun.step("Discard 4k of data on exported object"): TestRun.executor.run_expect_success(f"blkdiscard {core.path} --length 4096 --offset 0") old_occupancy = cache.get_statistics().usage_stats.occupancy.get_value(Unit.Blocks4096) @@ -205,7 +205,7 @@ def test_trim_device_discard_support( mount_point = "/mnt" - with TestRun.step(f"Create partitions on SSD and HDD devices. Create filesystem."): + with TestRun.step("Create partitions on SSD and HDD devices. Create filesystem."): TestRun.disks["ssd1"].create_partitions([Size(1, Unit.GibiByte)]) TestRun.disks["ssd2"].create_partitions([Size(1, Unit.GibiByte)]) disk_not_supporting_trim = None @@ -221,7 +221,7 @@ def test_trim_device_discard_support( ssd2_dev = TestRun.disks["ssd2"].partitions[0] dev_not_supporting_trim = disk_not_supporting_trim.partitions[0] - with TestRun.step(f"Start cache and add core."): + with TestRun.step("Start cache and add core."): cache_dev = ssd1_dev if trim_support_cache_core[0] else dev_not_supporting_trim core_dev = ssd2_dev if trim_support_cache_core[1] else dev_not_supporting_trim diff --git a/test/functional/tests/io_class/io_class_common.py b/test/functional/tests/io_class/io_class_common.py index dc14da519..5f710aaeb 100644 --- a/test/functional/tests/io_class/io_class_common.py +++ b/test/functional/tests/io_class/io_class_common.py @@ -1,6 +1,6 @@ # # Copyright(c) 2019-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -44,17 +44,17 @@ def prepare( cache_device = cache_device.partitions[0] core_device = core_device.partitions[0] - TestRun.LOGGER.info(f"Starting cache") + TestRun.LOGGER.info("Starting cache") cache = casadm.start_cache( cache_device, cache_mode=cache_mode, cache_line_size=cache_line_size, force=True ) Udev.disable() - TestRun.LOGGER.info(f"Setting cleaning policy to NOP") + TestRun.LOGGER.info("Setting cleaning policy to NOP") casadm.set_param_cleaning(cache_id=cache.cache_id, policy=CleaningPolicy.nop) - TestRun.LOGGER.info(f"Adding core device") + TestRun.LOGGER.info("Adding core device") core = casadm.add_core(cache, core_dev=core_device) - TestRun.LOGGER.info(f"Setting seq cutoff policy to never") + TestRun.LOGGER.info("Setting seq cutoff policy to never") core.set_seq_cutoff_policy(SeqCutOffPolicy.never) ioclass_config.create_ioclass_config( add_default_rule=False, ioclass_config_path=ioclass_config_path @@ -72,7 +72,7 @@ def prepare( output = TestRun.executor.run(f"mkdir -p {mountpoint}") if output.exit_code != 0: - raise Exception(f"Failed to create mountpoint") + raise Exception("Failed to create mountpoint") return cache, core diff --git a/test/functional/tests/io_class/test_io_class_cli.py b/test/functional/tests/io_class/test_io_class_cli.py index 05e3a0409..19782a844 100644 --- a/test/functional/tests/io_class/test_io_class_cli.py +++ b/test/functional/tests/io_class/test_io_class_cli.py @@ -1,6 +1,6 @@ # # Copyright(c) 2019-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -31,12 +31,12 @@ def test_io_class_export_configuration(): """ cache_mode = CacheMode.WB - with TestRun.LOGGER.step(f"Test prepare"): + with TestRun.LOGGER.step("Test prepare"): cache, core = prepare(cache_mode) saved_config_path = "/tmp/opencas_saved.conf" default_list = [IoClass.default()] - with TestRun.LOGGER.step(f"Check IO class configuration (should contain only default class)"): + with TestRun.LOGGER.step("Check IO class configuration (should contain only default class)"): csv = casadm.list_io_classes(cache.cache_id, OutputFormat.csv).stdout if not IoClass.compare_ioclass_lists(IoClass.csv_to_list(csv), default_list): TestRun.LOGGER.error( @@ -97,7 +97,7 @@ def test_io_class_export_configuration(): f"Expected:{IoClass.list_to_csv(random_list)}" ) - with TestRun.LOGGER.step(f"Test cleanup"): + with TestRun.LOGGER.step("Test cleanup"): remove(saved_config_path) @@ -112,9 +112,9 @@ def prepare(cache_mode: CacheMode = None): cache_device = cache_device.partitions[0] core_device = core_device.partitions[0] - TestRun.LOGGER.info(f"Starting cache") + TestRun.LOGGER.info("Starting cache") cache = casadm.start_cache(cache_device, cache_mode=cache_mode, force=True) - TestRun.LOGGER.info(f"Adding core device") + TestRun.LOGGER.info("Adding core device") core = casadm.add_core(cache, core_dev=core_device) return cache, core diff --git a/test/functional/tests/io_class/test_io_class_core_id.py b/test/functional/tests/io_class/test_io_class_core_id.py index c4e59c594..7de2d6de1 100644 --- a/test/functional/tests/io_class/test_io_class_core_id.py +++ b/test/functional/tests/io_class/test_io_class_core_id.py @@ -1,6 +1,6 @@ # # Copyright(c) 2019-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -35,12 +35,12 @@ def test_ioclass_core_id(): """ with TestRun.step( - f"Start cache with two cores on created partitions with NOP, disabled seq cutoff" + "Start cache with two cores on created partitions with NOP, disabled seq cutoff" ): cache, cores = prepare(2) core_1, core_2 = cores[0], cores[1] - with TestRun.step(f"Add core_id based classification rules"): + with TestRun.step("Add core_id based classification rules"): cached_ioclass_id = 11 not_cached_ioclass_id = 12 @@ -59,18 +59,18 @@ def test_ioclass_core_id(): ioclass_config_path=ioclass_config.default_config_file_path, ) - with TestRun.step(f"Load ioclass config file"): + with TestRun.step("Load ioclass config file"): casadm.load_io_classes( cache_id=cache.cache_id, file=ioclass_config.default_config_file_path ) - with TestRun.step(f"Reset counters"): + with TestRun.step("Reset counters"): sync() drop_caches() cache.purge_cache() cache.reset_counters() - with TestRun.step(f"Trigger IO to both cores"): + with TestRun.step("Trigger IO to both cores"): dd_dst_paths = [core_1.path, core_2.path] for path in dd_dst_paths: @@ -86,7 +86,7 @@ def test_ioclass_core_id(): sync() drop_caches() - with TestRun.step(f"Check cores occupancy"): + with TestRun.step("Check cores occupancy"): dd_size = (dd_bs * dd_count).set_unit(Unit.Blocks4096) core_1_occupancy = core_1.get_statistics().usage_stats.occupancy @@ -101,7 +101,7 @@ def test_ioclass_core_id(): if core_2_occupancy.get_value() != 0: TestRun.LOGGER.error(f"First core's occupancy is {core_2_occupancy} instead of 0!") - with TestRun.step(f"Check io classes occupancy"): + with TestRun.step("Check io classes occupancy"): cached_ioclass_occupancy = cache.get_io_class_statistics( io_class_id=cached_ioclass_id ).usage_stats.occupancy @@ -119,7 +119,7 @@ def test_ioclass_core_id(): f"Not cached ioclass occupancy is {not_cached_ioclass_occupancy} instead of 0!" ) - with TestRun.step(f"Check number of serviced requests to not cached core"): + with TestRun.step("Check number of serviced requests to not cached core"): core_2_serviced_requests = core_2.get_statistics().request_stats.requests_serviced if core_2_serviced_requests != 0: TestRun.LOGGER.error( diff --git a/test/functional/tests/io_class/test_io_class_directory.py b/test/functional/tests/io_class/test_io_class_directory.py index 4d346f117..92698acb9 100644 --- a/test/functional/tests/io_class/test_io_class_directory.py +++ b/test/functional/tests/io_class/test_io_class_directory.py @@ -1,6 +1,6 @@ # # Copyright(c) 2019-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -53,7 +53,7 @@ def test_ioclass_directory_depth(filesystem): with TestRun.step(f"Create the base directory: {base_dir_path}."): create_directory(base_dir_path) - with TestRun.step(f"Create a nested directory."): + with TestRun.step("Create a nested directory."): nested_dir_path = base_dir_path random_depth = random.randint(40, 80) for i in range(random_depth): @@ -338,7 +338,7 @@ def test_ioclass_directory_dir_operations(filesystem): ioclass_id=32, eviction_priority=255, allocation="0.00", - rule=f"metadata", + rule="metadata", ioclass_config_path=ioclass_config_path, ) casadm.load_io_classes(cache_id=cache.cache_id, file=ioclass_config_path) diff --git a/test/functional/tests/io_class/test_io_class_eviction_priority.py b/test/functional/tests/io_class/test_io_class_eviction_priority.py index 8ea1bc406..bafb738e2 100644 --- a/test/functional/tests/io_class/test_io_class_eviction_priority.py +++ b/test/functional/tests/io_class/test_io_class_eviction_priority.py @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -76,7 +76,7 @@ def test_io_class_eviction_priority(): f" Expected 0, got: {occupancy}" ) - with TestRun.step(f"To A, B and C directories perform IO with size of max io_class occupancy"): + with TestRun.step("To A, B and C directories perform IO with size of max io_class occupancy"): for io_class in io_classes[0:3]: run_io_dir( f"{io_class.dir_path}/tmp_file", diff --git a/test/functional/tests/io_class/test_io_class_file.py b/test/functional/tests/io_class/test_io_class_file.py index be7c83a89..ba8708601 100644 --- a/test/functional/tests/io_class/test_io_class_file.py +++ b/test/functional/tests/io_class/test_io_class_file.py @@ -696,7 +696,7 @@ def load_file_size_io_classes(cache, base_size): ioclass_id=6, eviction_priority=1, allocation="0.00", - rule=f"metadata", + rule="metadata", ioclass_config_path=ioclass_config_path, ) ioclass_config.add_ioclass( diff --git a/test/functional/tests/io_class/test_io_class_lvm_on_cas.py b/test/functional/tests/io_class/test_io_class_lvm_on_cas.py index 6ac8e2b35..0314dd5d6 100644 --- a/test/functional/tests/io_class/test_io_class_lvm_on_cas.py +++ b/test/functional/tests/io_class/test_io_class_lvm_on_cas.py @@ -1,6 +1,6 @@ # # Copyright(c) 2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -35,7 +35,7 @@ def test_io_class_lvm_on_cas(): - Increasing proper statistics as expected. """ - with TestRun.step(f"Create CAS device."): + with TestRun.step("Create CAS device."): cache_dev = TestRun.disks['cache'] core_dev = TestRun.disks['core'] cache_dev.create_partitions([Size(20, Unit.GibiByte)]) 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 7dbaf1729..c377d3ea3 100644 --- a/test/functional/tests/io_class/test_io_class_occupancy.py +++ b/test/functional/tests/io_class/test_io_class_occupancy.py @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -239,7 +239,7 @@ def test_io_class_occupancy_directory_read(io_size_multiplication): f" Expected 0, got: {occupancy}" ) - with TestRun.step(f"Read each file and check if data was inserted to appropriate ioclass"): + with TestRun.step("Read each file and check if data was inserted to appropriate ioclass"): for io_class in io_classes: original_occupancies = {} tmp_io_class_list = [i for i in io_classes if i != io_class] @@ -387,7 +387,7 @@ def test_ioclass_occupancy_sum_cache(): f"Particular stats {all_io_class_usage_stats}" ) - with TestRun.step(f"Trigger IO to each directory"): + with TestRun.step("Trigger IO to each directory"): for io_class in io_classes: run_io_dir( f"{io_class.dir_path}/tmp_file", 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 d47ad9962..5d00acae1 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 @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -99,7 +99,7 @@ def test_ioclass_occupancy_load(): f" Expected 0, got: {occupancy}" ) - with TestRun.step(f"Perform IO with size equal to cache size"): + with TestRun.step("Perform IO with size equal to cache size"): for io_class in io_classes: run_io_dir(f"{io_class.dir_path}/tmp_file", int(cache_size / blocks4096)) 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 50833a62e..eb887214a 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 @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -99,7 +99,7 @@ def test_ioclass_repart(io_class_size_multiplication): cache.purge_cache() cache.reset_counters() - with TestRun.step(f"Create 3 files classified in default ioclass"): + with TestRun.step("Create 3 files classified in default ioclass"): for i, io_class in enumerate(io_classes[0:3]): run_io_dir( f"{mountpoint}/{i}", @@ -111,7 +111,7 @@ def test_ioclass_repart(io_class_size_multiplication): cache_size.value, rel_tol=0.1, ): - TestRun.fail(f"Failed to populte default ioclass") + TestRun.fail("Failed to populte default ioclass") with TestRun.step("Check initial occupancy"): for io_class in io_classes: 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 47259a7ea..a755e3c0e 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 @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -94,7 +94,7 @@ def test_ioclass_resize(cache_line_size, new_occupancy): f" Expected 0, got: {occupancy}" ) - with TestRun.step(f"Perform IO with size equal to cache size"): + with TestRun.step("Perform IO with size equal to cache size"): run_io_dir(f"{io_class.dir_path}/tmp_file", int(cache_size / Unit.Blocks4096)) with TestRun.step("Check if the ioclass did not exceed specified occupancy"): @@ -139,7 +139,7 @@ def test_ioclass_resize(cache_line_size, new_occupancy): casadm.load_io_classes(cache_id=cache.cache_id, file=default_config_file_path) - with TestRun.step(f"Perform IO with size equal to cache size"): + with TestRun.step("Perform IO with size equal to cache size"): run_io_dir(f"{io_class.dir_path}/tmp_file", int(cache_size / Unit.Blocks4096)) with TestRun.step("Check if the ioclass did not exceed specified occupancy"): diff --git a/test/functional/tests/io_class/test_io_class_pinning_eviction.py b/test/functional/tests/io_class/test_io_class_pinning_eviction.py index d44a0e0f2..814218ab3 100644 --- a/test/functional/tests/io_class/test_io_class_pinning_eviction.py +++ b/test/functional/tests/io_class/test_io_class_pinning_eviction.py @@ -92,7 +92,7 @@ def test_io_class_pinning_eviction(): f" Expected 0, got: {occupancy}" ) - with TestRun.step(f"Trigger IO to pinned class directory"): + with TestRun.step("Trigger IO to pinned class directory"): run_io_dir( f"{pinned_io_class.dir_path}/tmp_file", int((pinned_io_class.max_occupancy * cache_line_count) / Unit.Blocks4096), @@ -187,7 +187,7 @@ def test_pinned_ioclasses_eviction(): f" Expected 0, got: {occupancy}" ) - with TestRun.step(f"Trigger IO to first pinned class directory"): + with TestRun.step("Trigger IO to first pinned class directory"): run_io_dir( f"{io_classes[0].dir_path}/tmp_file", int((io_classes[0].max_occupancy * cache_size) / Unit.Blocks4096), @@ -204,7 +204,7 @@ def test_pinned_ioclasses_eviction(): f"Expected: {expected_occupancy} Actual: {first_io_pinned_occupancy} " ) - with TestRun.step(f"Trigger IO to second pinned class directory"): + with TestRun.step("Trigger IO to second pinned class directory"): run_io_dir( f"{io_classes[1].dir_path}/tmp_file", int((io_classes[1].max_occupancy * cache_size) / Unit.Blocks4096), diff --git a/test/functional/tests/io_class/test_io_class_prevent_wrong_configuration.py b/test/functional/tests/io_class/test_io_class_prevent_wrong_configuration.py index 01d9268dc..c8d08cf18 100644 --- a/test/functional/tests/io_class/test_io_class_prevent_wrong_configuration.py +++ b/test/functional/tests/io_class/test_io_class_prevent_wrong_configuration.py @@ -1,6 +1,6 @@ # # Copyright(c) 2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -150,7 +150,7 @@ def try_load_malformed_config(cache, config_io_classes, expected_err_msg): TestRun.LOGGER.error("Open CAS accepts malformed configuration.") create_and_load_default_io_class_config(cache) except CmdException as e: - TestRun.LOGGER.info(f"Open CAS did not load malformed config file as expected.") + TestRun.LOGGER.info("Open CAS did not load malformed config file as expected.") cli_messages.check_stderr_msg(e.output, expected_err_msg) output_io_classes = cache.list_io_classes() if not IoClass.compare_ioclass_lists(output_io_classes, config_io_classes): diff --git a/test/functional/tests/io_class/test_io_class_process.py b/test/functional/tests/io_class/test_io_class_process.py index e8ab5f876..4eb508f7a 100644 --- a/test/functional/tests/io_class/test_io_class_process.py +++ b/test/functional/tests/io_class/test_io_class_process.py @@ -1,6 +1,6 @@ # # Copyright(c) 2019-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -40,7 +40,7 @@ def test_ioclass_process_name(): ioclass_id=ioclass_id, eviction_priority=1, allocation="1.00", - rule=f"process_name:dd&done", + rule="process_name:dd&done", ioclass_config_path=ioclass_config_path, ) casadm.load_io_classes(cache_id=cache.cache_id, file=ioclass_config_path) diff --git a/test/functional/tests/io_class/test_io_class_stats_file_size_core.py b/test/functional/tests/io_class/test_io_class_stats_file_size_core.py index 4748ca8f4..89511be87 100644 --- a/test/functional/tests/io_class/test_io_class_stats_file_size_core.py +++ b/test/functional/tests/io_class/test_io_class_stats_file_size_core.py @@ -1,6 +1,6 @@ # # Copyright(c) 2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -135,7 +135,7 @@ def test_io_class_stats_file_size_core_direct(cache_mode: CacheMode): sync() drop_caches() - with TestRun.step(f"Check that statistics increase only for direct IO class"): + with TestRun.step("Check that statistics increase only for direct IO class"): issued_reqs_no = \ result[0].write_requests_number() + result[0].read_requests_number() check_statistics(cache, core, io_classes, io_class_direct, issued_reqs_no) diff --git a/test/functional/tests/io_class/test_io_class_wlth.py b/test/functional/tests/io_class/test_io_class_wlth.py index fbd32e81b..92efa453a 100644 --- a/test/functional/tests/io_class/test_io_class_wlth.py +++ b/test/functional/tests/io_class/test_io_class_wlth.py @@ -1,6 +1,6 @@ # # Copyright(c) 2019-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -29,40 +29,40 @@ def test_ioclass_wlth(): - IO with wlth is cached - IO without wlth is not cached """ - with TestRun.step(f"Start cache with one core with NOP and disabled seq cutoff"): + with TestRun.step("Start cache with one core with NOP and disabled seq cutoff"): cache, core = prepare() - with TestRun.step(f"Add wlth based classification rules"): + with TestRun.step("Add wlth based classification rules"): cached_ioclass_id = 10 ioclass_config.create_ioclass_config(add_default_rule=False) ioclass_config.add_ioclass( ioclass_id=0, eviction_priority=22, allocation="0", - rule=f"unclassified", + rule="unclassified", ioclass_config_path=ioclass_config.default_config_file_path, ) ioclass_config.add_ioclass( ioclass_id=cached_ioclass_id, eviction_priority=22, allocation="1.00", - rule=f"wlth:eq:4&done", + rule="wlth:eq:4&done", ioclass_config_path=ioclass_config.default_config_file_path, ) - with TestRun.step(f"Load ioclass config file"): + with TestRun.step("Load ioclass config file"): casadm.load_io_classes( cache_id=cache.cache_id, file=ioclass_config.default_config_file_path ) - with TestRun.step(f"Reset counters"): + with TestRun.step("Reset counters"): sync() drop_caches() Udev.disable() cache.purge_cache() cache.reset_counters() - with TestRun.step(f"Trigger IO with a write life time hint"): + with TestRun.step("Trigger IO with a write life time hint"): # Fio adds hints only to direct IO. Even if `write_hint` param isn't provided, direct IO # has assigned a hint by default io_count = 12345 @@ -81,7 +81,7 @@ def test_ioclass_wlth(): .run() ) - with TestRun.step(f"Trigger IO without write life time hint"): + with TestRun.step("Trigger IO without write life time hint"): ( Fio() .create_command() @@ -96,7 +96,7 @@ def test_ioclass_wlth(): sync() drop_caches() - with TestRun.step(f"Check stats"): + with TestRun.step("Check stats"): default_io_class_stats = core.get_io_class_statistics(io_class_id=0) wlth_io_class_stats = core.get_io_class_statistics(io_class_id=10) diff --git a/test/functional/tests/io_class/test_io_classification.py b/test/functional/tests/io_class/test_io_classification.py index aca002cbf..83f2af1c7 100644 --- a/test/functional/tests/io_class/test_io_classification.py +++ b/test/functional/tests/io_class/test_io_classification.py @@ -1,6 +1,6 @@ # # Copyright(c) 2019-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -63,7 +63,7 @@ def test_ioclass_lba(): with TestRun.step("Run IO and check if lbas from defined range are cached."): dirty_count = 0 # '8' step is set to prevent writing cache line more than once - TestRun.LOGGER.info(f"Writing to one sector in each cache line from range.") + TestRun.LOGGER.info("Writing to one sector in each cache line from range.") for lba in range(min_cached_lba, max_cached_lba, 8): ( Dd() @@ -82,7 +82,7 @@ def test_ioclass_lba(): TestRun.LOGGER.error(f"LBA {lba} not cached") with TestRun.step("Run IO and check if lba outside of defined range are not cached."): - TestRun.LOGGER.info(f"Writing to sectors outside of cached range.") + TestRun.LOGGER.info("Writing to sectors outside of cached range.") test_lba = [max_cached_lba + 1] + random.sample( [ *range(0, min_cached_lba), @@ -132,7 +132,7 @@ def test_ioclass_request_size(): ioclass_id=ioclass_id, eviction_priority=1, allocation="1.00", - rule=f"request_size:ge:8192&request_size:le:16384&done", + rule="request_size:ge:8192&request_size:le:16384&done", ioclass_config_path=ioclass_config_path, ) casadm.load_io_classes(cache_id=cache.cache_id, file=ioclass_config_path) @@ -728,7 +728,7 @@ def test_ioclass_effective_ioclass(): """ filesystem = Filesystem.xfs - with TestRun.LOGGER.step(f"Test prepare"): + with TestRun.LOGGER.step("Test prepare"): cache, core = prepare(default_allocation="1.00") Udev.disable() file_size = Size(10, Unit.Blocks4096) diff --git a/test/functional/tests/lazy_writes/cleaning_policy/test_acp.py b/test/functional/tests/lazy_writes/cleaning_policy/test_acp.py index c8220140a..248c813a4 100644 --- a/test/functional/tests/lazy_writes/cleaning_policy/test_acp.py +++ b/test/functional/tests/lazy_writes/cleaning_policy/test_acp.py @@ -123,6 +123,7 @@ def sector_in_tested_region(blktrace_header, list_of_chunks): max_percent = 100 bucket_chunks = [] current_chunk = None + write_counter = 0 for header in blktrace_output: # Sector not in current chunk - search for the next chunk diff --git a/test/functional/tests/lazy_writes/test_flush_huge_dirty_data.py b/test/functional/tests/lazy_writes/test_flush_huge_dirty_data.py index 0aa6b35a3..61e8ad1b4 100644 --- a/test/functional/tests/lazy_writes/test_flush_huge_dirty_data.py +++ b/test/functional/tests/lazy_writes/test_flush_huge_dirty_data.py @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2021 Intel Corporation -# Copyright(c) 2024 Huawei Technologies +# Copyright(c) 2024-2025 Huawei Technologies # SPDX-License-Identifier: BSD-3-Clause # @@ -153,7 +153,7 @@ def test_flush_over_640_gibibytes_raw_device(cache_mode): with TestRun.step(f"Start cache in {cache_mode} mode."): cache = casadm.start_cache(cache_part, cache_mode) - with TestRun.step(f"Add core to cache."): + with TestRun.step("Add core to cache."): core = cache.add_core(core_dev) with TestRun.step("Disable cleaning and sequential cutoff."): diff --git a/test/functional/tests/lazy_writes/test_wb_throttling.py b/test/functional/tests/lazy_writes/test_wb_throttling.py index 98fd7acf7..2335c878c 100644 --- a/test/functional/tests/lazy_writes/test_wb_throttling.py +++ b/test/functional/tests/lazy_writes/test_wb_throttling.py @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2021 Intel Corporation -# Copyright(c) 2024 Huawei Technologies +# Copyright(c) 2024-2025 Huawei Technologies # SPDX-License-Identifier: BSD-3-Clause # @@ -56,7 +56,7 @@ def test_wb_throttling(): cache_device = cache_device.partitions[0] with TestRun.step( - f"Start cache with one core in write back with 64k cache line, NOP and disabled seq cutoff" + "Start cache with one core in write back with 64k cache line, NOP and disabled seq cutoff" ): cache = casadm.start_cache(cache_device, CacheMode.WB, CacheLineSize.LINE_64KiB) cache.set_cleaning_policy(CleaningPolicy.nop) @@ -67,12 +67,12 @@ def test_wb_throttling(): wbt_lat_val = get_wbt_lat(core) TestRun.LOGGER.info(f"wbt_lat for exported object is {wbt_lat_val}") if wbt_lat_val == 0: - TestRun.LOGGER.info(f"Setting wbt_lat for exported object to 75000us") + TestRun.LOGGER.info("Setting wbt_lat for exported object to 75000us") set_wbt_lat(core, 75000) with TestRun.step("Fill cache with dirty data"): fio = get_fio_rw_cmd(core, write_percentage=100) - fio_pid = fio.run_in_background() + fio.run_in_background() wait( lambda: core.get_statistics(percentage_val=True).usage_stats.dirty == 100, diff --git a/test/functional/tests/memory/test_check_number_of_processes.py b/test/functional/tests/memory/test_check_number_of_processes.py index f65af8f13..8a5ca4ed3 100644 --- a/test/functional/tests/memory/test_check_number_of_processes.py +++ b/test/functional/tests/memory/test_check_number_of_processes.py @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -40,7 +40,7 @@ def test_check_number_of_processes(): core_dev = core_disk.partitions[0] cache = casadm.start_cache(cache_dev, force=True) - core = cache.add_core(core_dev) + cache.add_core(core_dev) with TestRun.step("Check number of IO threads."): number_of_processors = get_number_of_processors_from_cpuinfo() diff --git a/test/functional/tests/memory/test_detach_memory_release.py b/test/functional/tests/memory/test_detach_memory_release.py index 86dd6edbd..67b63e3d8 100644 --- a/test/functional/tests/memory/test_detach_memory_release.py +++ b/test/functional/tests/memory/test_detach_memory_release.py @@ -7,7 +7,6 @@ import pytest from api.cas.casadm import start_cache -from core.test_run import TestRun from core.test_run_utils import TestRun from storage_devices.disk import DiskTypeSet, DiskType, DiskTypeLowerThan from test_tools.memory import get_mem_free diff --git a/test/functional/tests/memory/test_memory_metadata_consumption.py b/test/functional/tests/memory/test_memory_metadata_consumption.py index 5c2732635..4d49b91c3 100644 --- a/test/functional/tests/memory/test_memory_metadata_consumption.py +++ b/test/functional/tests/memory/test_memory_metadata_consumption.py @@ -1,6 +1,6 @@ # # Copyright(c) 2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -146,14 +146,14 @@ def test_memory_metadata_consumption_full_cache(cache_line_size): occupancy = cache.get_statistics(percentage_val=True).usage_stats.occupancy TestRun.LOGGER.info(f"Cache occupancy: {occupancy}") if occupancy < (100 - percentage_tolerance): - TestRun.LOGGER.warning(f"Cache occupancy is below expectation.") + TestRun.LOGGER.warning("Cache occupancy is below expectation.") with TestRun.step("Measure allocates size of metadata."): used_memory = get_module_mem_footprint(cas_cache_module) TestRun.LOGGER.info(f"Memory allocated: {used_memory}") with TestRun.step( - "Compare allocated size with cache usage statistics " "and required consumption." + "Compare allocated size with cache usage statistics and required consumption." ): free_mem_after_start = get_mem_available() diff --git a/test/functional/tests/performance/test_performance_reads.py b/test/functional/tests/performance/test_performance_reads.py index b2c2e470d..237307442 100644 --- a/test/functional/tests/performance/test_performance_reads.py +++ b/test/functional/tests/performance/test_performance_reads.py @@ -1,6 +1,6 @@ # # Copyright(c) 2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -152,7 +152,7 @@ def test_performance_read_hit_wt(cache_line_size, block_size, queue_depth): TestRun.LOGGER.info(f"Read ratio: {read_iops_ratio}") if read_iops_ratio < 85: - TestRun.LOGGER.error(f"The read iops ratio is below expected threshold (85%).") + TestRun.LOGGER.error("The read iops ratio is below expected threshold (85%).") # TODO: for disks other than Intel Optane, fio ramp is needed before fio tests on raw disk @@ -274,10 +274,10 @@ def test_performance_read_hit_wb(cache_line_size, block_size, queue_depth): TestRun.LOGGER.info(f"Write ratio: {write_iops_ratio}") if read_iops_ratio < 90: - TestRun.LOGGER.error(f"The read iops ratio is below expected threshold (90%).") + TestRun.LOGGER.error("The read iops ratio is below expected threshold (90%).") if write_iops_ratio < 90: - TestRun.LOGGER.error(f"The write iops ratio is below expected threshold (90%).") + TestRun.LOGGER.error("The write iops ratio is below expected threshold (90%).") @pytest.fixture(scope="session", autouse=True) diff --git a/test/functional/tests/performance/test_performance_write.py b/test/functional/tests/performance/test_performance_write.py index 4c2b14c33..ba501611d 100644 --- a/test/functional/tests/performance/test_performance_write.py +++ b/test/functional/tests/performance/test_performance_write.py @@ -1,6 +1,6 @@ # # Copyright(c) 2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -155,7 +155,7 @@ def test_performance_write_insert_wb(block_size, queue_depth): TestRun.LOGGER.info(f"Write ratio: {write_iops_ratio}") if write_iops_ratio < 50: - TestRun.LOGGER.error(f"The write iops ratio is below expected threshold (50%).") + TestRun.LOGGER.error("The write iops ratio is below expected threshold (50%).") @pytest.fixture(scope="session", autouse=True) diff --git a/test/functional/tests/security/fuzzy/kernel/fuzzy_with_io/fuzzy_io_class/test_fuzzy_io_class_config_allocation.py b/test/functional/tests/security/fuzzy/kernel/fuzzy_with_io/fuzzy_io_class/test_fuzzy_io_class_config_allocation.py index 198683fdd..19991f4a0 100644 --- a/test/functional/tests/security/fuzzy/kernel/fuzzy_with_io/fuzzy_io_class/test_fuzzy_io_class_config_allocation.py +++ b/test/functional/tests/security/fuzzy/kernel/fuzzy_with_io/fuzzy_io_class/test_fuzzy_io_class_config_allocation.py @@ -74,7 +74,7 @@ def test_fuzzy_io_class_config_allocation( if not TestRun.executor.check_if_process_exists(fio_pid): raise Exception("Fio is not running.") - io_class = IoClass(class_id=1, rule=f"directory:/", priority=255) + io_class = IoClass(class_id=1, rule="directory:/", priority=255) with TestRun.step("Prepare PeachFuzzer"): PeachFuzzer.generate_config(get_fuzz_config("io_class_allocation.yml")) diff --git a/test/functional/tests/security/fuzzy/kernel/fuzzy_with_io/fuzzy_io_class/test_fuzzy_io_class_config_io_class_name.py b/test/functional/tests/security/fuzzy/kernel/fuzzy_with_io/fuzzy_io_class/test_fuzzy_io_class_config_io_class_name.py index 5b918055b..546f85881 100644 --- a/test/functional/tests/security/fuzzy/kernel/fuzzy_with_io/fuzzy_io_class/test_fuzzy_io_class_config_io_class_name.py +++ b/test/functional/tests/security/fuzzy/kernel/fuzzy_with_io/fuzzy_io_class/test_fuzzy_io_class_config_io_class_name.py @@ -222,7 +222,7 @@ def __validate_single_condition(value: str): if condition_key in ["file_name_prefix", "extension", "process_name"]: if 0 < len(condition_value) <= 256: return True - if condition_key is "directory": + if condition_key == "directory": if 0 < len(condition_value) <= 1024: return True elif condition_key == "io_direction": diff --git a/test/functional/tests/security/test_security_user.py b/test/functional/tests/security/test_security_user.py index 0f8a618e5..ea68cc64a 100644 --- a/test/functional/tests/security/test_security_user.py +++ b/test/functional/tests/security/test_security_user.py @@ -1,6 +1,6 @@ # # Copyright(c) 2019-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -486,7 +486,7 @@ def run_as_other_user(command, user: str, sudo: bool = False): command = 'sudo ' + command command = f'{prefix} {command}' output = TestRun.executor.run(command) - if output.exit_code != 0 or output.stderr is not "": + if output.exit_code != 0 or output.stderr != "": raise CmdException("Must be run as root.", output) return output diff --git a/test/functional/tests/stats/test_display_statistics.py b/test/functional/tests/stats/test_display_statistics.py index bcd99cbd6..620012345 100644 --- a/test/functional/tests/stats/test_display_statistics.py +++ b/test/functional/tests/stats/test_display_statistics.py @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2021 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -56,7 +56,7 @@ def test_cache_config_stats(): ): caches, cores = cache_prepare(cache_dev, core_dev) - with TestRun.step(f"Get configuration statistics for each cache and validate them"): + with TestRun.step("Get configuration statistics for each cache and validate them"): validate_cache_config_statistics(caches) with TestRun.step("Run 'fio'"): @@ -97,7 +97,7 @@ def test_core_config_stats(): ): caches, cores = cache_prepare(cache_dev, core_dev) - with TestRun.step(f"Get configuration statistics for each core and validate them"): + with TestRun.step("Get configuration statistics for each core and validate them"): validate_core_config_statistics(cores) with TestRun.step("Run 'fio'"): diff --git a/test/functional/tests/stats/test_statistics_integrity.py b/test/functional/tests/stats/test_statistics_integrity.py index f4238e585..2e908be47 100644 --- a/test/functional/tests/stats/test_statistics_integrity.py +++ b/test/functional/tests/stats/test_statistics_integrity.py @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2021 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -241,7 +241,7 @@ def check_stats_sum(caches, cores): def validate_usage_stats(stats, stats_perc, cache, cache_mode, fail_message): - fail_message += f"in 'usage' stats" + fail_message += "in 'usage' stats" if cache_mode not in CacheMode.with_traits(CacheModeTrait.InsertWrite): if stats.usage_stats.occupancy.value != 0: TestRun.LOGGER.error( @@ -353,7 +353,7 @@ def validate_usage_stats(stats, stats_perc, cache, cache_mode, fail_message): def validate_request_stats(stats, stats_perc, cache_mode, fail_message): - fail_message += f"in 'request' stats" + fail_message += "in 'request' stats" if stats.request_stats.read.hits != 0: TestRun.LOGGER.error( f"{fail_message} 'Read hits' is " @@ -519,7 +519,7 @@ def validate_request_stats(stats, stats_perc, cache_mode, fail_message): def validate_block_stats(stats, stats_perc, cache_mode, fail_message): - fail_message += f"in 'block' stats" + fail_message += "in 'block' stats" if stats.block_stats.core.reads.value != 0: TestRun.LOGGER.error( f"{fail_message} 'Core reads' is " @@ -701,7 +701,7 @@ def validate_block_stats(stats, stats_perc, cache_mode, fail_message): def validate_error_stats(stats, stats_perc, fail_message): - fail_message += f"in 'error' stats" + fail_message += "in 'error' stats" for stat_name, stat_value in stats.items(): if stat_value != 0: TestRun.LOGGER.error( diff --git a/test/functional/tests/stress/test_stress_cleaning_policy_change.py b/test/functional/tests/stress/test_stress_cleaning_policy_change.py index 12e18b40d..eb5d2e06d 100644 --- a/test/functional/tests/stress/test_stress_cleaning_policy_change.py +++ b/test/functional/tests/stress/test_stress_cleaning_policy_change.py @@ -1,6 +1,5 @@ # -# Copyright(c) 2024 Huawei Technologies Co., Ltd. -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -45,10 +44,10 @@ def test_change_cleaning_policy_during_io_raw(): with TestRun.step("Disable udev"): Udev.disable() - with TestRun.step(f"Start cache in Write-Back mode"): + with TestRun.step("Start cache in Write-Back mode"): cache = casadm.start_cache(cache_dev.partitions[0], CacheMode.WB, force=True) - with TestRun.step(f"Add core to the cache"): + with TestRun.step("Add core to the cache"): core = cache.add_core(core_dev) with TestRun.step("Run I/O in background"): @@ -64,7 +63,7 @@ def test_change_cleaning_policy_during_io_raw(): fio_pid = fio.run_in_background() - with TestRun.step(f"Start changing the cleaning policy during I/O operations"): + with TestRun.step("Start changing the cleaning policy during I/O operations"): current_policy = cache.get_cleaning_policy() while TestRun.executor.check_if_process_exists(fio_pid): random_policy = [policy for policy in list(CleaningPolicy) if policy != current_policy] @@ -101,13 +100,13 @@ def test_change_cleaning_policy_during_io_fs(filesystem): with TestRun.step("Disable udev"): Udev.disable() - with TestRun.step(f"Start cache in Write-Back mode"): + with TestRun.step("Start cache in Write-Back mode"): cache = casadm.start_cache(cache_dev.partitions[0], CacheMode.WB, force=True) - with TestRun.step(f"Create filesystem on core device"): + with TestRun.step("Create filesystem on core device"): core_dev.create_filesystem(filesystem) - with TestRun.step(f"Add core to the cache"): + with TestRun.step("Add core to the cache"): core = cache.add_core(core_dev) with TestRun.step("Mount exported object"): @@ -126,7 +125,7 @@ def test_change_cleaning_policy_during_io_fs(filesystem): fio_pid = fio.run_in_background() - with TestRun.step(f"Start changing the cleaning policy during I/O operations"): + with TestRun.step("Start changing the cleaning policy during I/O operations"): current_policy = cache.get_cleaning_policy() while TestRun.executor.check_if_process_exists(fio_pid): random_policy = [policy for policy in list(CleaningPolicy) if policy != current_policy] diff --git a/test/functional/tests/stress/test_stress_io_small_device.py b/test/functional/tests/stress/test_stress_io_small_device.py index a87ca2034..38e8d30fa 100644 --- a/test/functional/tests/stress/test_stress_io_small_device.py +++ b/test/functional/tests/stress/test_stress_io_small_device.py @@ -1,6 +1,6 @@ # # Copyright(c) 2019-2021 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -103,7 +103,7 @@ def test_stress_small_cas_device(cache_line_size, cores_number, cache_config): with TestRun.step("Compare md5 sum of exported objects and cores."): if md5sum_core_dev != md5sum_core: - TestRun.LOGGER.error(f"Md5 sums of core devices and of exported objects are different.") + TestRun.LOGGER.error("Md5 sums of core devices and of exported objects are different.") with TestRun.step("Stop all caches"): casadm.stop_all_caches() diff --git a/test/functional/tests/volumes/common.py b/test/functional/tests/volumes/common.py index c84fc5d4f..b235225d7 100644 --- a/test/functional/tests/volumes/common.py +++ b/test/functional/tests/volumes/common.py @@ -28,7 +28,7 @@ def create_files_with_md5sums(destination_path, files_count): md5sums.append(test_file.md5sum()) - TestRun.LOGGER.info(f"Files created and copied to core successfully.") + TestRun.LOGGER.info("Files created and copied to core successfully.") return md5sums @@ -47,7 +47,7 @@ def compare_md5sums(md5_sums_source, files_to_check_path, copy_to_tmp=False): if md5_sums_source[i] != file_to_check.md5sum(): TestRun.fail(f"Source and target files {file_to_check_path} checksums are different.") - TestRun.LOGGER.info(f"Successful verification, md5sums match.") + TestRun.LOGGER.info("Successful verification, md5sums match.") def get_test_configuration(): @@ -62,15 +62,15 @@ def validate_configuration(config_before_reboot, devices_before): config_after_reboot, devices_after = get_test_configuration() if config_after_reboot == config_before_reboot: - TestRun.LOGGER.info(f"Configuration is as expected") + TestRun.LOGGER.info("Configuration is as expected") else: TestRun.LOGGER.info(f"Config before reboot: {config_before_reboot}") TestRun.LOGGER.info(f"Config after reboot: {config_after_reboot}") - TestRun.LOGGER.error(f"Configuration changed after reboot") + TestRun.LOGGER.error("Configuration changed after reboot") if devices_after == devices_before: - TestRun.LOGGER.info(f"Device list is as expected") + TestRun.LOGGER.info("Device list is as expected") else: TestRun.LOGGER.info(f"Devices before: {devices_before}") TestRun.LOGGER.info(f"Devices after: {devices_after}") - TestRun.LOGGER.error(f"Device list changed after reboot") + TestRun.LOGGER.error("Device list changed after reboot") diff --git a/test/functional/tests/volumes/test_discard_on_huge_core.py b/test/functional/tests/volumes/test_discard_on_huge_core.py index 14cdbe76c..0f22ee45e 100644 --- a/test/functional/tests/volumes/test_discard_on_huge_core.py +++ b/test/functional/tests/volumes/test_discard_on_huge_core.py @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2021 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -29,7 +29,7 @@ def test_discard_on_huge_core(): - There is no RCU-sched type stall in dmesg log. """ with TestRun.step("Clear dmesg log."): - TestRun.executor.run_expect_success(f"dmesg -c") + TestRun.executor.run_expect_success("dmesg -c") with TestRun.step("Prepare devices for cache and core."): cache_dev = TestRun.disks['cache'] @@ -52,7 +52,7 @@ def test_discard_on_huge_core(): def check_for_rcu_sched_type_stall(): - output = TestRun.executor.run_expect_success(f"dmesg") + output = TestRun.executor.run_expect_success("dmesg") rcu_sched_found = False dmesg_log_id = "" diff --git a/test/functional/tests/volumes/test_many_cores_on_many_lvms.py b/test/functional/tests/volumes/test_many_cores_on_many_lvms.py index e10c27d20..11ea0f257 100644 --- a/test/functional/tests/volumes/test_many_cores_on_many_lvms.py +++ b/test/functional/tests/volumes/test_many_cores_on_many_lvms.py @@ -31,7 +31,7 @@ def test_many_cores_on_many_lvms(update_initramfs_before_and_after_test): - FIO with verification ran successfully. - Configuration after reboot match configuration before. """ - with TestRun.step(f"Prepare devices."): + with TestRun.step("Prepare devices."): cache_device = TestRun.disks['cache'] core_device = TestRun.disks['core'] cache_device.create_partitions([Size(1, Unit.GibiByte)]) @@ -51,7 +51,7 @@ def test_many_cores_on_many_lvms(update_initramfs_before_and_after_test): lvms = Lvm.create_specific_lvm_configuration([core_dev], config) - with TestRun.step(f"Create CAS device."): + with TestRun.step("Create CAS device."): cache = casadm.start_cache(cache_dev, force=True) cores = [] for lvm in lvms: diff --git a/test/functional/tests/volumes/test_many_lvms_on_many_cores.py b/test/functional/tests/volumes/test_many_lvms_on_many_cores.py index c2d2f9e7a..4242814a1 100644 --- a/test/functional/tests/volumes/test_many_lvms_on_many_cores.py +++ b/test/functional/tests/volumes/test_many_lvms_on_many_cores.py @@ -32,7 +32,7 @@ def test_many_lvms_on_many_cores(update_initramfs_before_and_after_test): - FIO with verification ran successfully. - Configuration after reboot match configuration before. """ - with TestRun.step(f"Create CAS device."): + with TestRun.step("Create CAS device."): cache_device = TestRun.disks['cache'] core_devices = [TestRun.disks['core1'], TestRun.disks['core2']] diff --git a/test/functional/tests/volumes/test_raid_as_cache.py b/test/functional/tests/volumes/test_raid_as_cache.py index b42376495..d988265c1 100644 --- a/test/functional/tests/volumes/test_raid_as_cache.py +++ b/test/functional/tests/volumes/test_raid_as_cache.py @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -50,7 +50,7 @@ def test_raid_as_cache(cache_mode): ) raid_volume = Raid.create(config, [raid_disk_1, raid_disk_2]) - TestRun.LOGGER.info(f"RAID created successfully.") + TestRun.LOGGER.info("RAID created successfully.") with TestRun.step("Prepare core device."): core_disk = TestRun.disks["core"] @@ -75,7 +75,7 @@ def test_raid_as_cache(cache_mode): remove(test_file.full_path, True) remove(test_file_copied.full_path, True) - TestRun.LOGGER.info(f"Successful verification.") + TestRun.LOGGER.info("Successful verification.") @pytest.mark.parametrize("cache_mode", CacheMode) @@ -111,7 +111,7 @@ def test_many_cores_raid_as_cache(cache_mode): ) raid_volume = Raid.create(config, [raid_disk_1, raid_disk_2]) - TestRun.LOGGER.info(f"RAID created successfully.") + TestRun.LOGGER.info("RAID created successfully.") cache = casadm.start_cache(raid_volume, cache_mode, force=True) diff --git a/test/functional/tests/volumes/test_volume_partitions.py b/test/functional/tests/volumes/test_volume_partitions.py index f76816ea8..6ee1d9810 100644 --- a/test/functional/tests/volumes/test_volume_partitions.py +++ b/test/functional/tests/volumes/test_volume_partitions.py @@ -1,6 +1,6 @@ # # Copyright(c) 2020-2022 Intel Corporation -# Copyright(c) 2024 Huawei Technologies Co., Ltd. +# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -34,7 +34,7 @@ def test_cas_preserves_partitions(partition_table, filesystem, cache_mode): - Md5 sums on partitions shall be identical before and after running cache. - Partition table shall be preserved on exported object. """ - with TestRun.step(f"Prepare cache and core devices."): + with TestRun.step("Prepare cache and core devices."): cache_dev = TestRun.disks['cache'] cache_dev.create_partitions([Size(1, Unit.GibiByte)]) cache_dev = cache_dev.partitions[0] @@ -63,7 +63,7 @@ def test_cas_preserves_partitions(partition_table, filesystem, cache_mode): for core in core_dev.partitions: core.unmount() - with TestRun.step(f"Start cache."): + with TestRun.step("Start cache."): cache = casadm.start_cache(cache_dev, cache_mode, force=True) with TestRun.step("Add cores to cache."): @@ -108,13 +108,13 @@ def test_partition_create_cas(partition_table, filesystem, cache_mode): - Md5 sums on partitions shall be identical before and after stopping cache. - Partition table shall be preserved on core device. """ - with TestRun.step(f"Prepare cache and core devices."): + with TestRun.step("Prepare cache and core devices."): cache_dev = TestRun.disks['cache'] cache_dev.create_partitions([Size(256, Unit.MebiByte)]) cache_dev = cache_dev.partitions[0] core_dev = TestRun.disks['core'] - with TestRun.step(f"Start cache."): + with TestRun.step("Start cache."): cache = casadm.start_cache(cache_dev, cache_mode, force=True) core = cache.add_core(core_dev) diff --git a/test/utils_tests/opencas-py-tests/test_cas_config_01.py b/test/utils_tests/opencas-py-tests/test_cas_config_01.py index b52ebe335..1fd7682a9 100644 --- a/test/utils_tests/opencas-py-tests/test_cas_config_01.py +++ b/test/utils_tests/opencas-py-tests/test_cas_config_01.py @@ -1,5 +1,6 @@ # # Copyright(c) 2012-2021 Intel Corporation +# Copyright(c) 2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -283,7 +284,7 @@ def test_cas_config_get_by_id_path_not_found(mock_listdir, mock_realpath): mock_realpath.side_effect = lambda x: x with pytest.raises(ValueError): - path = opencas.cas_config.get_by_id_path("/dev/dummy1") + opencas.cas_config.get_by_id_path("/dev/dummy1") @pytest.mark.parametrize( diff --git a/test/utils_tests/opencas-py-tests/test_helper_functions_01.py b/test/utils_tests/opencas-py-tests/test_helper_functions_01.py index c71dcee22..1069499f6 100644 --- a/test/utils_tests/opencas-py-tests/test_helper_functions_01.py +++ b/test/utils_tests/opencas-py-tests/test_helper_functions_01.py @@ -1,12 +1,12 @@ # # Copyright(c) 2019-2021 Intel Corporation +# Copyright(c) 2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # import pytest from unittest.mock import patch, Mock import time -import subprocess import opencas @@ -771,7 +771,7 @@ def test_last_resort_add_01(mock_start, mock_add, mock_exists, mock_run, mock_li mock_exists.return_value = False - result = opencas.wait_for_startup(timeout=0, interval=0) + opencas.wait_for_startup(timeout=0, interval=0) mock_add.assert_not_called() mock_start.assert_not_called() @@ -805,7 +805,7 @@ def test_last_resort_add_02(mock_start, mock_add, mock_exists, mock_run, mock_li mock_exists.return_value = True - result = opencas.wait_for_startup(timeout=0, interval=0) + opencas.wait_for_startup(timeout=0, interval=0) mock_start.assert_any_call(config.caches[1], load=True) mock_start.assert_any_call(config.caches[2], load=True) @@ -852,7 +852,7 @@ def test_last_resort_add_03(mock_start, mock_add, mock_exists, mock_run, mock_li mock_exists.side_effect = _exists_mock(time.time() + 10) - result = opencas.wait_for_startup(timeout=0.5, interval=0.1) + opencas.wait_for_startup(timeout=0.5, interval=0.1) mock_start.assert_not_called() mock_add.assert_not_called() @@ -886,7 +886,7 @@ def test_last_resort_add_04(mock_start, mock_add, mock_exists, mock_run, mock_li mock_exists.side_effect = _exists_mock(time.time() + 1) - result = opencas.wait_for_startup(timeout=2, interval=0.1) + opencas.wait_for_startup(timeout=2, interval=0.1) mock_start.assert_any_call(config.caches[1], load=True) mock_start.assert_any_call(config.caches[2], load=True) @@ -922,7 +922,7 @@ def test_last_resort_add_05(mock_start, mock_add, mock_exists, mock_run, mock_li mock_exists.return_value = True - result = opencas.wait_for_startup(timeout=0.5, interval=0.1) + opencas.wait_for_startup(timeout=0.5, interval=0.1) mock_start.assert_any_call(config.caches[1], load=True) mock_start.assert_any_call(config.caches[2], load=True) @@ -960,7 +960,7 @@ def test_last_resort_add_06(mock_start, mock_add, mock_exists, mock_run, mock_li mock_exists.side_effect = _exists_mock(time.time() + 1) - result = opencas.wait_for_startup(timeout=2, interval=0.5) + opencas.wait_for_startup(timeout=2, interval=0.5) mock_start.assert_not_called() mock_add.assert_not_called() diff --git a/utils/open-cas-loader.py b/utils/open-cas-loader.py index 09538859c..21bfcadd7 100755 --- a/utils/open-cas-loader.py +++ b/utils/open-cas-loader.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # # Copyright(c) 2012-2021 Intel Corporation +# Copyright(c) 2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -12,7 +13,7 @@ try: subprocess.call(['/sbin/modprobe', 'cas_cache']) -except: +except Exception: sl.syslog(sl.LOG_ERR, 'Unable to probe cas_cache module') exit(1) diff --git a/utils/opencas.py b/utils/opencas.py index f3ae11256..b4d189729 100644 --- a/utils/opencas.py +++ b/utils/opencas.py @@ -1,5 +1,6 @@ # # Copyright(c) 2012-2021 Intel Corporation +# Copyright(c) 2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -204,7 +205,7 @@ def check_block_device(path): try: mode = os.stat(path).st_mode - except: + except Exception: raise ValueError(f'{path} not found') if not stat.S_ISBLK(mode): @@ -280,7 +281,7 @@ def check_cache_id_valid(cache_id): def check_cache_device_empty(self): try: result = casadm.run_cmd(['lsblk', '-o', 'NAME', '-l', '-n', self.device]) - except: + except Exception: # lsblk returns non-0 if it can't probe for partitions # this means that we're probably dealing with atomic device # let it through @@ -500,7 +501,7 @@ def insert_cache(self, new_cache_config): try: new_cache_config.device = cas_config.get_by_id_path(new_cache_config.device) - except: + except Exception: pass self.caches[new_cache_config.cache_id] = new_cache_config @@ -536,7 +537,7 @@ def insert_core(self, new_core_config): try: new_core_config.device = cas_config.get_by_id_path(new_core_config.device) - except: + except Exception: pass self.caches[new_core_config.cache_id].cores[new_core_config.core_id] = new_core_config @@ -561,7 +562,7 @@ def write(self, config_file): conf.write('\n[cores]\n') for core in self.cores: conf.write(core.to_line()) - except: + except Exception: raise Exception('Couldn\'t write config file') # Config helper functions @@ -654,7 +655,7 @@ def get_cas_version(): for line in version.stdout.split('\n')[1:]: try: component, version = line.split(',') - except: + except Exception: continue ret[component] = version @@ -714,7 +715,7 @@ def detach_all_cores(flush): dev_list = get_caches_list() except casadm.CasadmError as e: raise Exception(f'Unable to list caches. Reason:\n{e.result.stderr}') - except: + except Exception: raise Exception('Unable to list caches.') for dev in dev_list: @@ -728,7 +729,7 @@ def detach_all_cores(flush): except casadm.CasadmError as e: error.add_exception(Exception( f"Unable to detach core {dev['disk']}. Reason:\n{e.result.stderr}")) - except: + except Exception: error.add_exception(Exception(f"Unable to detach core {dev['disk']}.")) error.raise_nonempty() @@ -741,7 +742,7 @@ def stop_all_caches(flush): dev_list = get_caches_list() except casadm.CasadmError as e: raise Exception(f'Unable to list caches. Reason:\n{e.result.stderr}') - except: + except Exception: raise Exception('Unable to list caches.') for dev in dev_list: @@ -753,7 +754,7 @@ def stop_all_caches(flush): except casadm.CasadmError as e: error.add_exception(Exception( f"Unable to stop cache {dev['disk']}. Reason:\n{e.result.stderr}")) - except: + except Exception: error.add_exception(Exception(f"Unable to stop cache {dev['disk']}.")) error.raise_nonempty() @@ -871,7 +872,7 @@ def start_device(dev): if not not_initialized: return [] - result = subprocess.run(["udevadm", "settle"]) + subprocess.run(["udevadm", "settle"]) for dev in not_initialized: start_device(dev) diff --git a/utils/upgrade_utils.py b/utils/upgrade_utils.py index c15a45a7f..14b084c86 100644 --- a/utils/upgrade_utils.py +++ b/utils/upgrade_utils.py @@ -1,5 +1,6 @@ # # Copyright(c) 2020-2021 Intel Corporation +# Copyright(c) 2025 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # @@ -215,5 +216,5 @@ def set_device_scheduler(sysfs_path, scheduler): def drop_os_caches(): - with open(f"/proc/sys/vm/drop_caches", "w") as f: + with open("/proc/sys/vm/drop_caches", "w") as f: f.write("3")