pyocf: settle cache before testing occupancy
The next commit will move occupancy accounting to backfill which makes testing statistics value even more time dependent. Settling cache before cache.get_stats() prevents this error-inducing race conditions Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
parent
96e527049a
commit
7f55116b5e
@ -1,10 +1,11 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies
|
||||
# Copyright(c) 2024-2025 Huawei Technologies
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import logging
|
||||
import time
|
||||
from math import ceil, isclose
|
||||
from ctypes import c_int
|
||||
|
||||
@ -45,6 +46,8 @@ def test_eviction_two_cores(pyocf_ctx, mode: CacheMode, cls: CacheLineSize):
|
||||
send_io(vol1, test_data)
|
||||
send_io(vol2, test_data)
|
||||
|
||||
cache.settle()
|
||||
|
||||
stats1 = core1.get_stats()
|
||||
stats2 = core2.get_stats()
|
||||
# IO to the second core should evict all the data from the first core
|
||||
@ -285,6 +288,7 @@ def test_eviction_freelist(pyocf_ctx, cls: CacheLineSize, cache_mode: CacheMode,
|
||||
for j in range(cache_lines_written):
|
||||
addr = (cache_lines_written * i + j) * data.size
|
||||
send_io(vol, data, addr, ioclass, io_dir)
|
||||
cache.settle()
|
||||
assert (
|
||||
get_ioclass_occupancy(cache, ioclass) == expected_occpancy_4k
|
||||
), f"Doesn't match for ioclass {ioclass}"
|
||||
@ -298,6 +302,9 @@ def test_eviction_freelist(pyocf_ctx, cls: CacheLineSize, cache_mode: CacheMode,
|
||||
addr += data.size
|
||||
send_io(vol, data, addr, high_prio_ioclass, io_dir)
|
||||
|
||||
cache.settle()
|
||||
time.sleep(1)
|
||||
|
||||
assert cache.get_stats()["usage"]["occupancy"]["value"] == cache_size_4k
|
||||
|
||||
for ioclass in low_prio_ioclasses:
|
||||
|
@ -1,6 +1,6 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies
|
||||
# Copyright(c) 2024-2025 Huawei Technologies
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
@ -212,7 +212,9 @@ def test_stop(pyocf_ctx, mode: CacheMode, cls: CacheLineSize, with_flush: bool):
|
||||
|
||||
cls_no = 10
|
||||
|
||||
run_io_and_cache_data_if_possible(front_vol, mode, cls, cls_no)
|
||||
run_io_and_cache_data_if_possible(cache, front_vol, mode, cls, cls_no)
|
||||
|
||||
cache.settle()
|
||||
|
||||
stats = cache.get_stats()
|
||||
assert int(stats["conf"]["dirty"]) == (
|
||||
@ -494,7 +496,7 @@ def test_start_stop_noqueue(pyocf_ctx):
|
||||
assert not c.results["error"], "Failed to stop cache: {}".format(c.results["error"])
|
||||
|
||||
|
||||
def run_io_and_cache_data_if_possible(vol, mode, cls, cls_no):
|
||||
def run_io_and_cache_data_if_possible(cache, vol, mode, cls, cls_no):
|
||||
queue = vol.parent.get_default_queue()
|
||||
|
||||
test_data = Data(cls_no * cls)
|
||||
@ -508,6 +510,8 @@ def run_io_and_cache_data_if_possible(vol, mode, cls, cls_no):
|
||||
logger.info("[STAGE] Write to exported object")
|
||||
io_to_core(vol, queue, test_data, 0)
|
||||
|
||||
cache.settle()
|
||||
|
||||
stats = vol.parent.cache.get_stats()
|
||||
assert stats["usage"]["occupancy"]["value"] == (
|
||||
(cls_no * cls / CacheLineSize.LINE_4KiB) if mode != CacheMode.PT else 0
|
||||
|
Loading…
Reference in New Issue
Block a user