Refactor IO class tests

Signed-off-by: Klaudia Jablonska <klaudia.jablonska@intel.com>
This commit is contained in:
Klaudia Jablonska
2022-08-29 16:04:22 +02:00
parent 2da9753a10
commit 1cf2af7ed4
17 changed files with 1100 additions and 883 deletions

View File

@@ -1,5 +1,5 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -20,11 +20,11 @@ from tests.io_class.io_class_common import prepare, ioclass_config_path
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
def test_ioclass_process_name():
"""
title: Test IO classification by process name.
description: Check if data generated by process with particular name is cached.
pass_criteria:
- No kernel bug.
- IO is classified properly based on process generating IO name.
title: Test IO classification by process name.
description: Check if data generated by process with particular name is cached.
pass_criteria:
- No kernel bug.
- IO is classified properly based on process generating IO name.
"""
ioclass_id = 1
dd_size = Size(4, Unit.KibiByte)
@@ -50,15 +50,15 @@ def test_ioclass_process_name():
with TestRun.step("Check if all data generated by dd process is cached."):
for i in range(iterations):
dd = (
(
Dd()
.input("/dev/zero")
.output(core.path)
.count(dd_count)
.block_size(dd_size)
.seek(i)
.run()
)
dd.run()
sync()
time.sleep(0.1)
dirty = cache.get_io_class_statistics(io_class_id=ioclass_id).usage_stats.dirty
@@ -70,11 +70,11 @@ def test_ioclass_process_name():
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
def test_ioclass_pid():
"""
title: Test IO classification by process id.
description: Check if data generated by process with particular id is cached.
pass_criteria:
- No kernel bug.
- IO is classified properly based on process generating IO id.
title: Test IO classification by process id.
description: Check if data generated by process with particular id is cached.
pass_criteria:
- No kernel bug.
- IO is classified properly based on process generating IO id.
"""
ioclass_id = 1
iterations = 20
@@ -89,11 +89,7 @@ def test_ioclass_pid():
# Since 'dd' has to be executed right after writing pid to 'ns_last_pid',
# 'dd' command is created and is appended to 'echo' command instead of running it
dd_command = str(
Dd()
.input("/dev/zero")
.output(core.path)
.count(dd_count)
.block_size(dd_size)
Dd().input("/dev/zero").output(core.path).count(dd_count).block_size(dd_size)
)
for _ in TestRun.iteration(range(iterations)):
@@ -117,12 +113,12 @@ def test_ioclass_pid():
rule=f"pid:eq:{pid}&done",
ioclass_config_path=ioclass_config_path,
)
casadm.load_io_classes(cache_id=cache.cache_id, file=ioclass_config_path)
casadm.load_io_classes(cache.cache_id, ioclass_config_path)
with TestRun.step(f"Run dd with pid {pid}."):
# pid saved in 'ns_last_pid' has to be smaller by one than target dd pid
dd_and_pid_command = (
f"echo {pid-1} > /proc/sys/kernel/ns_last_pid && {dd_command} "
f"echo {pid - 1} > /proc/sys/kernel/ns_last_pid && {dd_command} "
f"&& cat /proc/sys/kernel/ns_last_pid"
)
output = TestRun.executor.run(dd_and_pid_command)
@@ -136,4 +132,4 @@ def test_ioclass_pid():
dirty = cache.get_io_class_statistics(io_class_id=ioclass_id).usage_stats.dirty
if dirty.get_value(Unit.Blocks4096) != dd_count:
TestRun.LOGGER.error(f"Wrong amount of dirty data ({dirty}).")
ioclass_config.remove_ioclass(ioclass_id)
ioclass_config.remove_ioclass(ioclass_id, ioclass_config_path)