Allow whole range of ALRU parameters in test API

Signed-off-by: Jan Musial <jan.musial@intel.com>
This commit is contained in:
Jan Musial 2020-03-10 09:20:57 +01:00
parent 1b0c0f6380
commit 8d86cdfa3b
4 changed files with 27 additions and 25 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2019 Intel Corporation
# Copyright(c) 2019-2020 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
@ -164,15 +164,16 @@ class Cache:
if acp_params.flush_max_buffers else None)
def set_params_alru(self, alru_params: FlushParametersAlru):
return casadm.set_param_cleaning_alru(self.cache_id,
int(alru_params.wake_up_time.total_seconds())
if alru_params.wake_up_time else None,
int(alru_params.staleness_time.total_seconds())
if alru_params.staleness_time else None,
alru_params.flush_max_buffers
if alru_params.flush_max_buffers else None,
alru_params.activity_threshold.total_milliseconds()
if alru_params.activity_threshold else None)
return casadm.set_param_cleaning_alru(
self.cache_id,
int(alru_params.wake_up_time.total_seconds())
if alru_params.wake_up_time is not None else None,
int(alru_params.staleness_time.total_seconds())
if alru_params.staleness_time is not None else None,
alru_params.flush_max_buffers
if alru_params.flush_max_buffers is not None else None,
alru_params.activity_threshold.total_milliseconds()
if alru_params.activity_threshold is not None else None)
def get_cache_config(self):
return CacheConfig(self.get_cache_line_size(),

View File

@ -158,10 +158,10 @@ class FlushParametersAlru:
@staticmethod
def alru_params_range():
alru_params = FlushParametersAlru()
alru_params.activity_threshold = (500, 1000000)
alru_params.activity_threshold = (0, 1000000)
alru_params.flush_max_buffers = (1, 10000)
alru_params.staleness_time = (1, 3600)
alru_params.wake_up_time = (1, 3600)
alru_params.wake_up_time = (0, 3600)
return alru_params
def __eq__(self, other):

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2019 Intel Corporation
# Copyright(c) 2019-2020 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
@ -274,11 +274,11 @@ def set_param_cleaning_alru(cache_id: int, wake_up: int = None, staleness_time:
flush_max_buffers: int = None, activity_threshold: int = None):
output = TestRun.executor.run(
set_param_cleaning_alru_cmd(
cache_id=str(cache_id),
wake_up=str(wake_up) if wake_up else None,
staleness_time=str(staleness_time) if staleness_time else None,
flush_max_buffers=str(flush_max_buffers) if flush_max_buffers else None,
activity_threshold=str(activity_threshold) if activity_threshold else None))
cache_id=cache_id,
wake_up=wake_up,
staleness_time=staleness_time,
flush_max_buffers=flush_max_buffers,
activity_threshold=activity_threshold))
if output.exit_code != 0:
raise CmdException("Error while setting alru cleaning policy parameters.", output)
return output

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2019 Intel Corporation
# Copyright(c) 2019-2020 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
@ -210,18 +210,19 @@ def set_param_cleaning_cmd(cache_id: str, policy: str, shortcut: bool = False):
additional_params=add_params, shortcut=shortcut)
def set_param_cleaning_alru_cmd(cache_id: str, wake_up: str, staleness_time: str,
flush_max_buffers: str, activity_threshold: str,
def set_param_cleaning_alru_cmd(cache_id, wake_up, staleness_time,
flush_max_buffers, activity_threshold,
shortcut: bool = False):
add_param = ""
if wake_up is not None:
add_param += (" -w " if shortcut else " --wake-up ") + wake_up
add_param += (" -w " if shortcut else " --wake-up ") + str(wake_up)
if staleness_time is not None:
add_param += (" -s " if shortcut else " --staleness-time ") + staleness_time
add_param += (" -s " if shortcut else " --staleness-time ") + str(staleness_time)
if flush_max_buffers is not None:
add_param += (" -b " if shortcut else " --flush-max-buffers ") + flush_max_buffers
add_param += (" -b " if shortcut else " --flush-max-buffers ") + str(flush_max_buffers)
if activity_threshold is not None:
add_param += (" -t " if shortcut else " --activity-threshold ") + activity_threshold
add_param += (" -t " if shortcut else " --activity-threshold ") + str(activity_threshold)
return _set_param_cmd(namespace="cleaning-alru", cache_id=cache_id,
additional_params=add_param, shortcut=shortcut)