Add sequential cutoff promotion count to test API

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2021-03-22 18:03:08 +01:00
parent 94dc9048c7
commit ff4dca4622
7 changed files with 38 additions and 22 deletions

View File

@ -144,7 +144,8 @@ class Cache:
def set_seq_cutoff_parameters(self, seq_cutoff_param: SeqCutOffParameters): def set_seq_cutoff_parameters(self, seq_cutoff_param: SeqCutOffParameters):
return casadm.set_param_cutoff(self.cache_id, return casadm.set_param_cutoff(self.cache_id,
threshold=seq_cutoff_param.threshold, threshold=seq_cutoff_param.threshold,
policy=seq_cutoff_param.policy) policy=seq_cutoff_param.policy,
promotion_count=seq_cutoff_param.promotion_count)
def set_seq_cutoff_threshold(self, threshold: Size): def set_seq_cutoff_threshold(self, threshold: Size):
return casadm.set_param_cutoff(self.cache_id, return casadm.set_param_cutoff(self.cache_id,

View File

@ -215,22 +215,25 @@ class FlushParametersAcp:
class SeqCutOffParameters: class SeqCutOffParameters:
def __init__(self, policy=None, threshold=None): def __init__(self, policy=None, threshold=None, promotion_count=None):
self.policy = policy self.policy = policy
self.threshold = threshold self.threshold = threshold
self.promotion_count = promotion_count
def __eq__(self, other): def __eq__(self, other):
return ( return (
self.policy == other.policy self.policy == other.policy
and self.threshold == other.threshold and self.threshold == other.threshold
and self.promotion_count == other.promotion_count
) )
@staticmethod @staticmethod
def default_seq_cut_off_params(): def default_seq_cut_off_params():
seq_cut_off_params = SeqCutOffParameters() return SeqCutOffParameters(
seq_cut_off_params.policy = SeqCutOffPolicy.full threshold=Size(1024, Unit.KibiByte),
seq_cut_off_params.threshold = Size(1024, Unit.KibiByte) policy=SeqCutOffPolicy.full,
return seq_cut_off_params promotion_count=8
)
class PromotionParametersNhit: class PromotionParametersNhit:

View File

@ -286,12 +286,18 @@ def get_param_cleaning_acp(cache_id: int, output_format: OutputFormat = None,
def set_param_cutoff(cache_id: int, core_id: int = None, threshold: Size = None, def set_param_cutoff(cache_id: int, core_id: int = None, threshold: Size = None,
policy: SeqCutOffPolicy = None): policy: SeqCutOffPolicy = None, promotion_count: int = None):
_core_id = None if core_id is None else str(core_id) _core_id = None if core_id is None else str(core_id)
_threshold = None if threshold is None else str(int(threshold.get_value(Unit.KibiByte))) _threshold = None if threshold is None else str(int(threshold.get_value(Unit.KibiByte)))
_policy = None if policy is None else policy.name _policy = None if policy is None else policy.name
_promotion_count = None if promotion_count is None else str(promotion_count)
command = set_param_cutoff_cmd( command = set_param_cutoff_cmd(
cache_id=str(cache_id), core_id=_core_id, threshold=_threshold, policy=_policy) cache_id=str(cache_id),
core_id=_core_id,
threshold=_threshold,
policy=_policy,
promotion_count=_promotion_count
)
output = TestRun.executor.run(command) output = TestRun.executor.run(command)
if output.exit_code != 0: if output.exit_code != 0:
raise CmdException("Error while setting sequential cut-off params.", output) raise CmdException("Error while setting sequential cut-off params.", output)

View File

@ -260,10 +260,12 @@ def get_seq_cut_off_parameters(cache_id: int, core_id: int):
cache_id, core_id, casadm.OutputFormat.csv).stdout.splitlines() cache_id, core_id, casadm.OutputFormat.csv).stdout.splitlines()
seq_cut_off_params = SeqCutOffParameters() seq_cut_off_params = SeqCutOffParameters()
for line in casadm_output: for line in casadm_output:
if 'threshold' in line: if 'Sequential cutoff threshold' in line:
seq_cut_off_params.threshold = Size(int(line.split(',')[1]), Unit.KibiByte) seq_cut_off_params.threshold = Size(int(line.split(',')[1]), Unit.KibiByte)
if 'policy' in line: if 'Sequential cutoff policy' in line:
seq_cut_off_params.policy = SeqCutOffPolicy.from_name(line.split(',')[1]) seq_cut_off_params.policy = SeqCutOffPolicy.from_name(line.split(',')[1])
if 'Sequential cutoff promotion request count threshold' in line:
seq_cut_off_params.promotion_count = int(line.split(',')[1])
return seq_cut_off_params return seq_cut_off_params

View File

@ -221,7 +221,7 @@ def _set_param_cmd(namespace: str, cache_id: str, additional_params: str = None,
def set_param_cutoff_cmd(cache_id: str, core_id: str = None, threshold: str = None, def set_param_cutoff_cmd(cache_id: str, core_id: str = None, threshold: str = None,
policy: str = None, shortcut: bool = False): policy: str = None, promotion_count: str = None, shortcut: bool = False):
add_params = "" add_params = ""
if core_id is not None: if core_id is not None:
add_params += (" -j " if shortcut else " --core-id ") + str(core_id) add_params += (" -j " if shortcut else " --core-id ") + str(core_id)
@ -229,6 +229,8 @@ def set_param_cutoff_cmd(cache_id: str, core_id: str = None, threshold: str = No
add_params += (" -t " if shortcut else " --threshold ") + str(threshold) add_params += (" -t " if shortcut else " --threshold ") + str(threshold)
if policy is not None: if policy is not None:
add_params += (" -p " if shortcut else " --policy ") + policy add_params += (" -p " if shortcut else " --policy ") + policy
if promotion_count is not None:
add_params += " --promotion-count " + str(promotion_count)
return _set_param_cmd(namespace="seq-cutoff", cache_id=cache_id, return _set_param_cmd(namespace="seq-cutoff", cache_id=cache_id,
additional_params=add_params, shortcut=shortcut) additional_params=add_params, shortcut=shortcut)

View File

@ -118,18 +118,22 @@ class Core(Device):
def set_seq_cutoff_parameters(self, seq_cutoff_param: SeqCutOffParameters): def set_seq_cutoff_parameters(self, seq_cutoff_param: SeqCutOffParameters):
return casadm.set_param_cutoff(self.cache_id, self.core_id, return casadm.set_param_cutoff(self.cache_id, self.core_id,
seq_cutoff_param.threshold, seq_cutoff_param.policy) seq_cutoff_param.threshold,
seq_cutoff_param.policy,
seq_cutoff_param.promotion_count)
def set_seq_cutoff_threshold(self, threshold: Size): def set_seq_cutoff_threshold(self, threshold: Size):
return casadm.set_param_cutoff(self.cache_id, self.core_id, return casadm.set_param_cutoff(self.cache_id, self.core_id,
threshold=threshold, threshold=threshold)
policy=None)
def set_seq_cutoff_policy(self, policy: SeqCutOffPolicy): def set_seq_cutoff_policy(self, policy: SeqCutOffPolicy):
return casadm.set_param_cutoff(self.cache_id, self.core_id, return casadm.set_param_cutoff(self.cache_id, self.core_id,
threshold=None,
policy=policy) policy=policy)
def set_seq_cutoff_promotion_count(self, promotion_count: int):
return casadm.set_param_cutoff(self.cache_id, self.core_id,
promotion_count=promotion_count)
def check_if_is_present_in_os(self, should_be_visible=True): def check_if_is_present_in_os(self, should_be_visible=True):
device_in_system_message = "CAS device exists in OS." device_in_system_message = "CAS device exists in OS."
device_not_in_system_message = "CAS device does not exist in OS." device_not_in_system_message = "CAS device does not exist in OS."

View File

@ -231,13 +231,11 @@ def cache_prepare(cache_mode, cache_dev, core_dev):
def new_seqcutoff_parameters_random_values(): def new_seqcutoff_parameters_random_values():
threshold_random_value = Size(random.randrange(1, 1000000), Unit.KibiByte) return SeqCutOffParameters(
policy_random_value = random.choice(list(SeqCutOffPolicy)) threshold = Size(random.randrange(1, 1000000), Unit.KibiByte),
seqcutoff_params = SeqCutOffParameters() policy = random.choice(list(SeqCutOffPolicy)),
seqcutoff_params.threshold = threshold_random_value promotion_count = random.randrange(1, 65535)
seqcutoff_params.policy = policy_random_value )
return seqcutoff_params
def new_cleaning_parameters_random_values(cleaning_policy): def new_cleaning_parameters_random_values(cleaning_policy):