Minor test description and names refactor
Signed-off-by: Katarzyna Treder <katarzyna.treder@h-partners.com>
This commit is contained in:
@@ -25,51 +25,51 @@ from test_tools.memory import disable_memory_affecting_functions, get_mem_free,
|
||||
@pytest.mark.os_dependent
|
||||
def test_insufficient_memory_for_cas_module():
|
||||
"""
|
||||
title: Negative test for the ability of CAS to load the kernel module with insufficient memory.
|
||||
title: Load CAS kernel module with insufficient memory
|
||||
description: |
|
||||
Check that the CAS kernel module won’t be loaded if enough memory is not available
|
||||
Negative test for the ability to load the CAS kernel module with insufficient memory.
|
||||
pass_criteria:
|
||||
- CAS module cannot be loaded with not enough memory.
|
||||
- Loading CAS with not enough memory returns error.
|
||||
- CAS kernel module cannot be loaded with not enough memory.
|
||||
- Loading CAS kernel module with not enough memory returns error.
|
||||
"""
|
||||
|
||||
with TestRun.step("Disable caching and memory over-committing"):
|
||||
disable_memory_affecting_functions()
|
||||
drop_caches()
|
||||
|
||||
with TestRun.step("Measure memory usage without OpenCAS module"):
|
||||
with TestRun.step("Measure memory usage without CAS kernel module"):
|
||||
if is_kernel_module_loaded(CasModule.cache.value):
|
||||
unload_kernel_module(CasModule.cache.value)
|
||||
available_mem_before_cas = get_mem_free()
|
||||
|
||||
with TestRun.step("Load CAS module"):
|
||||
with TestRun.step("Load CAS kernel module"):
|
||||
load_kernel_module(CasModule.cache.value)
|
||||
|
||||
with TestRun.step("Measure memory usage with CAS module"):
|
||||
with TestRun.step("Measure memory usage with CAS kernel module"):
|
||||
available_mem_with_cas = get_mem_free()
|
||||
memory_used_by_cas = available_mem_before_cas - available_mem_with_cas
|
||||
TestRun.LOGGER.info(
|
||||
f"OpenCAS module uses {memory_used_by_cas.get_value(Unit.MiB):.2f} MiB of DRAM."
|
||||
f"CAS kernel module uses {memory_used_by_cas.get_value(Unit.MiB):.2f} MiB of DRAM."
|
||||
)
|
||||
|
||||
with TestRun.step("Unload CAS module"):
|
||||
with TestRun.step("Unload CAS kernel module"):
|
||||
unload_kernel_module(CasModule.cache.value)
|
||||
|
||||
with TestRun.step("Allocate memory, leaving not enough memory for CAS module"):
|
||||
memory_to_leave = get_mem_free() - (memory_used_by_cas * (3 / 4))
|
||||
allocate_memory(memory_to_leave)
|
||||
TestRun.LOGGER.info(
|
||||
f"Memory left for OpenCAS module: {get_mem_free().get_value(Unit.MiB):0.2f} MiB."
|
||||
f"Memory left for CAS kernel module: {get_mem_free().get_value(Unit.MiB):0.2f} MiB."
|
||||
)
|
||||
|
||||
with TestRun.step(
|
||||
"Try to load OpenCAS module and check if correct error message is printed on failure"
|
||||
"Try to load CAS kernel module and check if correct error message is printed on failure"
|
||||
):
|
||||
output = load_kernel_module(CasModule.cache.value)
|
||||
if output.stderr and output.exit_code != 0:
|
||||
TestRun.LOGGER.info(f"Cannot load OpenCAS module as expected.\n{output.stderr}")
|
||||
TestRun.LOGGER.info(f"Cannot load CAS kernel module as expected.\n{output.stderr}")
|
||||
else:
|
||||
TestRun.LOGGER.error("Loading OpenCAS module successfully finished, but should fail.")
|
||||
TestRun.LOGGER.error("Loading CAS kernel module successfully finished, but should fail.")
|
||||
|
||||
|
||||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
|
||||
@@ -118,3 +118,4 @@ def test_attach_cache_min_ram():
|
||||
|
||||
with TestRun.step("Unlock RAM memory"):
|
||||
unmount_ramfs()
|
||||
|
||||
|
@@ -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
|
||||
#
|
||||
|
||||
@@ -23,14 +23,14 @@ from test_tools.udev import Udev
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_cleaning_policy():
|
||||
"""
|
||||
Title: test_cleaning_policy
|
||||
Title: Basic test for cleaning policy
|
||||
description: |
|
||||
The test is to see if dirty data will be removed from the Cache after changing the
|
||||
cleaning policy from NOP to one that expects a flush.
|
||||
Verify cleaning behaviour after changing cleaning policy from NOP
|
||||
to one that expects a flush.
|
||||
pass_criteria:
|
||||
- Cache is successfully populated with dirty data
|
||||
- Cleaning policy is changed successfully
|
||||
- There is no dirty data after the policy change
|
||||
- Cache is successfully populated with dirty data
|
||||
- Cleaning policy is changed successfully
|
||||
- There is no dirty data after the policy change
|
||||
"""
|
||||
wait_time = 60
|
||||
|
||||
|
126
test/functional/tests/cli/test_cli_help_and_version.py
Normal file
126
test/functional/tests/cli/test_cli_help_and_version.py
Normal file
@@ -0,0 +1,126 @@
|
||||
#
|
||||
# Copyright(c) 2020-2022 Intel Corporation
|
||||
# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import re
|
||||
import pytest
|
||||
|
||||
from api.cas import casadm
|
||||
from api.cas.casadm_params import OutputFormat
|
||||
from api.cas.cli_help_messages import *
|
||||
from api.cas.cli_messages import check_stderr_msg, check_stdout_msg
|
||||
from core.test_run import TestRun
|
||||
|
||||
|
||||
@pytest.mark.parametrize("shortcut", [True, False])
|
||||
def test_cli_help(shortcut):
|
||||
"""
|
||||
title: Test for 'help' command.
|
||||
description: Test if help for commands displays correct output.
|
||||
pass_criteria:
|
||||
- Proper help displays for every command.
|
||||
"""
|
||||
TestRun.LOGGER.info("Run 'help' for every 'casadm' command.")
|
||||
output = casadm.help(shortcut)
|
||||
check_stdout_msg(output, casadm_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -S" if shortcut else " --start-cache")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, start_cache_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -T" if shortcut else " --stop-cache")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, stop_cache_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -X" if shortcut else " --set-param")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, set_params_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -G" if shortcut else " --get-param")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, get_params_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -Q" if shortcut else " --set-cache-mode")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, set_cache_mode_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -A" if shortcut else " --add-core")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, add_core_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -R" if shortcut else " --remove-core")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, remove_core_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + " --remove-detached"
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, remove_detached_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -L" if shortcut else " --list-caches")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, list_caches_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -P" if shortcut else " --stats")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, stats_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -Z" if shortcut else " --reset-counters")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, reset_counters_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -F" if shortcut else " --flush-cache")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, flush_cache_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -C" if shortcut else " --io-class")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, ioclass_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -V" if shortcut else " --version")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, version_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -H" if shortcut else " --help")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, help_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + " --standby"
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, standby_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + " --zero-metadata"
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stdout_msg(output, zero_metadata_help)
|
||||
|
||||
output = TestRun.executor.run("casadm" + (" -Y" if shortcut else " --yell")
|
||||
+ (" -H" if shortcut else " --help"))
|
||||
check_stderr_msg(output, unrecognized_stderr)
|
||||
check_stdout_msg(output, unrecognized_stdout)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("output_format", OutputFormat)
|
||||
@pytest.mark.parametrize("shortcut", [True, False])
|
||||
def test_cli_version(shortcut, output_format):
|
||||
"""
|
||||
title: Test for 'version' command.
|
||||
description: Test if 'version' command displays correct output.
|
||||
pass_criteria:
|
||||
- Proper component names displayed in table with component versions.
|
||||
"""
|
||||
TestRun.LOGGER.info("Check version.")
|
||||
output = casadm.print_version(output_format, shortcut).stdout
|
||||
TestRun.LOGGER.info(output)
|
||||
if not names_in_output(output) or not versions_in_output(output):
|
||||
TestRun.fail("'Version' command failed.")
|
||||
|
||||
|
||||
def names_in_output(output):
|
||||
return ("CAS Cache Kernel Module" in output
|
||||
and "CAS CLI Utility" in output)
|
||||
|
||||
|
||||
def versions_in_output(output):
|
||||
version_pattern = re.compile(r"(\d){2}\.(\d){2}\.(\d)\.(\d){4}.(\S)")
|
||||
return len(version_pattern.findall(output)) == 2
|
@@ -14,7 +14,7 @@ def test_cli_help_spelling():
|
||||
title: Spelling test for 'help' command
|
||||
description: Validates spelling of 'help' in CLI
|
||||
pass criteria:
|
||||
- no spelling mistakes are found
|
||||
- No spelling mistakes are found
|
||||
"""
|
||||
|
||||
cas_dictionary = os.path.join(TestRun.usr.repo_dir, "test", "functional", "resources")
|
||||
|
@@ -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
|
||||
#
|
||||
|
||||
@@ -20,12 +20,11 @@ from test_tools.dd import Dd
|
||||
@pytest.mark.parametrize("purge_target", ["cache", "core"])
|
||||
def test_purge(purge_target):
|
||||
"""
|
||||
title: Call purge without and with `--script` switch
|
||||
description: |
|
||||
Check if purge is called only when `--script` switch is used.
|
||||
title: Basic test for purge command
|
||||
description: Check purge command behaviour with and without '--script' flag
|
||||
pass_criteria:
|
||||
- casadm returns an error when `--script` is missing
|
||||
- cache is wiped when purge command is used properly
|
||||
- Error returned when '--script' is missing
|
||||
- Cache is wiped when purge command is used properly
|
||||
"""
|
||||
with TestRun.step("Prepare devices"):
|
||||
cache_device = TestRun.disks["cache"]
|
||||
@@ -41,7 +40,7 @@ def test_purge(purge_target):
|
||||
cache = casadm.start_cache(cache_device, force=True)
|
||||
core = casadm.add_core(cache, core_device)
|
||||
|
||||
with TestRun.step("Trigger IO to prepared cache instance"):
|
||||
with TestRun.step("Trigger I/O to prepared cache instance"):
|
||||
dd = (
|
||||
Dd()
|
||||
.input("/dev/zero")
|
||||
@@ -79,8 +78,3 @@ def test_purge(purge_target):
|
||||
if cache.get_statistics().usage_stats.occupancy.get_value() != 0:
|
||||
TestRun.fail(f"{cache.get_statistics().usage_stats.occupancy.get_value()}")
|
||||
TestRun.fail(f"Purge {purge_target} should invalidate all cache lines!")
|
||||
|
||||
with TestRun.step(
|
||||
f"Stop cache"
|
||||
):
|
||||
casadm.stop_all_caches()
|
||||
|
@@ -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
|
||||
#
|
||||
|
||||
@@ -44,8 +44,8 @@ def test_standby_neg_cli_params():
|
||||
"""
|
||||
title: Verifying parameters for starting a standby cache instance
|
||||
description: |
|
||||
Try executing the standby init command with required arguments missing or
|
||||
disallowed arguments present.
|
||||
Try executing the standby init command with required arguments missing or
|
||||
disallowed arguments present.
|
||||
pass_criteria:
|
||||
- The execution is unsuccessful for all improper argument combinations
|
||||
- A proper error message is displayed for unsuccessful executions
|
||||
@@ -272,8 +272,8 @@ def test_start_neg_cli_flags():
|
||||
"""
|
||||
title: Blocking standby start command with mutually exclusive flags
|
||||
description: |
|
||||
Try executing the standby start command with different combinations of mutually
|
||||
exclusive flags.
|
||||
Try executing the standby start command with different combinations of mutually
|
||||
exclusive flags.
|
||||
pass_criteria:
|
||||
- The command execution is unsuccessful for commands with mutually exclusive flags
|
||||
- A proper error message is displayed
|
||||
@@ -327,7 +327,7 @@ def test_activate_without_detach():
|
||||
"""
|
||||
title: Activate cache without detach command.
|
||||
description: |
|
||||
Try activate passive cache without detach command before activation.
|
||||
Try to activate passive cache without detach command before activation.
|
||||
pass_criteria:
|
||||
- The activation is not possible
|
||||
- The cache remains in Standby state after unsuccessful activation
|
||||
@@ -390,14 +390,14 @@ def test_activate_without_detach():
|
||||
@pytest.mark.require_disk("standby_cache", DiskTypeSet([DiskType.nand, DiskType.optane]))
|
||||
def test_activate_neg_cache_line_size():
|
||||
"""
|
||||
title: Blocking cache with mismatching cache line size activation.
|
||||
description: |
|
||||
Try restoring cache operations from a replicated cache that was initialized
|
||||
with different cache line size than the original cache.
|
||||
pass_criteria:
|
||||
- The activation is cancelled
|
||||
- The cache remains in Standby detached state after an unsuccessful activation
|
||||
- A proper error message is displayed
|
||||
title: Blocking cache with mismatching cache line size activation.
|
||||
description: |
|
||||
Try restoring cache operations from a replicated cache that was initialized
|
||||
with different cache line size than the original cache.
|
||||
pass_criteria:
|
||||
- The activation is cancelled
|
||||
- The cache remains in Standby detached state after an unsuccessful activation
|
||||
- A proper error message is displayed
|
||||
"""
|
||||
|
||||
with TestRun.step("Prepare cache devices"):
|
||||
@@ -593,7 +593,7 @@ def test_standby_init_with_preexisting_filesystem(filesystem):
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("caches"))
|
||||
def test_standby_activate_with_corepool():
|
||||
"""
|
||||
title: Activate standby cache instance with corepool
|
||||
title: Activate standby cache instance with core pool
|
||||
description: |
|
||||
Activation of standby cache with core taken from core pool
|
||||
pass_criteria:
|
||||
@@ -652,12 +652,12 @@ def test_standby_activate_with_corepool():
|
||||
@pytest.mark.parametrizex("cache_line_size", CacheLineSize)
|
||||
def test_standby_start_stop(cache_line_size):
|
||||
"""
|
||||
title: Start and stop a standby cache instance.
|
||||
description: Test if cache can be started in standby state and stopped without activation.
|
||||
pass_criteria:
|
||||
- A cache exported object appears after starting a cache in standby state
|
||||
- The data written to the cache exported object committed on the underlying cache device
|
||||
- The cache exported object disappears after stopping the standby cache instance
|
||||
title: Start and stop a standby cache instance.
|
||||
description: Test if cache can be started in standby state and stopped without activation.
|
||||
pass_criteria:
|
||||
- A cache exported object appears after starting a cache in standby state
|
||||
- The data written to the cache exported object committed on the underlying cache device
|
||||
- The cache exported object disappears after stopping the standby cache instance
|
||||
"""
|
||||
with TestRun.step("Prepare a cache device"):
|
||||
cache_size = Size(500, Unit.MebiByte)
|
||||
|
@@ -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
|
||||
#
|
||||
|
||||
@@ -21,12 +21,12 @@ CORE_ID_RANGE = (0, 4095)
|
||||
@pytest.mark.parametrize("shortcut", [True, False])
|
||||
def test_cli_start_stop_default_id(shortcut):
|
||||
"""
|
||||
title: Test for starting a cache with a default ID - short and long command
|
||||
description: |
|
||||
Start a new cache with a default ID and then stop this cache.
|
||||
pass_criteria:
|
||||
- The cache has successfully started with default ID
|
||||
- The cache has successfully stopped
|
||||
title: Test for starting a cache with a default ID - short and long command
|
||||
description: |
|
||||
Start a new cache with a default ID and then stop this cache.
|
||||
pass_criteria:
|
||||
- The cache has successfully started with default ID
|
||||
- The cache has successfully stopped
|
||||
"""
|
||||
with TestRun.step("Prepare the device for the cache."):
|
||||
cache_device = TestRun.disks['cache']
|
||||
@@ -62,12 +62,12 @@ def test_cli_start_stop_default_id(shortcut):
|
||||
@pytest.mark.parametrize("shortcut", [True, False])
|
||||
def test_cli_start_stop_custom_id(shortcut):
|
||||
"""
|
||||
title: Test for starting a cache with a custom ID - short and long command
|
||||
description: |
|
||||
Start a new cache with a random ID (from allowed pool) and then stop this cache.
|
||||
pass_criteria:
|
||||
- The cache has successfully started with a custom ID
|
||||
- The cache has successfully stopped
|
||||
title: Test for starting a cache with a custom ID - short and long command
|
||||
description: |
|
||||
Start a new cache with a random ID (from allowed pool) and then stop this cache.
|
||||
pass_criteria:
|
||||
- The cache has successfully started with a custom ID
|
||||
- The cache has successfully stopped
|
||||
"""
|
||||
with TestRun.step("Prepare the device for the cache."):
|
||||
cache_device = TestRun.disks['cache']
|
||||
@@ -106,13 +106,13 @@ def test_cli_start_stop_custom_id(shortcut):
|
||||
@pytest.mark.parametrize("shortcut", [True, False])
|
||||
def test_cli_add_remove_default_id(shortcut):
|
||||
"""
|
||||
title: Test for adding and removing a core with a default ID - short and long command
|
||||
description: |
|
||||
Start a new cache and add a core to it without passing a core ID as an argument
|
||||
and then remove this core from the cache.
|
||||
pass_criteria:
|
||||
- The core is added to the cache with a default ID
|
||||
- The core is successfully removed from the cache
|
||||
title: Test for adding and removing a core with a default ID - short and long command
|
||||
description: |
|
||||
Start a new cache and add a core to it without passing a core ID as an argument
|
||||
and then remove this core from the cache.
|
||||
pass_criteria:
|
||||
- The core is added to the cache with a default ID
|
||||
- The core is successfully removed from the cache
|
||||
"""
|
||||
with TestRun.step("Prepare the devices."):
|
||||
cache_disk = TestRun.disks['cache']
|
||||
@@ -157,13 +157,13 @@ def test_cli_add_remove_default_id(shortcut):
|
||||
@pytest.mark.parametrize("shortcut", [True, False])
|
||||
def test_cli_add_remove_custom_id(shortcut):
|
||||
"""
|
||||
title: Test for adding and removing a core with a custom ID - short and long command
|
||||
description: |
|
||||
Start a new cache and add a core to it with passing a random core ID
|
||||
(from allowed pool) as an argument and then remove this core from the cache.
|
||||
pass_criteria:
|
||||
- The core is added to the cache with a default ID
|
||||
- The core is successfully removed from the cache
|
||||
title: Test for adding and removing a core with a custom ID - short and long command
|
||||
description: |
|
||||
Start a new cache and add a core to it with passing a random core ID
|
||||
(from allowed pool) as an argument and then remove this core from the cache.
|
||||
pass_criteria:
|
||||
- The core is added to the cache with a default ID
|
||||
- The core is successfully removed from the cache
|
||||
"""
|
||||
with TestRun.step("Prepare the devices."):
|
||||
cache_disk = TestRun.disks['cache']
|
||||
@@ -209,13 +209,13 @@ def test_cli_add_remove_custom_id(shortcut):
|
||||
@pytest.mark.parametrize("shortcut", [True, False])
|
||||
def test_cli_load_and_force(shortcut):
|
||||
"""
|
||||
title: Test if it is possible to use start command with 'load' and 'force' flag at once
|
||||
description: |
|
||||
Try to start cache with 'load' and 'force' options at the same time
|
||||
and check if it is not possible to do
|
||||
pass_criteria:
|
||||
- Start cache command with both 'force' and 'load' options should fail
|
||||
- Proper message should be received
|
||||
title: Test if it is possible to use start command with 'load' and 'force' flag at once
|
||||
description: |
|
||||
Try to start cache with 'load' and 'force' options at the same time
|
||||
and check if it is not possible to do
|
||||
pass_criteria:
|
||||
- Start cache command with both 'force' and 'load' options should fail
|
||||
- Proper message should be received
|
||||
"""
|
||||
with TestRun.step("Prepare cache."):
|
||||
cache_device = TestRun.disks['cache']
|
||||
|
@@ -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
|
||||
#
|
||||
|
||||
@@ -24,9 +24,10 @@ from test_tools.udev import Udev
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_cleaning_policy():
|
||||
"""
|
||||
Title: test manual casadm flush
|
||||
description: | The test is to see if dirty data will be removed from the Cache
|
||||
or Core after using the casadm command with the corresponding parameter.
|
||||
title: Test for manual cache and core flushing
|
||||
description: |
|
||||
The test is to see if dirty data will be removed from the cache
|
||||
or core after using the casadm command with the corresponding parameter.
|
||||
pass_criteria:
|
||||
- Cache and core are filled with dirty data.
|
||||
- After cache and core flush dirty data are cleared.
|
||||
|
@@ -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
|
||||
#
|
||||
|
||||
@@ -22,26 +22,26 @@ from type_def.size import Size, Unit
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_seq_cutoff_default_params():
|
||||
"""
|
||||
title: Default sequential cut-off threshold & policy test
|
||||
title: Default sequential cutoff threshold & policy test
|
||||
description: Test if proper default threshold and policy is set after cache start
|
||||
pass_criteria:
|
||||
- "Full" shall be default sequential cut-off policy
|
||||
- There shall be default 1MiB (1024kiB) value for sequential cut-off threshold
|
||||
- "Full" shall be default sequential cutoff policy
|
||||
- There shall be default 1MiB (1024kiB) value for sequential cutoff threshold
|
||||
"""
|
||||
with TestRun.step("Test prepare (start cache and add core)"):
|
||||
cache, cores = prepare()
|
||||
|
||||
with TestRun.step("Getting sequential cut-off parameters"):
|
||||
with TestRun.step("Getting sequential cutoff parameters"):
|
||||
params = cores[0].get_seq_cut_off_parameters()
|
||||
|
||||
with TestRun.step("Check if proper sequential cut off policy is set as a default"):
|
||||
with TestRun.step("Check if proper sequential cutoff policy is set as a default"):
|
||||
if params.policy != SeqCutOffPolicy.DEFAULT:
|
||||
TestRun.fail(f"Wrong sequential cut off policy set: {params.policy} "
|
||||
TestRun.fail(f"Wrong sequential cutoff policy set: {params.policy} "
|
||||
f"should be {SeqCutOffPolicy.DEFAULT}")
|
||||
|
||||
with TestRun.step("Check if proper sequential cut off threshold is set as a default"):
|
||||
with TestRun.step("Check if proper sequential cutoff threshold is set as a default"):
|
||||
if params.threshold != SEQ_CUT_OFF_THRESHOLD_DEFAULT:
|
||||
TestRun.fail(f"Wrong sequential cut off threshold set: {params.threshold} "
|
||||
TestRun.fail(f"Wrong sequential cutoff threshold set: {params.threshold} "
|
||||
f"should be {SEQ_CUT_OFF_THRESHOLD_DEFAULT}")
|
||||
|
||||
|
||||
@@ -50,32 +50,31 @@ def test_seq_cutoff_default_params():
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_seq_cutoff_set_get_policy_core(policy):
|
||||
"""
|
||||
title: Sequential cut-off policy set/get test for core
|
||||
title: Sequential cutoff policy set/get test for core
|
||||
description: |
|
||||
Test if CAS is setting proper sequential cut-off policy for core and
|
||||
returns previously set value
|
||||
Verify if it is possible to set and get a sequential cutoff policy per core
|
||||
pass_criteria:
|
||||
- Sequential cut-off policy obtained from get-param command for the first core must be
|
||||
- Sequential cutoff policy obtained from get-param command for the first core must be
|
||||
the same as the one used in set-param command
|
||||
- Sequential cut-off policy obtained from get-param command for the second core must be
|
||||
- Sequential cutoff policy obtained from get-param command for the second core must be
|
||||
proper default value
|
||||
"""
|
||||
with TestRun.step("Test prepare (start cache and add 2 cores)"):
|
||||
cache, cores = prepare(cores_count=2)
|
||||
|
||||
with TestRun.step(f"Setting core sequential cut off policy mode to {policy}"):
|
||||
with TestRun.step(f"Setting core sequential cutoff policy mode to {policy}"):
|
||||
cores[0].set_seq_cutoff_policy(policy)
|
||||
|
||||
with TestRun.step("Check if proper sequential cut off policy was set for the first core"):
|
||||
with TestRun.step("Check if proper sequential cutoff policy was set for the first core"):
|
||||
if cores[0].get_seq_cut_off_policy() != policy:
|
||||
TestRun.fail(f"Wrong sequential cut off policy set: "
|
||||
TestRun.fail(f"Wrong sequential cutoff policy set: "
|
||||
f"{cores[0].get_seq_cut_off_policy()} "
|
||||
f"should be {policy}")
|
||||
|
||||
with TestRun.step("Check if proper default sequential cut off policy was set for the "
|
||||
with TestRun.step("Check if proper default sequential cutoff policy was set for the "
|
||||
"second core"):
|
||||
if cores[1].get_seq_cut_off_policy() != SeqCutOffPolicy.DEFAULT:
|
||||
TestRun.fail(f"Wrong default sequential cut off policy: "
|
||||
TestRun.fail(f"Wrong default sequential cutoff policy: "
|
||||
f"{cores[1].get_seq_cut_off_policy()} "
|
||||
f"should be {SeqCutOffPolicy.DEFAULT}")
|
||||
|
||||
@@ -85,24 +84,23 @@ def test_seq_cutoff_set_get_policy_core(policy):
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_seq_cutoff_set_get_policy_cache(policy):
|
||||
"""
|
||||
title: Sequential cut-off policy set/get test for cache
|
||||
title: Sequential cutoff policy set/get test for cache
|
||||
description: |
|
||||
Test if CAS is setting proper sequential cut-off policy for whole cache and
|
||||
returns previously set value
|
||||
Verify if it is possible to set and get a sequential cutoff policy for the whole cache
|
||||
pass_criteria:
|
||||
- Sequential cut-off policy obtained from get-param command for each of 3 cores must be the
|
||||
- Sequential cutoff policy obtained from get-param command for each of 3 cores must be the
|
||||
same as the one used in set-param command for cache
|
||||
"""
|
||||
with TestRun.step("Test prepare (start cache and add 3 cores)"):
|
||||
cache, cores = prepare(cores_count=3)
|
||||
|
||||
with TestRun.step(f"Setting sequential cut off policy mode {policy} for cache"):
|
||||
with TestRun.step(f"Setting sequential cutoff policy mode {policy} for cache"):
|
||||
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 cut off policy was set for core"):
|
||||
with TestRun.step(f"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 cut off policy: "
|
||||
TestRun.fail(f"Wrong core sequential cutoff policy: "
|
||||
f"{cores[i].get_seq_cut_off_policy()} "
|
||||
f"should be {policy}")
|
||||
|
||||
@@ -111,23 +109,25 @@ def test_seq_cutoff_set_get_policy_cache(policy):
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_seq_cutoff_policy_load():
|
||||
"""
|
||||
title: Sequential cut-off policy set/get test with cache load between
|
||||
title: Sequential cutoff policy set/get test with cache load between
|
||||
description: |
|
||||
Set each possible policy for different core, stop cache, test if after cache load
|
||||
sequential cut-off policy value previously set is being loaded correctly for each core.
|
||||
Set each possible policy for different core, stop cache, test if after cache load
|
||||
sequential cutoff policy value previously set is being loaded correctly for each core.
|
||||
pass_criteria:
|
||||
- Sequential cut-off policy obtained from get-param command after cache load
|
||||
- Sequential cutoff policy obtained from get-param command after cache load
|
||||
must be the same as the one used in set-param command before cache stop
|
||||
- Sequential cut-off policy loaded for the last core should be the default one
|
||||
- Sequential cutoff policy loaded for the last core should be the default one
|
||||
"""
|
||||
with TestRun.step(f"Test prepare (start cache and add {len(SeqCutOffPolicy) + 1} cores)"):
|
||||
# Create as many cores as many possible policies including default one
|
||||
cache, cores = prepare(cores_count=len(SeqCutOffPolicy) + 1)
|
||||
policies = [policy for policy in SeqCutOffPolicy]
|
||||
|
||||
for i, core in TestRun.iteration(enumerate(cores[:-1]), "Set all possible policies "
|
||||
"except the default one"):
|
||||
with TestRun.step(f"Setting cache sequential cut off policy mode to "
|
||||
for i, core in TestRun.iteration(
|
||||
enumerate(cores[:-1]),
|
||||
"Set all possible policies except the default one"
|
||||
):
|
||||
with TestRun.step(f"Setting cache sequential cutoff policy mode to "
|
||||
f"{policies[i]}"):
|
||||
cores[i].set_seq_cutoff_policy(policies[i])
|
||||
|
||||
@@ -140,18 +140,21 @@ def test_seq_cutoff_policy_load():
|
||||
with TestRun.step("Getting cores from loaded cache"):
|
||||
cores = loaded_cache.get_core_devices()
|
||||
|
||||
for i, core in TestRun.iteration(enumerate(cores[:-1]), "Check if proper policies have "
|
||||
"been loaded"):
|
||||
with TestRun.step(f"Check if proper sequential cut off policy was loaded"):
|
||||
for i, core in TestRun.iteration(
|
||||
enumerate(cores[:-1]),
|
||||
"Check if proper policies have been loaded"
|
||||
):
|
||||
with TestRun.step(f"Check if proper sequential cutoff policy was loaded"):
|
||||
if cores[i].get_seq_cut_off_policy() != policies[i]:
|
||||
TestRun.fail(f"Wrong sequential cut off policy loaded: "
|
||||
TestRun.fail(f"Wrong sequential cutoff policy loaded: "
|
||||
f"{cores[i].get_seq_cut_off_policy()} "
|
||||
f"should be {policies[i]}")
|
||||
|
||||
with TestRun.step(f"Check if proper (default) sequential cut off policy was loaded for "
|
||||
f"last core"):
|
||||
with TestRun.step(
|
||||
"Check if proper (default) sequential cutoff policy was loaded for last core"
|
||||
):
|
||||
if cores[len(SeqCutOffPolicy)].get_seq_cut_off_policy() != SeqCutOffPolicy.DEFAULT:
|
||||
TestRun.fail(f"Wrong sequential cut off policy loaded: "
|
||||
TestRun.fail(f"Wrong sequential cutoff policy loaded: "
|
||||
f"{cores[len(SeqCutOffPolicy)].get_seq_cut_off_policy()} "
|
||||
f"should be {SeqCutOffPolicy.DEFAULT}")
|
||||
|
||||
@@ -163,16 +166,16 @@ def test_seq_cutoff_policy_load():
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_seq_cutoff_set_invalid_threshold(threshold):
|
||||
"""
|
||||
title: Invalid sequential cut-off threshold test
|
||||
description: Test if CAS is allowing setting invalid sequential cut-off threshold
|
||||
title: Invalid sequential cutoff threshold test
|
||||
description: Validate setting invalid sequential cutoff threshold
|
||||
pass_criteria:
|
||||
- Setting invalid sequential cut-off threshold should be blocked
|
||||
- Setting invalid sequential cutoff threshold should be blocked
|
||||
"""
|
||||
with TestRun.step("Test prepare (start cache and add core)"):
|
||||
cache, cores = prepare()
|
||||
_threshold = Size(threshold, Unit.KibiByte)
|
||||
|
||||
with TestRun.step(f"Setting cache sequential cut off threshold to out of range value: "
|
||||
with TestRun.step(f"Setting cache sequential cutoff threshold to out of range value: "
|
||||
f"{_threshold}"):
|
||||
command = set_param_cutoff_cmd(
|
||||
cache_id=str(cache.cache_id), core_id=str(cores[0].core_id),
|
||||
@@ -182,7 +185,7 @@ 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 cut off threshold "
|
||||
with TestRun.step(f"Setting cache sequential cutoff threshold "
|
||||
f"to value passed as a float"):
|
||||
command = set_param_cutoff_cmd(
|
||||
cache_id=str(cache.cache_id), core_id=str(cores[0].core_id),
|
||||
@@ -199,25 +202,23 @@ def test_seq_cutoff_set_invalid_threshold(threshold):
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_seq_cutoff_set_get_threshold(threshold):
|
||||
"""
|
||||
title: Sequential cut-off threshold set/get test
|
||||
description: |
|
||||
Test if CAS is setting proper sequential cut-off threshold and returns
|
||||
previously set value
|
||||
title: Sequential cutoff threshold set/get test
|
||||
description: Verify setting and getting value of sequential cutoff threshold
|
||||
pass_criteria:
|
||||
- Sequential cut-off threshold obtained from get-param command must be the same as
|
||||
- Sequential cutoff threshold obtained from get-param command must be the same as
|
||||
the one used in set-param command
|
||||
"""
|
||||
with TestRun.step("Test prepare (start cache and add core)"):
|
||||
cache, cores = prepare()
|
||||
_threshold = Size(threshold, Unit.KibiByte)
|
||||
|
||||
with TestRun.step(f"Setting cache sequential cut off threshold to "
|
||||
with TestRun.step(f"Setting cache sequential cutoff threshold to "
|
||||
f"{_threshold}"):
|
||||
cores[0].set_seq_cutoff_threshold(_threshold)
|
||||
|
||||
with TestRun.step("Check if proper sequential cut off threshold was set"):
|
||||
with TestRun.step("Check if proper sequential cutoff threshold was set"):
|
||||
if cores[0].get_seq_cut_off_threshold() != _threshold:
|
||||
TestRun.fail(f"Wrong sequential cut off threshold set: "
|
||||
TestRun.fail(f"Wrong sequential cutoff threshold set: "
|
||||
f"{cores[0].get_seq_cut_off_threshold()} "
|
||||
f"should be {_threshold}")
|
||||
|
||||
@@ -228,20 +229,17 @@ def test_seq_cutoff_set_get_threshold(threshold):
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_seq_cutoff_threshold_load(threshold):
|
||||
"""
|
||||
title: Sequential cut-off threshold set/get test with cache load between
|
||||
description: |
|
||||
Test if after cache load sequential cut-off threshold
|
||||
value previously set is being loaded correctly. Each of possible sequential cut-off
|
||||
policies is set for different core.
|
||||
title: Sequential cutoff threshold after loading cache
|
||||
description: Verify sequential cutoff threshold value after reloading the cache.
|
||||
pass_criteria:
|
||||
- Sequential cut-off threshold obtained from get-param command after cache load
|
||||
- Sequential cutoff threshold obtained from get-param command after cache load
|
||||
must be the same as the one used in set-param command before cache stop
|
||||
"""
|
||||
with TestRun.step("Test prepare (start cache and add core)"):
|
||||
cache, cores = prepare()
|
||||
_threshold = Size(threshold, Unit.KibiByte)
|
||||
|
||||
with TestRun.step(f"Setting cache sequential cut off threshold to "
|
||||
with TestRun.step(f"Setting cache sequential cutoff threshold to "
|
||||
f"{_threshold}"):
|
||||
cores[0].set_seq_cutoff_threshold(_threshold)
|
||||
|
||||
@@ -254,9 +252,9 @@ def test_seq_cutoff_threshold_load(threshold):
|
||||
with TestRun.step("Getting core from loaded cache"):
|
||||
cores_load = loaded_cache.get_core_devices()
|
||||
|
||||
with TestRun.step("Check if proper sequential cut off policy was loaded"):
|
||||
with TestRun.step("Check if proper sequential cutoff policy was loaded"):
|
||||
if cores_load[0].get_seq_cut_off_threshold() != _threshold:
|
||||
TestRun.fail(f"Wrong sequential cut off threshold set: "
|
||||
TestRun.fail(f"Wrong sequential cutoff threshold set: "
|
||||
f"{cores_load[0].get_seq_cut_off_threshold()} "
|
||||
f"should be {_threshold}")
|
||||
|
||||
|
@@ -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
|
||||
#
|
||||
|
||||
@@ -36,15 +36,15 @@ number_of_checks = 10
|
||||
@pytest.mark.parametrizex("cache_mode", CacheMode)
|
||||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_set_get_seqcutoff_params(cache_mode):
|
||||
def test_set_get_seq_cutoff_params(cache_mode):
|
||||
"""
|
||||
title: Test for setting and reading sequential cut-off parameters.
|
||||
description: |
|
||||
Verify that it is possible to set and read all available sequential cut-off
|
||||
parameters using casadm --set-param and --get-param options.
|
||||
pass_criteria:
|
||||
- All sequential cut-off parameters are set to given values.
|
||||
- All sequential cut-off parameters displays proper values.
|
||||
title: Test for setting and reading sequential cutoff parameters.
|
||||
description: |
|
||||
Verify that it is possible to set and read all available sequential cutoff
|
||||
parameters using casadm --set-param and --get-param options.
|
||||
pass_criteria:
|
||||
- All sequential cutoff parameters are set to given values.
|
||||
- All sequential cutoff parameters displays proper values.
|
||||
"""
|
||||
|
||||
with TestRun.step("Partition cache and core devices"):
|
||||
@@ -56,60 +56,60 @@ def test_set_get_seqcutoff_params(cache_mode):
|
||||
):
|
||||
caches, cores = cache_prepare(cache_mode, cache_dev, core_dev)
|
||||
|
||||
with TestRun.step("Check sequential cut-off default parameters"):
|
||||
default_seqcutoff_params = SeqCutOffParameters.default_seq_cut_off_params()
|
||||
with TestRun.step("Check sequential cutoff default parameters"):
|
||||
default_seq_cutoff_params = SeqCutOffParameters.default_seq_cut_off_params()
|
||||
for i in range(caches_count):
|
||||
for j in range(cores_per_cache):
|
||||
check_seqcutoff_parameters(cores[i][j], default_seqcutoff_params)
|
||||
check_seq_cutoff_parameters(cores[i][j], default_seq_cutoff_params)
|
||||
|
||||
with TestRun.step(
|
||||
"Set new random values for sequential cut-off parameters for one core only"
|
||||
"Set new random values for sequential cutoff parameters for one core only"
|
||||
):
|
||||
for check in range(number_of_checks):
|
||||
random_seqcutoff_params = new_seqcutoff_parameters_random_values()
|
||||
cores[0][0].set_seq_cutoff_parameters(random_seqcutoff_params)
|
||||
random_seq_cutoff_params = new_seq_cutoff_parameters_random_values()
|
||||
cores[0][0].set_seq_cutoff_parameters(random_seq_cutoff_params)
|
||||
|
||||
# Check changed parameters for first core:
|
||||
check_seqcutoff_parameters(cores[0][0], random_seqcutoff_params)
|
||||
check_seq_cutoff_parameters(cores[0][0], random_seq_cutoff_params)
|
||||
|
||||
# Check default parameters for other cores:
|
||||
for j in range(1, cores_per_cache):
|
||||
check_seqcutoff_parameters(cores[0][j], default_seqcutoff_params)
|
||||
check_seq_cutoff_parameters(cores[0][j], default_seq_cutoff_params)
|
||||
for i in range(1, caches_count):
|
||||
for j in range(cores_per_cache):
|
||||
check_seqcutoff_parameters(cores[i][j], default_seqcutoff_params)
|
||||
check_seq_cutoff_parameters(cores[i][j], default_seq_cutoff_params)
|
||||
|
||||
with TestRun.step(
|
||||
"Set new random values for sequential cut-off parameters "
|
||||
"Set new random values for sequential cutoff parameters "
|
||||
"for all cores within given cache instance"
|
||||
):
|
||||
for check in range(number_of_checks):
|
||||
random_seqcutoff_params = new_seqcutoff_parameters_random_values()
|
||||
caches[0].set_seq_cutoff_parameters(random_seqcutoff_params)
|
||||
random_seq_cutoff_params = new_seq_cutoff_parameters_random_values()
|
||||
caches[0].set_seq_cutoff_parameters(random_seq_cutoff_params)
|
||||
|
||||
# Check changed parameters for first cache instance:
|
||||
for j in range(cores_per_cache):
|
||||
check_seqcutoff_parameters(cores[0][j], random_seqcutoff_params)
|
||||
check_seq_cutoff_parameters(cores[0][j], random_seq_cutoff_params)
|
||||
|
||||
# Check default parameters for other cache instances:
|
||||
for i in range(1, caches_count):
|
||||
for j in range(cores_per_cache):
|
||||
check_seqcutoff_parameters(cores[i][j], default_seqcutoff_params)
|
||||
check_seq_cutoff_parameters(cores[i][j], default_seq_cutoff_params)
|
||||
|
||||
with TestRun.step(
|
||||
"Set new random values for sequential cut-off parameters for all cores"
|
||||
"Set new random values for sequential cutoff parameters for all cores"
|
||||
):
|
||||
for check in range(number_of_checks):
|
||||
seqcutoff_params = []
|
||||
seq_cutoff_params = []
|
||||
for i in range(caches_count):
|
||||
for j in range(cores_per_cache):
|
||||
random_seqcutoff_params = new_seqcutoff_parameters_random_values()
|
||||
seqcutoff_params.append(random_seqcutoff_params)
|
||||
cores[i][j].set_seq_cutoff_parameters(random_seqcutoff_params)
|
||||
random_seq_cutoff_params = new_seq_cutoff_parameters_random_values()
|
||||
seq_cutoff_params.append(random_seq_cutoff_params)
|
||||
cores[i][j].set_seq_cutoff_parameters(random_seq_cutoff_params)
|
||||
for i in range(caches_count):
|
||||
for j in range(cores_per_cache):
|
||||
check_seqcutoff_parameters(
|
||||
cores[i][j], seqcutoff_params[i * cores_per_cache + j]
|
||||
check_seq_cutoff_parameters(
|
||||
cores[i][j], seq_cutoff_params[i * cores_per_cache + j]
|
||||
)
|
||||
|
||||
|
||||
@@ -119,14 +119,14 @@ def test_set_get_seqcutoff_params(cache_mode):
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_set_get_cleaning_params(cache_mode, cleaning_policy):
|
||||
"""
|
||||
title: Test for setting and reading cleaning parameters.
|
||||
description: |
|
||||
Verify that it is possible to set and read all available cleaning
|
||||
parameters for all cleaning policies using casadm --set-param and
|
||||
--get-param options.
|
||||
pass_criteria:
|
||||
- All cleaning parameters are set to given values.
|
||||
- All cleaning parameters displays proper values.
|
||||
title: Test for setting and reading cleaning parameters.
|
||||
description: |
|
||||
Verify that it is possible to set and read all available cleaning
|
||||
parameters for all cleaning policies using casadm --set-param and
|
||||
--get-param options.
|
||||
pass_criteria:
|
||||
- All cleaning parameters are set to given values.
|
||||
- All cleaning parameters displays proper values.
|
||||
"""
|
||||
|
||||
with TestRun.step("Partition cache and core devices"):
|
||||
@@ -231,7 +231,7 @@ def cache_prepare(cache_mode, cache_dev, core_dev):
|
||||
return caches, cores
|
||||
|
||||
|
||||
def new_seqcutoff_parameters_random_values():
|
||||
def new_seq_cutoff_parameters_random_values():
|
||||
return SeqCutOffParameters(
|
||||
threshold=Size(random.randrange(1, 1000000), Unit.KibiByte),
|
||||
policy=random.choice(list(SeqCutOffPolicy)),
|
||||
@@ -275,27 +275,27 @@ def new_cleaning_parameters_random_values(cleaning_policy):
|
||||
return cleaning_params
|
||||
|
||||
|
||||
def check_seqcutoff_parameters(core, seqcutoff_params):
|
||||
current_seqcutoff_params = core.get_seq_cut_off_parameters()
|
||||
def check_seq_cutoff_parameters(core, seq_cutoff_params):
|
||||
current_seq_cutoff_params = core.get_seq_cut_off_parameters()
|
||||
failed_params = ""
|
||||
if current_seqcutoff_params.threshold != seqcutoff_params.threshold:
|
||||
if current_seq_cutoff_params.threshold != seq_cutoff_params.threshold:
|
||||
failed_params += (
|
||||
f"Threshold is {current_seqcutoff_params.threshold}, "
|
||||
f"should be {seqcutoff_params.threshold}\n"
|
||||
f"Threshold is {current_seq_cutoff_params.threshold}, "
|
||||
f"should be {seq_cutoff_params.threshold}\n"
|
||||
)
|
||||
if current_seqcutoff_params.policy != seqcutoff_params.policy:
|
||||
if current_seq_cutoff_params.policy != seq_cutoff_params.policy:
|
||||
failed_params += (
|
||||
f"Policy is {current_seqcutoff_params.policy}, "
|
||||
f"should be {seqcutoff_params.policy}\n"
|
||||
f"Policy is {current_seq_cutoff_params.policy}, "
|
||||
f"should be {seq_cutoff_params.policy}\n"
|
||||
)
|
||||
if current_seqcutoff_params.promotion_count != seqcutoff_params.promotion_count:
|
||||
if current_seq_cutoff_params.promotion_count != seq_cutoff_params.promotion_count:
|
||||
failed_params += (
|
||||
f"Promotion count is {current_seqcutoff_params.promotion_count}, "
|
||||
f"should be {seqcutoff_params.promotion_count}\n"
|
||||
f"Promotion count is {current_seq_cutoff_params.promotion_count}, "
|
||||
f"should be {seq_cutoff_params.promotion_count}\n"
|
||||
)
|
||||
if failed_params:
|
||||
TestRun.LOGGER.error(
|
||||
f"Sequential cut-off parameters are not correct "
|
||||
f"Sequential cutoff parameters are not correct "
|
||||
f"for {core.path}:\n{failed_params}"
|
||||
)
|
||||
|
||||
@@ -306,12 +306,12 @@ def check_cleaning_parameters(cache, cleaning_policy, cleaning_params):
|
||||
failed_params = ""
|
||||
if current_cleaning_params.wake_up_time != cleaning_params.wake_up_time:
|
||||
failed_params += (
|
||||
f"Wake Up time is {current_cleaning_params.wake_up_time}, "
|
||||
f"Wake up time is {current_cleaning_params.wake_up_time}, "
|
||||
f"should be {cleaning_params.wake_up_time}\n"
|
||||
)
|
||||
if current_cleaning_params.staleness_time != cleaning_params.staleness_time:
|
||||
failed_params += (
|
||||
f"Staleness Time is {current_cleaning_params.staleness_time}, "
|
||||
f"Staleness time is {current_cleaning_params.staleness_time}, "
|
||||
f"should be {cleaning_params.staleness_time}\n"
|
||||
)
|
||||
if (
|
||||
@@ -319,7 +319,7 @@ def check_cleaning_parameters(cache, cleaning_policy, cleaning_params):
|
||||
!= cleaning_params.flush_max_buffers
|
||||
):
|
||||
failed_params += (
|
||||
f"Flush Max Buffers is {current_cleaning_params.flush_max_buffers}, "
|
||||
f"Flush max buffers is {current_cleaning_params.flush_max_buffers}, "
|
||||
f"should be {cleaning_params.flush_max_buffers}\n"
|
||||
)
|
||||
if (
|
||||
@@ -327,7 +327,7 @@ def check_cleaning_parameters(cache, cleaning_policy, cleaning_params):
|
||||
!= cleaning_params.activity_threshold
|
||||
):
|
||||
failed_params += (
|
||||
f"Activity Threshold is {current_cleaning_params.activity_threshold}, "
|
||||
f"Activity threshold is {current_cleaning_params.activity_threshold}, "
|
||||
f"should be {cleaning_params.activity_threshold}\n"
|
||||
)
|
||||
if failed_params:
|
||||
@@ -341,7 +341,7 @@ def check_cleaning_parameters(cache, cleaning_policy, cleaning_params):
|
||||
failed_params = ""
|
||||
if current_cleaning_params.wake_up_time != cleaning_params.wake_up_time:
|
||||
failed_params += (
|
||||
f"Wake Up time is {current_cleaning_params.wake_up_time}, "
|
||||
f"Wake up time is {current_cleaning_params.wake_up_time}, "
|
||||
f"should be {cleaning_params.wake_up_time}\n"
|
||||
)
|
||||
if (
|
||||
@@ -349,7 +349,7 @@ def check_cleaning_parameters(cache, cleaning_policy, cleaning_params):
|
||||
!= cleaning_params.flush_max_buffers
|
||||
):
|
||||
failed_params += (
|
||||
f"Flush Max Buffers is {current_cleaning_params.flush_max_buffers}, "
|
||||
f"Flush max buffers is {current_cleaning_params.flush_max_buffers}, "
|
||||
f"should be {cleaning_params.flush_max_buffers}\n"
|
||||
)
|
||||
if failed_params:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Copyright(c) 2021 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
import time
|
||||
@@ -24,20 +24,19 @@ from type_def.size import Size, Unit
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_zero_metadata_negative_cases():
|
||||
"""
|
||||
title: Test for '--zero-metadata' negative cases.
|
||||
description: |
|
||||
Test for '--zero-metadata' scenarios with expected failures.
|
||||
pass_criteria:
|
||||
- Zeroing metadata without '--force' failed when run on cache.
|
||||
- Zeroing metadata with '--force' failed when run on cache.
|
||||
- Zeroing metadata failed when run on system drive.
|
||||
- Load cache command failed after successfully zeroing metadata on the cache device.
|
||||
title: Test for '--zero-metadata' negative cases.
|
||||
description: Test for '--zero-metadata' scenarios with expected failures.
|
||||
pass_criteria:
|
||||
- Zeroing metadata without '--force' failed when run on cache.
|
||||
- Zeroing metadata with '--force' failed when run on cache.
|
||||
- Zeroing metadata failed when run on system drive.
|
||||
- Load cache command failed after successfully zeroing metadata on the cache device.
|
||||
"""
|
||||
with TestRun.step("Prepare cache and core devices."):
|
||||
cache_dev, core_dev, cache_disk = prepare_devices()
|
||||
|
||||
with TestRun.step("Start cache."):
|
||||
cache = casadm.start_cache(cache_dev, force=True)
|
||||
casadm.start_cache(cache_dev, force=True)
|
||||
|
||||
with TestRun.step("Try to zero metadata and validate error message."):
|
||||
try:
|
||||
@@ -75,7 +74,7 @@ def test_zero_metadata_negative_cases():
|
||||
|
||||
with TestRun.step("Load cache."):
|
||||
try:
|
||||
cache = casadm.load_cache(cache_dev)
|
||||
casadm.load_cache(cache_dev)
|
||||
TestRun.LOGGER.error("Loading cache should fail.")
|
||||
except CmdException:
|
||||
TestRun.LOGGER.info("Loading cache failed as expected.")
|
||||
@@ -86,12 +85,11 @@ def test_zero_metadata_negative_cases():
|
||||
@pytest.mark.parametrizex("filesystem", Filesystem)
|
||||
def test_zero_metadata_filesystem(filesystem):
|
||||
"""
|
||||
title: Test for '--zero-metadata' and filesystem.
|
||||
description: |
|
||||
Test for '--zero-metadata' on drive with filesystem.
|
||||
pass_criteria:
|
||||
- Zeroing metadata on device with filesystem failed and not removed filesystem.
|
||||
- Zeroing metadata on mounted device failed.
|
||||
title: Test for '--zero-metadata' and filesystem.
|
||||
description: Test for '--zero-metadata' on drive with filesystem.
|
||||
pass_criteria:
|
||||
- Zeroing metadata on device with filesystem failed and not removed filesystem.
|
||||
- Zeroing metadata on mounted device failed.
|
||||
"""
|
||||
mount_point = "/mnt"
|
||||
with TestRun.step("Prepare devices."):
|
||||
@@ -131,14 +129,14 @@ def test_zero_metadata_filesystem(filesystem):
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_zero_metadata_dirty_data():
|
||||
"""
|
||||
title: Test for '--zero-metadata' and dirty data scenario.
|
||||
description: |
|
||||
Test for '--zero-metadata' with and without 'force' option if there are dirty data
|
||||
on cache.
|
||||
pass_criteria:
|
||||
- Zeroing metadata without force failed on cache with dirty data.
|
||||
- Zeroing metadata with force ran successfully on cache with dirty data.
|
||||
- Cache started successfully after zeroing metadata on cache with dirty data.
|
||||
title: Test for '--zero-metadata' and dirty data scenario.
|
||||
description: |
|
||||
Test for '--zero-metadata' with and without 'force' option if there are dirty data
|
||||
on cache.
|
||||
pass_criteria:
|
||||
- Zeroing metadata without force failed on cache with dirty data.
|
||||
- Zeroing metadata with force ran successfully on cache with dirty data.
|
||||
- Cache started successfully after zeroing metadata on cache with dirty data.
|
||||
"""
|
||||
with TestRun.step("Prepare cache and core devices."):
|
||||
cache_dev, core_disk, cache_disk = prepare_devices()
|
||||
@@ -165,7 +163,7 @@ def test_zero_metadata_dirty_data():
|
||||
|
||||
with TestRun.step("Start cache (expect to fail)."):
|
||||
try:
|
||||
cache = casadm.start_cache(cache_dev, CacheMode.WB)
|
||||
casadm.start_cache(cache_dev, CacheMode.WB)
|
||||
except CmdException:
|
||||
TestRun.LOGGER.info("Start cache failed as expected.")
|
||||
|
||||
@@ -186,7 +184,7 @@ def test_zero_metadata_dirty_data():
|
||||
|
||||
with TestRun.step("Start cache without 'force' option."):
|
||||
try:
|
||||
cache = casadm.start_cache(cache_dev, CacheMode.WB)
|
||||
casadm.start_cache(cache_dev, CacheMode.WB)
|
||||
TestRun.LOGGER.info("Cache started successfully.")
|
||||
except CmdException:
|
||||
TestRun.LOGGER.error("Start cache failed.")
|
||||
@@ -196,21 +194,21 @@ def test_zero_metadata_dirty_data():
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_zero_metadata_dirty_shutdown():
|
||||
"""
|
||||
title: Test for '--zero-metadata' and dirty shutdown scenario.
|
||||
description: |
|
||||
Test for '--zero-metadata' with and without 'force' option on cache which had been dirty
|
||||
shut down before.
|
||||
pass_criteria:
|
||||
- Zeroing metadata without force failed on cache after dirty shutdown.
|
||||
- Zeroing metadata with force ran successfully on cache after dirty shutdown.
|
||||
- Cache started successfully after dirty shutdown and zeroing metadata on cache.
|
||||
title: Test for '--zero-metadata' and dirty shutdown scenario.
|
||||
description: |
|
||||
Test for '--zero-metadata' with and without 'force' option on cache which had been dirty
|
||||
shut down before.
|
||||
pass_criteria:
|
||||
- Zeroing metadata without force failed on cache after dirty shutdown.
|
||||
- Zeroing metadata with force ran successfully on cache after dirty shutdown.
|
||||
- Cache started successfully after dirty shutdown and zeroing metadata on cache.
|
||||
"""
|
||||
with TestRun.step("Prepare cache and core devices."):
|
||||
cache_dev, core_disk, cache_disk = prepare_devices()
|
||||
|
||||
with TestRun.step("Start cache."):
|
||||
cache = casadm.start_cache(cache_dev, CacheMode.WT, force=True)
|
||||
core = cache.add_core(core_disk)
|
||||
cache.add_core(core_disk)
|
||||
|
||||
with TestRun.step("Unplug cache device."):
|
||||
cache_disk.unplug()
|
||||
@@ -227,7 +225,7 @@ def test_zero_metadata_dirty_shutdown():
|
||||
|
||||
with TestRun.step("Start cache (expect to fail)."):
|
||||
try:
|
||||
cache = casadm.start_cache(cache_dev, CacheMode.WT)
|
||||
casadm.start_cache(cache_dev, CacheMode.WT)
|
||||
TestRun.LOGGER.error("Starting cache should fail!")
|
||||
except CmdException:
|
||||
TestRun.LOGGER.info("Start cache failed as expected.")
|
||||
@@ -249,7 +247,7 @@ def test_zero_metadata_dirty_shutdown():
|
||||
|
||||
with TestRun.step("Start cache."):
|
||||
try:
|
||||
cache = casadm.start_cache(cache_dev, CacheMode.WT)
|
||||
casadm.start_cache(cache_dev, CacheMode.WT)
|
||||
TestRun.LOGGER.info("Cache started successfully.")
|
||||
except CmdException:
|
||||
TestRun.LOGGER.error("Start cache failed.")
|
||||
|
Reference in New Issue
Block a user