Skip to content

Commit 6cf9dc9

Browse files
committed
Test modifications
Signed-off-by: Daniel Madej <daniel.madej@huawei.com>
1 parent e5b5523 commit 6cf9dc9

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

test/functional/tests/cache_ops/test_cleaning_policy_operation.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ def set_cleaning_policy_params(cache, cleaning_policy):
209209
alru_params.staleness_time = Time(seconds=2)
210210
alru_params.flush_max_buffers = 100
211211
alru_params.activity_threshold = Time(milliseconds=1000)
212+
alru_params.dirty_ratio_threshold = 66
213+
alru_params.dirty_ratio_inertia = Size(66, Unit.MebiByte)
212214
cache.set_params_alru(alru_params)
213215
current_alru_params = cache.get_flush_parameters_alru()
214216
if current_alru_params != alru_params:
@@ -233,6 +235,16 @@ def set_cleaning_policy_params(cache, cleaning_policy):
233235
f"Activity threshold is {current_alru_params.activity_threshold}, "
234236
f"should be {alru_params.activity_threshold}\n"
235237
)
238+
if current_alru_params.dirty_ratio_threshold != alru_params.dirty_ratio_threshold:
239+
failed_params += (
240+
f"Dirty ratio trigger threshold is {current_alru_params.dirty_ratio_threshold}, "
241+
f"should be {alru_params.dirty_ratio_threshold}\n"
242+
)
243+
if current_alru_params.dirty_ratio_inertia != alru_params.dirty_ratio_inertia:
244+
failed_params += (
245+
f"Dirty ratio trigger inertia is {current_alru_params.dirty_ratio_inertia}, "
246+
f"should be {alru_params.dirty_ratio_inertia}\n"
247+
)
236248
TestRun.LOGGER.error(f"ALRU parameters did not switch properly:\n{failed_params}")
237249

238250

test/functional/tests/cli/test_set_get_params.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def new_seq_cutoff_parameters_random_values():
243243

244244
def new_cleaning_parameters_random_values(cleaning_policy):
245245
if cleaning_policy == CleaningPolicy.alru:
246-
alru_params_range = FlushParametersAlru().alru_params_range()
246+
alru_params_range = FlushParametersAlru.alru_params_range()
247247
wake_up_time_random_value = Time(
248248
seconds=random.randint(*alru_params_range.wake_up_time)
249249
)
@@ -256,11 +256,21 @@ def new_cleaning_parameters_random_values(cleaning_policy):
256256
activity_threshold_random_value = Time(
257257
milliseconds=random.randint(*alru_params_range.activity_threshold)
258258
)
259+
dirty_ratio_threshold_random_value = random.randint(
260+
*alru_params_range.dirty_ratio_threshold
261+
)
262+
dirty_ratio_inertia_random_value = Size(random.randint(
263+
*alru_params_range.dirty_ratio_inertia),
264+
Unit.MebiByte,
265+
)
259266
cleaning_params = FlushParametersAlru()
260267
cleaning_params.wake_up_time = wake_up_time_random_value
261268
cleaning_params.staleness_time = staleness_time_random_value
262269
cleaning_params.flush_max_buffers = flush_max_buffers_random_value
263270
cleaning_params.activity_threshold = activity_threshold_random_value
271+
cleaning_params.dirty_ratio_threshold = dirty_ratio_threshold_random_value
272+
cleaning_params.dirty_ratio_inertia = dirty_ratio_inertia_random_value
273+
264274

265275
if cleaning_policy == CleaningPolicy.acp:
266276
acp_params_range = FlushParametersAcp().acp_params_range()

test/functional/tests/initialize/test_initialize_load.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
22
# Copyright(c) 2019-2022 Intel Corporation
3-
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
3+
# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd.
44
# SPDX-License-Identifier: BSD-3-Clause
55
#
66

@@ -67,6 +67,8 @@ def test_load_x_cores_to_one_cache(cache_mode, cleaning_policy, cache_line_size,
6767
alru.flush_max_buffers = 10
6868
alru.staleness_time = Time(seconds=60)
6969
alru.wake_up_time = Time(seconds=5)
70+
alru.dirty_ratio_threshold = 75
71+
alru.dirty_ratio_inertia = Size(15, Unit.MebiByte)
7072
cache.set_params_alru(alru)
7173
if cleaning_policy == CleaningPolicy.acp:
7274
acp = FlushParametersAcp()

test/functional/tests/misc/test_random_cache_ops.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ def set_param(
330330
f"Changed seq-cutoff params on cache {cache_to_set_param.cache_id} to:\n"
331331
f"Threshold: {str(random_threshold)}\n"
332332
f"Policy: {str(random_policy)}\n"
333-
f"Threshold: {str(random_threshold)}\n"
334333
)
335334
else:
336335
core_list = cache_to_set_param.get_cores()
@@ -385,15 +384,20 @@ def set_param(
385384
)
386385

387386
case cache_to_set_param.set_params_alru:
388-
random_wake_up_time = Time(seconds=random.randint(0, 3600))
389-
random_staleness_time = Time(seconds=random.randint(1, 3600))
390-
random_flush_max_buffers = random.randint(1, 10000)
391-
random_activity_threshold = Time(milliseconds=random.randint(0, 1000000))
387+
ranges = FlushParametersAlru.alru_params_range()
388+
random_wake_up_time = Time(seconds=random.randint(*ranges.wake_up_time))
389+
random_staleness_time = Time(seconds=random.randint(*ranges.staleness_time))
390+
random_flush_max_buffers = random.randint(*ranges.flush_max_buffers)
391+
random_activity_threshold = Time(milliseconds=random.randint(*ranges.activity_threshold))
392+
random_dirty_ratio_threshold = random.randint(*ranges.dirty_ratio_threshold)
393+
random_dirty_ratio_inertia = Size(random.randint(*ranges.dirty_ratio_inertia), Unit.MebiByte)
392394
random_flush_parameters_alru = FlushParametersAlru(
393395
wake_up_time=random_wake_up_time,
394396
staleness_time=random_staleness_time,
395397
flush_max_buffers=random_flush_max_buffers,
396398
activity_threshold=random_activity_threshold,
399+
dirty_ratio_threshold=random_dirty_ratio_threshold,
400+
dirty_ratio_inertia=random_dirty_ratio_inertia,
397401
)
398402
cache_to_set_param.set_params_alru(random_flush_parameters_alru)
399403
return (
@@ -402,6 +406,8 @@ def set_param(
402406
f"Staleness time: {str(random_staleness_time)}\n"
403407
f"Flush max buffers: {str(random_flush_max_buffers)}\n"
404408
f"Activity threshold time: {str(random_activity_threshold)}\n"
409+
f"Dirty ratio trigger threshold: {str(random_dirty_ratio_threshold)}%\n"
410+
f"Dirty ratio trigger inertia: {str(random_dirty_ratio_inertia)}%\n"
405411
)
406412

407413
case cache_to_set_param.set_params_acp:

0 commit comments

Comments
 (0)