Merge pull request #753 from robertbaldyga/test-seq-cutoff-promo-fix

Add sequential cutoff promotion count to test API
This commit is contained in:
Robert Baldyga 2021-03-23 17:56:10 +01:00 committed by GitHub
commit a5fee7c3eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 43 additions and 22 deletions

View File

@ -144,7 +144,8 @@ class Cache:
def set_seq_cutoff_parameters(self, seq_cutoff_param: SeqCutOffParameters):
return casadm.set_param_cutoff(self.cache_id,
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):
return casadm.set_param_cutoff(self.cache_id,

View File

@ -215,22 +215,25 @@ class FlushParametersAcp:
class SeqCutOffParameters:
def __init__(self, policy=None, threshold=None):
def __init__(self, policy=None, threshold=None, promotion_count=None):
self.policy = policy
self.threshold = threshold
self.promotion_count = promotion_count
def __eq__(self, other):
return (
self.policy == other.policy
and self.threshold == other.threshold
and self.promotion_count == other.promotion_count
)
@staticmethod
def default_seq_cut_off_params():
seq_cut_off_params = SeqCutOffParameters()
seq_cut_off_params.policy = SeqCutOffPolicy.full
seq_cut_off_params.threshold = Size(1024, Unit.KibiByte)
return seq_cut_off_params
return SeqCutOffParameters(
threshold=Size(1024, Unit.KibiByte),
policy=SeqCutOffPolicy.full,
promotion_count=8
)
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,
policy: SeqCutOffPolicy = None):
policy: SeqCutOffPolicy = None, promotion_count: int = None):
_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)))
_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(
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)
if output.exit_code != 0:
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()
seq_cut_off_params = SeqCutOffParameters()
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)
if 'policy' in line:
if 'Sequential cutoff policy' in line:
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

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,
policy: str = None, shortcut: bool = False):
policy: str = None, promotion_count: str = None, shortcut: bool = False):
add_params = ""
if core_id is not None:
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)
if policy is not None:
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,
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):
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):
return casadm.set_param_cutoff(self.cache_id, self.core_id,
threshold=threshold,
policy=None)
threshold=threshold)
def set_seq_cutoff_policy(self, policy: SeqCutOffPolicy):
return casadm.set_param_cutoff(self.cache_id, self.core_id,
threshold=None,
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):
device_in_system_message = "CAS device exists 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():
threshold_random_value = Size(random.randrange(1, 1000000), Unit.KibiByte)
policy_random_value = random.choice(list(SeqCutOffPolicy))
seqcutoff_params = SeqCutOffParameters()
seqcutoff_params.threshold = threshold_random_value
seqcutoff_params.policy = policy_random_value
return seqcutoff_params
return SeqCutOffParameters(
threshold=Size(random.randrange(1, 1000000), Unit.KibiByte),
policy=random.choice(list(SeqCutOffPolicy)),
promotion_count=random.randrange(1, 65535)
)
def new_cleaning_parameters_random_values(cleaning_policy):
@ -289,6 +287,11 @@ def check_seqcutoff_parameters(core, seqcutoff_params):
f"Policy is {current_seqcutoff_params.policy}, "
f"should be {seqcutoff_params.policy}\n"
)
if current_seqcutoff_params.promotion_count != seqcutoff_params.promotion_count:
failed_params += (
f"Promotion count is {current_seqcutoff_params.promotion_count}, "
f"should be {seqcutoff_params.promotion_count}\n"
)
if failed_params:
TestRun.LOGGER.error(
f"Sequential cut-off parameters are not correct "