Update test_stats_max tests
Signed-off-by: Daniel Madej <daniel.madej@huawei.com>
This commit is contained in:
parent
aa0dc4d7ee
commit
6e781fe464
@ -1,22 +1,23 @@
|
|||||||
#
|
#
|
||||||
# Copyright(c) 2020-2021 Intel Corporation
|
# Copyright(c) 2020-2021 Intel Corporation
|
||||||
|
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from api.cas import casadm
|
from api.cas import casadm
|
||||||
from api.cas.cache_config import CacheMode, CleaningPolicy
|
from api.cas.cache_config import CacheMode, CleaningPolicy
|
||||||
from api.cas.casadm import StatsFilter
|
from api.cas.casadm import StatsFilter
|
||||||
|
from api.cas.statistics import get_stats_dict, get_stat_value
|
||||||
from core.test_run import TestRun
|
from core.test_run import TestRun
|
||||||
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
|
||||||
from test_tools.fio.fio import Fio
|
from test_tools.fio.fio import Fio
|
||||||
from test_tools.fio.fio_param import ReadWrite, IoEngine
|
from test_tools.fio.fio_param import ReadWrite, IoEngine
|
||||||
from test_utils.os_utils import Udev
|
from test_utils.os_utils import Udev
|
||||||
from test_utils.size import Size, Unit
|
from test_utils.size import Size, Unit
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
|
|
||||||
cache_size = Size(1, Unit.GibiByte)
|
cache_size = Size(1, Unit.GibiByte)
|
||||||
core_size = Size(2, Unit.GibiByte)
|
core_size = Size(2, Unit.GibiByte)
|
||||||
@ -33,7 +34,7 @@ def test_stat_max_cache():
|
|||||||
Check CAS ability to display correct values in statistics
|
Check CAS ability to display correct values in statistics
|
||||||
for 16 cache devices per cache mode.
|
for 16 cache devices per cache mode.
|
||||||
pass_criteria:
|
pass_criteria:
|
||||||
- Core's statistics matches cache's statistics.
|
- Cores' statistics match cache's statistics.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
caches_per_cache_mode = 16
|
caches_per_cache_mode = 16
|
||||||
@ -82,20 +83,21 @@ def test_stat_max_cache():
|
|||||||
fio.run()
|
fio.run()
|
||||||
sleep(3)
|
sleep(3)
|
||||||
|
|
||||||
with TestRun.step("Check if cache's statistics matches core's statistics"):
|
with TestRun.step("Check if cache's statistics match cores' statistics"):
|
||||||
for i in range(caches_count):
|
for i in range(caches_count):
|
||||||
cache_stats = caches[i].get_statistics_flat(stat_filter=stat_filter)
|
cache_stats = get_stats_dict(filter=stat_filter, cache_id=caches[i].cache_id)
|
||||||
cores_stats = [
|
cores_stats = [
|
||||||
cores[i][j].get_statistics_flat(stat_filter=stat_filter)
|
get_stats_dict(
|
||||||
for j in range(cores_per_cache)
|
filter=stat_filter, cache_id=caches[i].cache_id, core_id=cores[i][j].core_id
|
||||||
|
) for j in range(cores_per_cache)
|
||||||
]
|
]
|
||||||
fail_message = f"For cache ID {caches[i].cache_id} "
|
fail_message = f"For cache ID {caches[i].cache_id} ({caches[i].get_cache_mode()}) "
|
||||||
stats_compare(cache_stats, cores_stats, cores_per_cache, fail_message)
|
stats_compare(cache_stats, cores_stats, cores_per_cache, fail_message)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrizex("cache_mode", CacheMode)
|
|
||||||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||||
|
@pytest.mark.parametrizex("cache_mode", CacheMode)
|
||||||
def test_stat_max_core(cache_mode):
|
def test_stat_max_core(cache_mode):
|
||||||
"""
|
"""
|
||||||
title: CAS statistics values for maximum core devices.
|
title: CAS statistics values for maximum core devices.
|
||||||
@ -103,7 +105,7 @@ def test_stat_max_core(cache_mode):
|
|||||||
Check CAS ability to display correct values in statistics
|
Check CAS ability to display correct values in statistics
|
||||||
for 62 core devices.
|
for 62 core devices.
|
||||||
pass_criteria:
|
pass_criteria:
|
||||||
- Core's statistics matches cache's statistics.
|
- Cores' statistics match cache's statistics.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cores_per_cache = 62
|
cores_per_cache = 62
|
||||||
@ -132,11 +134,12 @@ def test_stat_max_core(cache_mode):
|
|||||||
fio.run()
|
fio.run()
|
||||||
sleep(3)
|
sleep(3)
|
||||||
|
|
||||||
with TestRun.step("Check if cache's statistics matches core's statistics"):
|
with TestRun.step("Check if cache's statistics match cores' statistics"):
|
||||||
cache_stats = cache.get_statistics_flat(stat_filter=stat_filter)
|
cache_stats = get_stats_dict(filter=stat_filter, cache_id=cache.cache_id)
|
||||||
cores_stats = [
|
cores_stats = [
|
||||||
cores[j].get_statistics_flat(stat_filter=stat_filter)
|
get_stats_dict(
|
||||||
for j in range(cores_per_cache)
|
filter=stat_filter, cache_id=cache.cache_id, core_id=cores[j].core_id
|
||||||
|
) for j in range(cores_per_cache)
|
||||||
]
|
]
|
||||||
fail_message = f"In {cache_mode} cache mode "
|
fail_message = f"In {cache_mode} cache mode "
|
||||||
stats_compare(cache_stats, cores_stats, cores_per_cache, fail_message)
|
stats_compare(cache_stats, cores_stats, cores_per_cache, fail_message)
|
||||||
@ -156,20 +159,20 @@ def fio_prepare():
|
|||||||
|
|
||||||
|
|
||||||
def stats_compare(cache_stats, cores_stats, cores_per_cache, fail_message):
|
def stats_compare(cache_stats, cores_stats, cores_per_cache, fail_message):
|
||||||
for cache_stat_name in cache_stats.keys():
|
for stat_name in cache_stats.keys():
|
||||||
if cache_stat_name.lower() != "free":
|
if stat_name.startswith("Free ") or stat_name.endswith("[%]"):
|
||||||
core_stat_name = cache_stat_name.replace("(s)", "")
|
continue
|
||||||
core_stat_sum = 0
|
core_stat_sum = 0
|
||||||
try:
|
try:
|
||||||
cache_stats[cache_stat_name] = cache_stats[cache_stat_name].value
|
cache_stats[stat_name] = get_stat_value(cache_stats, stat_name)
|
||||||
for j in range(cores_per_cache):
|
|
||||||
cores_stats[j][core_stat_name] = cores_stats[j][core_stat_name].value
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
for j in range(cores_per_cache):
|
for j in range(cores_per_cache):
|
||||||
core_stat_sum += cores_stats[j][core_stat_name]
|
cores_stats[j][stat_name] = get_stat_value(cores_stats[j], stat_name)
|
||||||
if core_stat_sum != cache_stats[cache_stat_name]:
|
except AttributeError:
|
||||||
TestRun.LOGGER.error(fail_message + (
|
pass
|
||||||
f"sum of core's '{core_stat_name}' values is "
|
for j in range(cores_per_cache):
|
||||||
f"{core_stat_sum}, should equal cache value: "
|
core_stat_sum += cores_stats[j][stat_name]
|
||||||
f"{cache_stats[cache_stat_name]}\n"))
|
if core_stat_sum != cache_stats[stat_name]:
|
||||||
|
TestRun.LOGGER.error(fail_message + (
|
||||||
|
f"sum of cores' '{stat_name}' values is "
|
||||||
|
f"{core_stat_sum}, should equal cache value: "
|
||||||
|
f"{cache_stats[stat_name]}\n"))
|
||||||
|
Loading…
Reference in New Issue
Block a user