-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test_io_class_stats_core_cache #1350
base: master
Are you sure you want to change the base?
Conversation
72221a9
to
c4f3246
Compare
retest this please |
with TestRun.step("Start caches (one for each supported cache mode) and add core devices."): | ||
caches = [casadm.start_cache(dev, cache_mode=cache_mode, force=True) | ||
for dev, cache_mode in zip(cache_devices, CacheMode)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CAS support 5 cache modes: WO, WB, WT, WA and PT. You should assign len(CacheMode)
to number_of_caches
in line 24 instead of assigning the raw number
s = '' if per_core else '(s)' | ||
stats_pt_wa = [f'writes to exported object{s}', f'total to/from exported object{s}', | ||
f'writes to core{s}', f'total to/from core{s}'] | ||
stats_wb = ['occupancy', 'dirty', 'write full misses', 'write total', | ||
f'writes to exported object{s}', f'total to/from exported object{s}', | ||
'writes to cache', 'total to/from cache'] | ||
stats_wt = ['occupancy', 'clean', 'write full misses', 'write total', | ||
f'writes to exported object{s}', f'total to/from exported object{s}', | ||
'writes to cache', 'total to/from cache', | ||
f'writes to core{s}', f'total to/from core{s}'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be defined outside of the loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of associating lists of stats relevant for the particular cache modes you should use trait-relevant stats association. That way the test will become more flexible for any modifications like adding a new cache mode or adding a new statistic.
You can grep older tests in search of CacheModeTrait
to see the usage of trait API.
InsertWrite
means a cache mode inserts data into cache when writing
InsertRead
means a cache mode inserts data into cache when reading
LazyWrites
means a cache mode inserts data into cache when writing but it doesn't flush on core device
if cache_mode == CacheMode.PT or cache_mode == CacheMode.WA: | ||
expected_value = size_in_blocks if name in stats_pt_wa else 0 | ||
check_value(name, value, expected_value) | ||
|
||
elif cache_mode == CacheMode.WB: | ||
expected_value = size_in_blocks if name in stats_wb else 0 | ||
check_value(name, value, expected_value) | ||
|
||
elif cache_mode == CacheMode.WT: | ||
expected_value = size_in_blocks if name in stats_wt else 0 | ||
check_value(name, value, expected_value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing case for WO. If you apply my suggestion with using traits you won't need to add a new extra case
if cache_mode == CacheMode.PT: | ||
expected_value = 0 | ||
epsilon_percentage = 0 | ||
check_perc_value(name, value, expected_value, epsilon_percentage) | ||
|
||
elif cache_mode == CacheMode.WA: | ||
expected_value = 0 | ||
epsilon_percentage = 0.5 if name == 'occupancy' else 0 | ||
check_perc_value(name, value, expected_value, epsilon_percentage) | ||
|
||
elif cache_mode == CacheMode.WB: | ||
occupancy = 100 * size_in_blocks / cache.size.get_value() | ||
expected_value = 100 if name == 'dirty' else \ | ||
occupancy if name == 'occupancy' else 0 | ||
epsilon_percentage = 0.5 if name in ('dirty', 'occupancy') else 0 | ||
check_perc_value(name, value, expected_value, epsilon_percentage) | ||
|
||
elif cache_mode == CacheMode.WT: | ||
occupancy = 100 * size_in_blocks / cache.size.get_value() | ||
expected_value = 100 if name == 'clean' else \ | ||
occupancy if name == 'occupancy' else 0 | ||
epsilon_percentage = 0.5 if name in ('clean', 'occupancy') else 0 | ||
check_perc_value(name, value, expected_value, epsilon_percentage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing case for WO. If you apply my suggestion with using traits you won't need to add a new extra case
test/functional/tests/io_class/test_io_class_stats_core_cache.py
Outdated
Show resolved
Hide resolved
|
||
core.reset_counters() | ||
cache.purge_cache() | ||
drop_caches() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case a cache device has some dirty data purge will trigger flushing which will lead to nonzero values in stats thus suggest resetting stats after purge and drop caches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw instead of resetting stats of each core separately, how about using cache.reset_counters()
? Additionally, I would move it to a separate step with a separate cache-based loop
I would say that testing more than one cache in a single iteration overcomplicates the code whereas the benefits of this approach are negligible. It could be a good idea to simplify it by testing only WT cache mode and leaving only one cache. In that case the most of my comments become irrelevant |
c4f3246
to
79c571f
Compare
Signed-off-by: Adriana Nikelska <adrianax.nikielska@intel.com>
needs modifications: the most important are parametrize by CacheMode and check stats logic |
Signed-off-by: Adriana Nikelska adrianax.nikielska@intel.com