Test API: Statistics refactor
Keep all statistics names in one place Differentiate Core/Cache IO class stats Signed-off-by: Daniel Madej <daniel.madej@intel.com>
This commit is contained in:
parent
d6cd388d3e
commit
25b0f0dc55
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
from api.cas.casadm_parser import *
|
from api.cas.casadm_parser import *
|
||||||
from api.cas.cli import *
|
from api.cas.cli import *
|
||||||
from api.cas.statistics import CacheStats, IoClassStats
|
from api.cas.statistics import CacheStats, CacheIoClassStats
|
||||||
from storage_devices.device import Device
|
from storage_devices.device import Device
|
||||||
from test_utils.os_utils import *
|
from test_utils.os_utils import *
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ class Cache:
|
|||||||
percentage_val: bool = False):
|
percentage_val: bool = False):
|
||||||
stats = get_statistics(self.cache_id, None, io_class_id,
|
stats = get_statistics(self.cache_id, None, io_class_id,
|
||||||
stat_filter, percentage_val)
|
stat_filter, percentage_val)
|
||||||
return IoClassStats(stats, for_cache=True)
|
return CacheIoClassStats(stats)
|
||||||
|
|
||||||
def get_statistics(self,
|
def get_statistics(self,
|
||||||
stat_filter: List[StatsFilter] = None,
|
stat_filter: List[StatsFilter] = None,
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
from api.cas.casadm_parser import *
|
from api.cas.casadm_parser import *
|
||||||
from api.cas.cli import *
|
from api.cas.cli import *
|
||||||
from api.cas.statistics import CoreStats, IoClassStats
|
from api.cas.statistics import CoreStats, CoreIoClassStats
|
||||||
from test_tools import fs_utils
|
from test_tools import fs_utils
|
||||||
from test_utils.os_utils import *
|
from test_utils.os_utils import *
|
||||||
from test_utils.os_utils import wait
|
from test_utils.os_utils import wait
|
||||||
@ -55,7 +55,7 @@ class Core(Device):
|
|||||||
percentage_val: bool = False):
|
percentage_val: bool = False):
|
||||||
stats = get_statistics(self.cache_id, self.core_id, io_class_id,
|
stats = get_statistics(self.cache_id, self.core_id, io_class_id,
|
||||||
stat_filter, percentage_val)
|
stat_filter, percentage_val)
|
||||||
return IoClassStats(stats, for_cache=False)
|
return CoreIoClassStats(stats)
|
||||||
|
|
||||||
def get_statistics(self,
|
def get_statistics(self,
|
||||||
stat_filter: List[StatsFilter] = None,
|
stat_filter: List[StatsFilter] = None,
|
||||||
|
@ -1,3 +1,41 @@
|
|||||||
|
#
|
||||||
|
# Copyright(c) 2019-2020 Intel Corporation
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
||||||
|
#
|
||||||
|
|
||||||
|
# Order in arrays is important!
|
||||||
|
config_stats_cache = [
|
||||||
|
"cache id", "cache size", "cache device", "core devices", "inactive core devices",
|
||||||
|
"write policy", "eviction policy", "cleaning policy", "promotion policy", "cache line size",
|
||||||
|
"metadata memory footprint", "dirty for", "metadata mode", "status"
|
||||||
|
]
|
||||||
|
config_stats_core = [
|
||||||
|
"core id", "core device", "exported object", "core size", "dirty for", "status",
|
||||||
|
"seq cutoff threshold", "seq cutoff policy"
|
||||||
|
]
|
||||||
|
config_stats_ioclass = ["io class id", "io class name", "eviction priority", "selective allocation"]
|
||||||
|
usage_stats = ["occupancy", "free", "clean", "dirty"]
|
||||||
|
inactive_usage_stats = ["inactive occupancy", "inactive clean", "inactive dirty"]
|
||||||
|
request_stats = [
|
||||||
|
"read hits", "read partial misses", "read full misses", "read total",
|
||||||
|
"write hits", "write partial misses", "write full misses", "write total",
|
||||||
|
"pass-through reads", "pass-through writes",
|
||||||
|
"serviced requests", "total requests"
|
||||||
|
]
|
||||||
|
block_stats_cache = [
|
||||||
|
"reads from core(s)", "writes to core(s)", "total to/from core(s)",
|
||||||
|
"reads from cache", "writes to cache", "total to/from cache",
|
||||||
|
"reads from exported object(s)", "writes to exported object(s)",
|
||||||
|
"total to/from exported object(s)"
|
||||||
|
]
|
||||||
|
block_stats_core = [stat.replace("(s)", "") for stat in block_stats_cache]
|
||||||
|
error_stats = [
|
||||||
|
"cache read errors", "cache write errors", "cache total errors",
|
||||||
|
"core read errors", "core write errors", "core total errors",
|
||||||
|
"total errors"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class CacheStats:
|
class CacheStats:
|
||||||
stats_list = [
|
stats_list = [
|
||||||
"config_stats",
|
"config_stats",
|
||||||
@ -11,77 +49,37 @@ class CacheStats:
|
|||||||
def __init__(self, stats):
|
def __init__(self, stats):
|
||||||
try:
|
try:
|
||||||
self.config_stats = CacheConfigStats(
|
self.config_stats = CacheConfigStats(
|
||||||
stats["cache id"],
|
*[stats[stat] for stat in config_stats_cache]
|
||||||
stats["cache size"],
|
|
||||||
stats["cache device"],
|
|
||||||
stats["core devices"],
|
|
||||||
stats["inactive core devices"],
|
|
||||||
stats["write policy"],
|
|
||||||
stats["eviction policy"],
|
|
||||||
stats["cleaning policy"],
|
|
||||||
stats["promotion policy"],
|
|
||||||
stats["cache line size"],
|
|
||||||
stats["metadata memory footprint"],
|
|
||||||
stats["dirty for"],
|
|
||||||
stats["metadata mode"],
|
|
||||||
stats["status"],
|
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.usage_stats = UsageStats(
|
self.usage_stats = UsageStats(
|
||||||
stats["occupancy"], stats["free"], stats["clean"], stats["dirty"]
|
*[stats[stat] for stat in usage_stats]
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.inactive_usage_stats = InactiveUsageStats(
|
self.inactive_usage_stats = InactiveUsageStats(
|
||||||
stats["inactive occupancy"],
|
*[stats[stat] for stat in inactive_usage_stats]
|
||||||
stats["inactive clean"],
|
|
||||||
stats["inactive dirty"],
|
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.request_stats = RequestStats(
|
self.request_stats = RequestStats(
|
||||||
stats["read hits"],
|
*[stats[stat] for stat in request_stats]
|
||||||
stats["read partial misses"],
|
|
||||||
stats["read full misses"],
|
|
||||||
stats["read total"],
|
|
||||||
stats["write hits"],
|
|
||||||
stats["write partial misses"],
|
|
||||||
stats["write full misses"],
|
|
||||||
stats["write total"],
|
|
||||||
stats["pass-through reads"],
|
|
||||||
stats["pass-through writes"],
|
|
||||||
stats["serviced requests"],
|
|
||||||
stats["total requests"],
|
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.block_stats = BlockStats(
|
self.block_stats = BlockStats(
|
||||||
stats["reads from core(s)"],
|
*[stats[stat] for stat in block_stats_cache]
|
||||||
stats["writes to core(s)"],
|
|
||||||
stats["total to/from core(s)"],
|
|
||||||
stats["reads from cache"],
|
|
||||||
stats["writes to cache"],
|
|
||||||
stats["total to/from cache"],
|
|
||||||
stats["reads from exported object(s)"],
|
|
||||||
stats["writes to exported object(s)"],
|
|
||||||
stats["total to/from exported object(s)"],
|
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.error_stats = ErrorStats(
|
self.error_stats = ErrorStats(
|
||||||
stats["cache read errors"],
|
*[stats[stat] for stat in error_stats]
|
||||||
stats["cache write errors"],
|
|
||||||
stats["cache total errors"],
|
|
||||||
stats["core read errors"],
|
|
||||||
stats["core write errors"],
|
|
||||||
stats["core total errors"],
|
|
||||||
stats["total errors"],
|
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
@ -115,63 +113,31 @@ class CoreStats:
|
|||||||
def __init__(self, stats):
|
def __init__(self, stats):
|
||||||
try:
|
try:
|
||||||
self.config_stats = CoreConfigStats(
|
self.config_stats = CoreConfigStats(
|
||||||
stats["core id"],
|
*[stats[stat] for stat in config_stats_core]
|
||||||
stats["core device"],
|
|
||||||
stats["exported object"],
|
|
||||||
stats["core size"],
|
|
||||||
stats["dirty for"],
|
|
||||||
stats["status"],
|
|
||||||
stats["seq cutoff threshold"],
|
|
||||||
stats["seq cutoff policy"],
|
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.usage_stats = UsageStats(
|
self.usage_stats = UsageStats(
|
||||||
stats["occupancy"], stats["free"], stats["clean"], stats["dirty"]
|
*[stats[stat] for stat in usage_stats]
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.request_stats = RequestStats(
|
self.request_stats = RequestStats(
|
||||||
stats["read hits"],
|
*[stats[stat] for stat in request_stats]
|
||||||
stats["read partial misses"],
|
|
||||||
stats["read full misses"],
|
|
||||||
stats["read total"],
|
|
||||||
stats["write hits"],
|
|
||||||
stats["write partial misses"],
|
|
||||||
stats["write full misses"],
|
|
||||||
stats["write total"],
|
|
||||||
stats["pass-through reads"],
|
|
||||||
stats["pass-through writes"],
|
|
||||||
stats["serviced requests"],
|
|
||||||
stats["total requests"],
|
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.block_stats = BlockStats(
|
self.block_stats = BlockStats(
|
||||||
stats["reads from core"],
|
*[stats[stat] for stat in block_stats_core]
|
||||||
stats["writes to core"],
|
|
||||||
stats["total to/from core"],
|
|
||||||
stats["reads from cache"],
|
|
||||||
stats["writes to cache"],
|
|
||||||
stats["total to/from cache"],
|
|
||||||
stats["reads from exported object"],
|
|
||||||
stats["writes to exported object"],
|
|
||||||
stats["total to/from exported object"],
|
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.error_stats = ErrorStats(
|
self.error_stats = ErrorStats(
|
||||||
stats["cache read errors"],
|
*[stats[stat] for stat in error_stats]
|
||||||
stats["cache write errors"],
|
|
||||||
stats["cache total errors"],
|
|
||||||
stats["core read errors"],
|
|
||||||
stats["core write errors"],
|
|
||||||
stats["core total errors"],
|
|
||||||
stats["total errors"],
|
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
@ -194,53 +160,35 @@ class CoreStats:
|
|||||||
|
|
||||||
|
|
||||||
class IoClassStats:
|
class IoClassStats:
|
||||||
stats_list = ["config_stats", "usage_stats", "request_stats", "block_stats"]
|
stats_list = [
|
||||||
|
"config_stats",
|
||||||
|
"usage_stats",
|
||||||
|
"request_stats",
|
||||||
|
"block_stats",
|
||||||
|
]
|
||||||
|
|
||||||
def __init__(self, stats, for_cache: bool):
|
def __init__(self, stats, block_stats_list):
|
||||||
try:
|
try:
|
||||||
self.config_stats = IoClassConfigStats(
|
self.config_stats = IoClassConfigStats(
|
||||||
stats["io class id"],
|
*[stats[stat] for stat in config_stats_ioclass]
|
||||||
stats["io class name"],
|
|
||||||
stats["eviction priority"],
|
|
||||||
stats["selective allocation"],
|
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.usage_stats = UsageStats(
|
self.usage_stats = UsageStats(
|
||||||
stats["occupancy"], stats["free"], stats["clean"], stats["dirty"]
|
*[stats[stat] for stat in usage_stats]
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.request_stats = RequestStats(
|
self.request_stats = RequestStats(
|
||||||
stats["read hits"],
|
*[stats[stat] for stat in request_stats]
|
||||||
stats["read partial misses"],
|
|
||||||
stats["read full misses"],
|
|
||||||
stats["read total"],
|
|
||||||
stats["write hits"],
|
|
||||||
stats["write partial misses"],
|
|
||||||
stats["write full misses"],
|
|
||||||
stats["write total"],
|
|
||||||
stats["pass-through reads"],
|
|
||||||
stats["pass-through writes"],
|
|
||||||
stats["serviced requests"],
|
|
||||||
stats["total requests"],
|
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
plural = "(s)" if for_cache else ""
|
|
||||||
self.block_stats = BlockStats(
|
self.block_stats = BlockStats(
|
||||||
stats["reads from core" + plural],
|
*[stats[stat] for stat in block_stats_list]
|
||||||
stats["writes to core" + plural],
|
|
||||||
stats["total to/from core" + plural],
|
|
||||||
stats["reads from cache"],
|
|
||||||
stats["writes to cache"],
|
|
||||||
stats["total to/from cache"],
|
|
||||||
stats["reads from exported object" + plural],
|
|
||||||
stats["writes to exported object" + plural],
|
|
||||||
stats["total to/from exported object" + plural],
|
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
@ -262,6 +210,16 @@ class IoClassStats:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class CacheIoClassStats(IoClassStats):
|
||||||
|
def __init__(self, stats):
|
||||||
|
super().__init__(stats, block_stats_cache)
|
||||||
|
|
||||||
|
|
||||||
|
class CoreIoClassStats(IoClassStats):
|
||||||
|
def __init__(self, stats):
|
||||||
|
super().__init__(stats, block_stats_core)
|
||||||
|
|
||||||
|
|
||||||
class CacheConfigStats:
|
class CacheConfigStats:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
Loading…
Reference in New Issue
Block a user