Refactor IO class tests
Signed-off-by: Klaudia Jablonska <klaudia.jablonska@intel.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright(c) 2020-2021 Intel Corporation
|
||||
# Copyright(c) 2020-2022 Intel Corporation
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
@@ -23,13 +23,13 @@ from tests.io_class.io_class_common import prepare, mountpoint, ioclass_config_p
|
||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||
def test_ioclass_usage_sum():
|
||||
"""
|
||||
title: Test for ioclass stats after purge
|
||||
description: |
|
||||
Create ioclasses for 3 different directories. Run IO against each
|
||||
directory, check usage stats correctness before and after purge
|
||||
pass_criteria:
|
||||
- Usage stats are consistent on each test step
|
||||
- Usage stats don't exceed cache size
|
||||
title: Test for ioclass stats after purge
|
||||
description: |
|
||||
Create io classes for 3 different directories. Run IO against each
|
||||
directory, check usage stats correctness before and after purge.
|
||||
pass_criteria:
|
||||
- Usage stats are consistent on each test step
|
||||
- Usage stats don't exceed cache size
|
||||
"""
|
||||
with TestRun.step("Prepare disks"):
|
||||
cache, core = prepare()
|
||||
@@ -38,9 +38,7 @@ def test_ioclass_usage_sum():
|
||||
with TestRun.step("Disable udev"):
|
||||
Udev.disable()
|
||||
|
||||
with TestRun.step(
|
||||
f"Prepare filesystem and mount {core.path} at {mountpoint}"
|
||||
):
|
||||
with TestRun.step(f"Prepare filesystem and mount {core.path} at {mountpoint}"):
|
||||
filesystem = Filesystem.xfs
|
||||
core.create_filesystem(filesystem)
|
||||
core.mount(mountpoint)
|
||||
@@ -58,7 +56,7 @@ def test_ioclass_usage_sum():
|
||||
for io_class in io_classes:
|
||||
fs_utils.create_directory(io_class.dir_path, parents=True)
|
||||
|
||||
with TestRun.step("Add ioclasses for all dirs"):
|
||||
with TestRun.step("Add io classes for all dirs"):
|
||||
ioclass_config.remove_ioclass_config()
|
||||
ioclass_config.create_ioclass_config(True)
|
||||
for io_class in io_classes:
|
||||
@@ -71,10 +69,8 @@ def test_ioclass_usage_sum():
|
||||
casadm.load_io_classes(cache_id=cache.cache_id, file=ioclass_config_path)
|
||||
|
||||
# Since default ioclass is already present in cache and no directory should be
|
||||
# created, it is added to ioclasses list after setup is done
|
||||
io_classes.append(
|
||||
IoclassConfig(default_ioclass_id, 22, f"{mountpoint}", cache_size * 0.2)
|
||||
)
|
||||
# created, it is added to io classes list after setup is done
|
||||
io_classes.append(IoclassConfig(default_ioclass_id, 22, f"{mountpoint}", cache_size * 0.2))
|
||||
|
||||
with TestRun.step("Verify stats of newly started cache device"):
|
||||
sync()
|
||||
@@ -83,7 +79,7 @@ def test_ioclass_usage_sum():
|
||||
|
||||
with TestRun.step("Trigger IO to each partition and verify stats"):
|
||||
for io_class in io_classes:
|
||||
run_io_dir(io_class.dir_path, int((io_class.io_size) / Unit.Blocks4096))
|
||||
run_io_dir(io_class.dir_path, int(io_class.io_size / Unit.Blocks4096.get_value()))
|
||||
|
||||
verify_ioclass_usage_stats(cache, [i.id for i in io_classes])
|
||||
|
||||
@@ -92,11 +88,9 @@ def test_ioclass_usage_sum():
|
||||
|
||||
verify_ioclass_usage_stats(cache, [i.id for i in io_classes])
|
||||
|
||||
with TestRun.step(
|
||||
"Trigger IO to each partition for the second time and verify stats"
|
||||
):
|
||||
with TestRun.step("Trigger IO to each partition for the second time and verify stats"):
|
||||
for io_class in io_classes:
|
||||
run_io_dir(io_class.dir_path, int((io_class.io_size) / Unit.Blocks4096))
|
||||
run_io_dir(io_class.dir_path, int(io_class.io_size / Unit.Blocks4096.get_value()))
|
||||
|
||||
verify_ioclass_usage_stats(cache, [i.id for i in io_classes])
|
||||
|
||||
@@ -116,9 +110,9 @@ def verify_ioclass_usage_stats(cache, ioclasses_ids):
|
||||
|
||||
if usage_stats_sum != cache_usage_stats:
|
||||
TestRun.LOGGER.error(
|
||||
"Sum of ioclasses usage stats doesn't match cache usage stats!"
|
||||
f" Cache stats:\n{cache_usage_stats} ioclasses sum:\n{usage_stats_sum}"
|
||||
f" Stats of particular ioclasses:\n"
|
||||
"Sum of io classes usage stats doesn't match cache usage stats!"
|
||||
f" Cache stats:\n{cache_usage_stats} io classes sum:\n{usage_stats_sum}"
|
||||
f" Stats of particular io classes:\n"
|
||||
f"{[get_io_class_usage(cache, i) for i in ioclasses_ids]}"
|
||||
)
|
||||
|
||||
@@ -141,13 +135,13 @@ def add_io_class(class_id, eviction_prio, rule):
|
||||
|
||||
|
||||
def run_io_dir(path, num_ios):
|
||||
dd = (
|
||||
(
|
||||
Dd()
|
||||
.input("/dev/zero")
|
||||
.output(f"{path}/tmp_file")
|
||||
.count(num_ios)
|
||||
.block_size(Size(1, Unit.Blocks4096))
|
||||
.run()
|
||||
)
|
||||
dd.run()
|
||||
sync()
|
||||
drop_caches(DropCachesMode.ALL)
|
||||
|
Reference in New Issue
Block a user