tests: sequential cut off related methods fixup
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
This commit is contained in:
parent
db8ff10cd5
commit
56b9ec1794
@ -123,8 +123,18 @@ class Cache:
|
||||
|
||||
def set_seq_cutoff_parameters(self, seq_cutoff_param: SeqCutOffParameters):
|
||||
return casadm.set_param_cutoff(self.cache_id,
|
||||
seq_cutoff_param.threshold,
|
||||
seq_cutoff_param.policy)
|
||||
threshold=seq_cutoff_param.threshold,
|
||||
policy=seq_cutoff_param.policy)
|
||||
|
||||
def set_seq_cutoff_threshold(self, threshold: Size):
|
||||
return casadm.set_param_cutoff(self.cache_id,
|
||||
threshold=threshold,
|
||||
policy=None)
|
||||
|
||||
def set_seq_cutoff_policy(self, policy: SeqCutOffPolicy):
|
||||
return casadm.set_param_cutoff(self.cache_id,
|
||||
threshold=None,
|
||||
policy=policy)
|
||||
|
||||
def set_cleaning_policy(self, cleaning_policy: CleaningPolicy):
|
||||
return casadm.set_param_cleaning(self.cache_id, cleaning_policy)
|
||||
|
@ -32,6 +32,14 @@ class SeqCutOffPolicy(Enum):
|
||||
never = 2
|
||||
DEFAULT = full
|
||||
|
||||
@classmethod
|
||||
def from_name(cls, name):
|
||||
for policy, policy_name in SeqCutOffPolicy.__members__.items():
|
||||
if name == policy:
|
||||
return policy_name
|
||||
|
||||
raise ValueError(f"{name} is not a valid sequential cut off name")
|
||||
|
||||
|
||||
class EvictionPolicy(Enum):
|
||||
lru = 0
|
||||
@ -106,6 +114,7 @@ class SeqCutOffParameters:
|
||||
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
|
||||
|
||||
|
||||
# TODO: Use case for this will be to iterate over configurations (kernel params such as
|
||||
|
@ -254,15 +254,10 @@ 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):
|
||||
_threshold = None if threshold is None else threshold.get_value(Unit.KibiByte)
|
||||
if core_id is None:
|
||||
command = set_param_cutoff_cmd(
|
||||
cache_id=str(cache_id), threshold=_threshold,
|
||||
policy=policy.name)
|
||||
else:
|
||||
command = set_param_cutoff_cmd(
|
||||
cache_id=str(cache_id), core_id=str(core_id),
|
||||
threshold=_threshold, policy=policy.name)
|
||||
_threshold = None if threshold is None else int(threshold.get_value(Unit.KibiByte))
|
||||
command = set_param_cutoff_cmd(
|
||||
cache_id=cache_id, core_id=core_id,
|
||||
threshold=_threshold, policy=policy)
|
||||
output = TestRun.executor.run(command)
|
||||
if output.exit_code != 0:
|
||||
raise Exception(
|
||||
|
@ -198,9 +198,10 @@ def get_seq_cut_off_parameters(cache_id: int, core_id: int):
|
||||
seq_cut_off_params = SeqCutOffParameters()
|
||||
for line in casadm_output:
|
||||
if 'threshold' in line:
|
||||
seq_cut_off_params.threshold = line.split(',')[1]
|
||||
seq_cut_off_params.threshold = Size(int(line.split(',')[1]), Unit.KibiByte)
|
||||
if 'policy' in line:
|
||||
seq_cut_off_params.policy = SeqCutOffPolicy(line.split(',')[1])
|
||||
seq_cut_off_params.policy = SeqCutOffPolicy.from_name(line.split(',')[1])
|
||||
return seq_cut_off_params
|
||||
|
||||
|
||||
def get_casadm_version():
|
||||
|
@ -190,11 +190,11 @@ def set_param_cutoff_cmd(cache_id: str, core_id: str = None, threshold: str = No
|
||||
policy: str = None, shortcut: bool = False):
|
||||
add_params = ""
|
||||
if core_id is not None:
|
||||
add_params += (" -j " if shortcut else " --core-id ") + core_id
|
||||
add_params += (" -j " if shortcut else " --core-id ") + str(core_id)
|
||||
if threshold is not None:
|
||||
add_params += (" -t " if shortcut else " --threshold ") + threshold
|
||||
add_params += (" -t " if shortcut else " --threshold ") + str(threshold)
|
||||
if policy is not None:
|
||||
add_params += (" -p " if shortcut else " --policy ") + policy
|
||||
add_params += (" -p " if shortcut else " --policy ") + policy.name
|
||||
return _set_param_cmd(namespace="seq-cutoff", cache_id=cache_id,
|
||||
additional_params=add_params, shortcut=shortcut)
|
||||
|
||||
|
@ -17,6 +17,9 @@ class CoreStatus(Enum):
|
||||
detached = 3
|
||||
|
||||
|
||||
SEQ_CUTOFF_THRESHOLD_MAX = 4194181
|
||||
|
||||
|
||||
class Core(Device):
|
||||
def __init__(self, core_device: str, cache_id: int):
|
||||
self.core_device = Device(core_device)
|
||||
@ -54,6 +57,12 @@ class Core(Device):
|
||||
def get_seq_cut_off_parameters(self):
|
||||
return get_seq_cut_off_parameters(self.cache_id, self.core_id)
|
||||
|
||||
def get_seq_cut_off_policy(self):
|
||||
return get_seq_cut_off_parameters(self.cache_id, self.core_id).policy
|
||||
|
||||
def get_seq_cut_off_threshold(self):
|
||||
return get_seq_cut_off_parameters(self.cache_id, self.core_id).threshold
|
||||
|
||||
def get_dirty_blocks(self):
|
||||
return self.get_core_statistics()["dirty"]
|
||||
|
||||
@ -77,5 +86,15 @@ class Core(Device):
|
||||
assert self.get_dirty_blocks().get_value(Unit.Blocks4096) == 0
|
||||
|
||||
def set_seq_cutoff_parameters(self, seq_cutoff_param: SeqCutOffParameters):
|
||||
casadm.set_param_cutoff(self.cache_id, self.core_id,
|
||||
seq_cutoff_param.threshold, seq_cutoff_param.policy)
|
||||
return casadm.set_param_cutoff(self.cache_id, self.core_id,
|
||||
seq_cutoff_param.threshold, seq_cutoff_param.policy)
|
||||
|
||||
def set_seq_cutoff_threshold(self, threshold: Size):
|
||||
return casadm.set_param_cutoff(self.cache_id, self.core_id,
|
||||
threshold=threshold,
|
||||
policy=None)
|
||||
|
||||
def set_seq_cutoff_policy(self, policy: SeqCutOffPolicy):
|
||||
return casadm.set_param_cutoff(self.cache_id, self.core_id,
|
||||
threshold=None,
|
||||
policy=policy)
|
||||
|
Loading…
Reference in New Issue
Block a user