From df8705373cf75743a363892bc368e602f5528ab1 Mon Sep 17 00:00:00 2001 From: Kamil Gierszewski Date: Mon, 23 Sep 2024 10:49:50 +0200 Subject: [PATCH 1/3] tests: fix test for cleaning policy Signed-off-by: Kamil Gierszewski --- .../tests/cache_ops/test_cleaning_policy_operation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/functional/tests/cache_ops/test_cleaning_policy_operation.py b/test/functional/tests/cache_ops/test_cleaning_policy_operation.py index 362af76..be6cf25 100644 --- a/test/functional/tests/cache_ops/test_cleaning_policy_operation.py +++ b/test/functional/tests/cache_ops/test_cleaning_policy_operation.py @@ -130,6 +130,7 @@ def test_cleaning_policies_in_write_through(cleaning_policy): with TestRun.step(f"Start cache in Write-Through mode with {cleaning_policy} cleaning policy"): cache = casadm.start_cache(cache_dev.partitions[0], CacheMode.WT, force=True) + cache.set_cleaning_policy(cleaning_policy=cleaning_policy) set_cleaning_policy_params(cache, cleaning_policy) with TestRun.step("Check for running CAS cleaner"): @@ -256,7 +257,7 @@ def check_cleaning_policy_operation( case CleaningPolicy.nop: if ( core_writes_after_wait_for_cleaning != Size.zero() - or core_writes_before_wait_for_cleaning.value != Size.zero() + or core_writes_before_wait_for_cleaning != Size.zero() ): TestRun.LOGGER.error( "NOP cleaning policy is not working properly! " From b8d6f8403eba9555f9007cd43497354ca339d946 Mon Sep 17 00:00:00 2001 From: Kamil Gierszewski Date: Mon, 23 Sep 2024 12:16:23 +0200 Subject: [PATCH 2/3] test-api: fix cache mode change Signed-off-by: Kamil Gierszewski --- test/functional/api/cas/casadm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/api/cas/casadm.py b/test/functional/api/cas/casadm.py index 6b693a6..3ac59df 100644 --- a/test/functional/api/cas/casadm.py +++ b/test/functional/api/cas/casadm.py @@ -235,10 +235,10 @@ def get_param_cleaning_acp( def set_cache_mode( - cache_mode: CacheMode, cache_id: int, flush=None, shortcut: bool = False + cache_mode: CacheMode, cache_id: int, flush: bool = None, shortcut: bool = False ) -> Output: flush_cache = None - if flush: + if flush is not None: flush_cache = "yes" if flush else "no" output = TestRun.executor.run( set_cache_mode_cmd( From 8d4262079ee84f543b0f73f787f9a4be27e974ce Mon Sep 17 00:00:00 2001 From: Kamil Gierszewski Date: Mon, 23 Sep 2024 12:43:15 +0200 Subject: [PATCH 3/3] tests: fix test_negative_start_cache Signed-off-by: Kamil Gierszewski --- test/functional/tests/basic/test_basic.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/functional/tests/basic/test_basic.py b/test/functional/tests/basic/test_basic.py index b3bfb1f..2b77c05 100644 --- a/test/functional/tests/basic/test_basic.py +++ b/test/functional/tests/basic/test_basic.py @@ -6,16 +6,16 @@ import pytest +from api.cas import casadm from api.cas.cache_config import CacheMode, CacheLineSize from api.cas.casadm_params import OutputFormat from api.cas.cli import start_cmd -from core.test_run import TestRun -from api.cas import casadm from api.cas.cli_messages import ( check_stderr_msg, start_cache_on_already_used_dev, start_cache_with_existing_id, ) +from core.test_run import TestRun from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan from test_tools import fs_utils from test_tools.dd import Dd @@ -81,31 +81,31 @@ def test_negative_start_cache(): with TestRun.step("Start cache on the same device but with another ID"): try: - output = TestRun.executor.run( + output = TestRun.executor.run_expect_fail( start_cmd( cache_dev=cache_dev_1.path, cache_id="2", force=True, ) ) - TestRun.fail("Two caches started on same device") - except CmdException: if not check_stderr_msg(output, start_cache_on_already_used_dev): TestRun.fail(f"Received unexpected error message: {output.stderr}") + except CmdException: + TestRun.fail("Two caches started on same device") with TestRun.step("Start cache with the same ID on another cache device"): try: - output = TestRun.executor.run( + output = TestRun.executor.run_expect_fail( start_cmd( cache_dev=cache_dev_2.path, cache_id="1", force=True, ) ) - TestRun.fail("Two caches started with same ID") - except CmdException: if not check_stderr_msg(output, start_cache_with_existing_id): TestRun.fail(f"Received unexpected error message: {output.stderr}") + except CmdException: + TestRun.fail("Two caches started with same ID") @pytest.mark.CI