11#
22# Copyright(c) 2020-2021 Intel Corporation
33# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd.
4+ # Copyright(c) 2026 Unvertical
45# SPDX-License-Identifier: BSD-3-Clause
56#
67
1920)
2021from api .cas .casadm import StatsFilter
2122from api .cas .core import CoreStatus
22- from api .cas .statistics import (
23- usage_stats , request_stats , block_stats_core , block_stats_cache , error_stats
24- )
23+ from api .cas .statistics import get_stats_dict
2524from core .test_run import TestRun
2625from storage_devices .disk import DiskType , DiskTypeSet , DiskTypeLowerThan
2726from test_tools .fio .fio import Fio
3433# Time to wait after fio (in seconds):
3534time_to_wait = 30
3635
36+ usage_stats = [
37+ "Occupancy [4KiB Blocks]" ,
38+ "Occupancy [%]" ,
39+ "Free [4KiB Blocks]" ,
40+ "Free [%]" ,
41+ "Clean [4KiB Blocks]" ,
42+ "Clean [%]" ,
43+ "Dirty [4KiB Blocks]" ,
44+ "Dirty [%]"
45+ ]
46+
47+ request_stats = [
48+ "Read hits [Requests]" ,
49+ "Read hits [%]" ,
50+ "Read partial misses [Requests]" ,
51+ "Read partial misses [%]" ,
52+ "Read full misses [Requests]" ,
53+ "Read full misses [%]" ,
54+ "Read total [Requests]" ,
55+ "Read total [%]" ,
56+ "Write hits [Requests]" ,
57+ "Write hits [%]" ,
58+ "Write partial misses [Requests]" ,
59+ "Write partial misses [%]" ,
60+ "Write full misses [Requests]" ,
61+ "Write full misses [%]" ,
62+ "Write total [Requests]" ,
63+ "Write total [%]" ,
64+ "Pass-Through reads [Requests]" ,
65+ "Pass-Through reads [%]" ,
66+ "Pass-Through writes [Requests]" ,
67+ "Pass-Through writes [%]" ,
68+ "Serviced requests [Requests]" ,
69+ "Serviced requests [%]" ,
70+ "Total requests [Requests]" ,
71+ "Total requests [%]"
72+ ]
73+
74+ block_stats = [
75+ "Reads from core [4KiB Blocks]" ,
76+ "Reads from core [%]" ,
77+ "Writes to core [4KiB Blocks]" ,
78+ "Writes to core [%]" ,
79+ "Total to/from core [4KiB Blocks]" ,
80+ "Total to/from core [%]" ,
81+ "Reads from cache [4KiB Blocks]" ,
82+ "Reads from cache [%]" ,
83+ "Writes to cache [4KiB Blocks]" ,
84+ "Writes to cache [%]" ,
85+ "Total to/from cache [4KiB Blocks]" ,
86+ "Total to/from cache [%]" ,
87+ "Reads from exported object [4KiB Blocks]" ,
88+ "Reads from exported object [%]" ,
89+ "Writes to exported object [4KiB Blocks]" ,
90+ "Writes to exported object [%]" ,
91+ "Total to/from exported object [4KiB Blocks]" ,
92+ "Total to/from exported object [%]"
93+ ]
94+
95+ error_stats = [
96+ "Cache read errors [Requests]" ,
97+ "Cache read errors [%]" ,
98+ "Cache write errors [Requests]" ,
99+ "Cache write errors [%]" ,
100+ "Cache total errors [Requests]" ,
101+ "Cache total errors [%]" ,
102+ "Core read errors [Requests]" ,
103+ "Core read errors [%]" ,
104+ "Core write errors [Requests]" ,
105+ "Core write errors [%]" ,
106+ "Core total errors [Requests]" ,
107+ "Core total errors [%]" ,
108+ "Total errors [Requests]" ,
109+ "Total errors [%]"
110+ ]
111+
37112
38113@pytest .mark .require_disk ("cache" , DiskTypeSet ([DiskType .optane , DiskType .nand ]))
39114@pytest .mark .require_disk ("core" , DiskTypeLowerThan ("cache" ))
@@ -145,7 +220,7 @@ def test_cache_nonconfig_stats(stat_filter):
145220
146221 with TestRun .step (f"Get { stat_filter } statistics for each cache and validate them" ):
147222 caches_stats = [
148- caches [i ].get_statistics_flat ( stat_filter = [ stat_filter ] )
223+ get_stats_dict ([ stat_filter ], caches [i ].cache_id )
149224 for i in range (caches_count )
150225 ]
151226 failed_stats = ""
@@ -189,7 +264,7 @@ def test_core_nonconfig_stats(stat_filter):
189264 failed_stats = ""
190265 for i in range (caches_count ):
191266 cores_stats = [
192- cores [i ][j ].get_statistics_flat ( stat_filter = [ stat_filter ] )
267+ get_stats_dict ([ stat_filter ], cores [i ][j ].cache_id , cores [ i ][ j ]. core_id )
193268 for j in range (cores_per_cache )
194269 ]
195270 for j in range (cores_per_cache ):
@@ -204,7 +279,7 @@ def test_core_nonconfig_stats(stat_filter):
204279
205280def storage_prepare ():
206281 cache_dev = TestRun .disks ["cache" ]
207- cache_parts = [Size (20 , Unit .GibiByte )] * caches_count
282+ cache_parts = [Size (10 , Unit .GibiByte )] * caches_count
208283 cache_dev .create_partitions (cache_parts )
209284 core_dev = TestRun .disks ["core" ]
210285 core_parts = [Size (10 , Unit .GibiByte )] * cores_per_cache * caches_count
@@ -268,7 +343,7 @@ def validate_cache_config_statistics(caches, after_io: bool = False):
268343 f"For cache number { caches [i ].cache_id } number of core devices is "
269344 f"{ caches_stats [i ].config_stats .core_dev } , "
270345 f"should be { cores_per_cache } \n " )
271- if caches_stats [i ].config_stats .inactive_core_dev != 0 :
346+ if caches_stats [i ].config_stats .inactive_core_devices != 0 :
272347 failed_stats += (
273348 f"For cache number { caches [i ].cache_id } number of inactive core devices is "
274349 f"{ caches_stats [i ].config_stats .inactive_core_dev } , should be 0\n " )
@@ -405,7 +480,7 @@ def validate_statistics_flat(device, stats, stat_filter, per_core: bool):
405480 if stat_filter == StatsFilter .usage :
406481 current_stats = usage_stats
407482 if stat_filter == StatsFilter .blk :
408- current_stats = block_stats_core if per_core else block_stats_cache
483+ current_stats = block_stats
409484 if stat_filter == StatsFilter .req :
410485 current_stats = request_stats
411486 if stat_filter == StatsFilter .err :
0 commit comments