Update statistics usage to use stats classes
Rename set_statistics_deprecated to set_statistics_flat, as flat statistics are sometimes more useful and actually not deprecated. Signed-off-by: Daniel Madej <daniel.madej@intel.com>
This commit is contained in:
@@ -7,11 +7,11 @@ import random
|
||||
|
||||
import pytest
|
||||
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from test_tools.dd import Dd
|
||||
from test_tools.disk_utils import Filesystem
|
||||
from test_utils.filesystem.file import File
|
||||
from test_utils.os_utils import sync, Udev, DropCachesMode, drop_caches
|
||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||
from .io_class_common import *
|
||||
|
||||
|
||||
@@ -56,8 +56,9 @@ def test_ioclass_file_extension():
|
||||
for i in range(iterations):
|
||||
dd.run()
|
||||
sync()
|
||||
stats = cache.get_statistics_deprecated(io_class_id=ioclass_id)
|
||||
assert stats["dirty"].get_value(Unit.Blocks4096) == (i + 1) * dd_count
|
||||
dirty = cache.get_io_class_statistics(io_class_id=ioclass_id).usage_stats.dirty
|
||||
if dirty.get_value(Unit.Blocks4096) != (i + 1) * dd_count:
|
||||
TestRun.LOGGER.error(f"Wrong amount of dirty data ({dirty}).")
|
||||
|
||||
cache.flush_cache()
|
||||
|
||||
@@ -73,8 +74,9 @@ def test_ioclass_file_extension():
|
||||
)
|
||||
dd.run()
|
||||
sync()
|
||||
stats = cache.get_statistics_deprecated(io_class_id=ioclass_id)
|
||||
assert stats["dirty"].get_value(Unit.Blocks4096) == 0
|
||||
dirty = cache.get_io_class_statistics(io_class_id=ioclass_id).usage_stats.dirty
|
||||
if dirty.get_value(Unit.Blocks4096) != 0:
|
||||
TestRun.LOGGER.error(f"Wrong amount of dirty data ({dirty}).")
|
||||
|
||||
|
||||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||
@@ -213,11 +215,9 @@ def test_ioclass_file_extension_preexisting_filesystem():
|
||||
)
|
||||
dd.run()
|
||||
sync()
|
||||
stats = cache.get_statistics_deprecated(io_class_id=ioclass_id)
|
||||
assert (
|
||||
stats["dirty"].get_value(Unit.Blocks4096)
|
||||
== (extensions.index(ext) + 1) * dd_count
|
||||
)
|
||||
dirty = cache.get_io_class_statistics(io_class_id=ioclass_id).usage_stats.dirty
|
||||
if dirty.get_value(Unit.Blocks4096) != (extensions.index(ext) + 1) * dd_count:
|
||||
TestRun.LOGGER.error(f"Wrong amount of dirty data ({dirty}).")
|
||||
|
||||
|
||||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||
@@ -269,10 +269,9 @@ def test_ioclass_file_offset():
|
||||
)
|
||||
dd.run()
|
||||
sync()
|
||||
stats = cache.get_statistics_deprecated(io_class_id=ioclass_id)
|
||||
assert (
|
||||
stats["dirty"].get_value(Unit.Blocks4096) == 1
|
||||
), f"Offset not cached: {file_offset}"
|
||||
dirty = cache.get_io_class_statistics(io_class_id=ioclass_id).usage_stats.dirty
|
||||
if dirty.get_value(Unit.Blocks4096) != 1:
|
||||
TestRun.LOGGER.error(f"Offset not cached: {file_offset}")
|
||||
cache.flush_cache()
|
||||
|
||||
min_seek = 0
|
||||
@@ -290,10 +289,9 @@ def test_ioclass_file_offset():
|
||||
)
|
||||
dd.run()
|
||||
sync()
|
||||
stats = cache.get_statistics_deprecated(io_class_id=ioclass_id)
|
||||
assert (
|
||||
stats["dirty"].get_value(Unit.Blocks4096) == 0
|
||||
), f"Inappropriately cached offset: {file_offset}"
|
||||
dirty = cache.get_io_class_statistics(io_class_id=ioclass_id).usage_stats.dirty
|
||||
if dirty.get_value(Unit.Blocks4096) != 0:
|
||||
TestRun.LOGGER.error(f"Inappropriately cached offset: {file_offset}")
|
||||
|
||||
|
||||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||
@@ -349,10 +347,12 @@ def test_ioclass_file_size(filesystem):
|
||||
TestRun.LOGGER.info("Creating files belonging to different IO classes "
|
||||
"(classification by writes).")
|
||||
for size, ioclass_id in size_to_class.items():
|
||||
occupancy_before = cache.get_statistics_deprecated(io_class_id=ioclass_id)["occupancy"]
|
||||
occupancy_before = cache.get_io_class_statistics(
|
||||
io_class_id=ioclass_id).usage_stats.occupancy
|
||||
file_path = f"{mountpoint}/test_file_{size.get_value()}"
|
||||
Dd().input("/dev/zero").output(file_path).oflag("sync").block_size(size).count(1).run()
|
||||
occupancy_after = cache.get_statistics_deprecated(io_class_id=ioclass_id)["occupancy"]
|
||||
occupancy_after = cache.get_io_class_statistics(
|
||||
io_class_id=ioclass_id).usage_stats.occupancy
|
||||
if occupancy_after != occupancy_before + size:
|
||||
pytest.xfail("File not cached properly!\n"
|
||||
f"Expected {occupancy_before + size}\n"
|
||||
@@ -366,9 +366,11 @@ def test_ioclass_file_size(filesystem):
|
||||
"(classification by reads).")
|
||||
for file in test_files:
|
||||
ioclass_id = size_to_class[file.size]
|
||||
occupancy_before = cache.get_statistics_deprecated(io_class_id=ioclass_id)["occupancy"]
|
||||
occupancy_before = cache.get_io_class_statistics(
|
||||
io_class_id=ioclass_id).usage_stats.occupancy
|
||||
Dd().input(file.full_path).output("/dev/null").block_size(file.size).run()
|
||||
occupancy_after = cache.get_statistics_deprecated(io_class_id=ioclass_id)["occupancy"]
|
||||
occupancy_after = cache.get_io_class_statistics(
|
||||
io_class_id=ioclass_id).usage_stats.occupancy
|
||||
if occupancy_after != occupancy_before + file.size:
|
||||
pytest.xfail("File not reclassified properly!\n"
|
||||
f"Expected {occupancy_before + file.size}\n"
|
||||
@@ -390,10 +392,10 @@ def test_ioclass_file_size(filesystem):
|
||||
ioclass_config_path=ioclass_config_path,
|
||||
)
|
||||
casadm.load_io_classes(cache_id=cache.cache_id, file=ioclass_config_path)
|
||||
occupancy_before = cache.get_statistics_deprecated(io_class_id=0)["occupancy"]
|
||||
occupancy_before = cache.get_io_class_statistics(io_class_id=0).usage_stats.occupancy
|
||||
for file in test_files:
|
||||
Dd().input(file.full_path).output("/dev/null").block_size(file.size).run()
|
||||
occupancy_after = cache.get_statistics_deprecated(io_class_id=0)["occupancy"]
|
||||
occupancy_after = cache.get_io_class_statistics(io_class_id=0).usage_stats.occupancy
|
||||
if occupancy_after != occupancy_before + file.size:
|
||||
pytest.xfail("File not reclassified properly!\n"
|
||||
f"Expected {occupancy_before + file.size}\n"
|
||||
|
Reference in New Issue
Block a user