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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user