Skip to content

Commit

Permalink
Add API for setting promotion policy params
Browse files Browse the repository at this point in the history
Signed-off-by: Katarzyna Treder <katarzyna.treder@h-partners.com>
  • Loading branch information
Katarzyna Treder committed Sep 13, 2024
1 parent 8f5dbc9 commit bf4c4a1
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
10 changes: 10 additions & 0 deletions test/functional/api/cas/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ def set_params_alru(self, alru_params: FlushParametersAlru) -> Output:
),
)

def set_promotion_policy(self, policy: PromotionPolicy) -> Output:
return casadm.set_param_promotion(self.cache_id, policy)

def set_params_nhit(self, promotion_params_nhit: PromotionParametersNhit) -> Output:
return casadm.set_param_promotion_nhit(
self.cache_id,
threshold=promotion_params_nhit.threshold.get_value(),
trigger=promotion_params_nhit.trigger
)

def get_cache_config(self) -> CacheConfig:
return CacheConfig(
self.get_cache_line_size(),
Expand Down
2 changes: 1 addition & 1 deletion test/functional/api/cas/cache_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def default_acp_params():

class SeqCutOffParameters:
def __init__(
self, policy: CleaningPolicy = None, threshold: Size = None, promotion_count: int = None
self, policy: SeqCutOffPolicy = None, threshold: Size = None, promotion_count: int = None
):
self.policy = policy
self.threshold = threshold
Expand Down
56 changes: 56 additions & 0 deletions test/functional/api/cas/casadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
SeqCutOffPolicy,
CleaningPolicy,
KernelParameters,
PromotionPolicy,
)
from api.cas.casadm_params import OutputFormat, StatsFilter
from api.cas.cli import *
Expand Down Expand Up @@ -177,6 +178,35 @@ def set_param_cleaning_acp(
return output


def set_param_promotion(cache_id: int, policy: PromotionPolicy, shortcut: bool = False) -> Output:
output = TestRun.executor.run(
set_param_promotion_cmd(
cache_id=str(cache_id),
policy=policy.name,
shortcut=shortcut,
)
)
if output.exit_code != 0:
raise CmdException("Error while setting promotion policy.", output)
return output


def set_param_promotion_nhit(cache_id: int, threshold: int = None, trigger: int = None, shortcut: bool = False):
_threshold = str(threshold) if threshold is not None else None
_trigger = str(trigger) if trigger is not None else None
output = TestRun.executor.run(
set_param_promotion_nhit_cmd(
cache_id=str(cache_id),
threshold=_threshold,
trigger=_trigger,
shortcut=shortcut,
)
)
if output.exit_code != 0:
raise CmdException("Error while setting promotion policy.", output)
return output


def get_param_cutoff(
cache_id: int, core_id: int, output_format: OutputFormat = None, shortcut: bool = False
) -> Output:
Expand Down Expand Up @@ -234,6 +264,32 @@ def get_param_cleaning_acp(
return output


def get_param_promotion(cache_id: int, output_format: OutputFormat = None, shortcut: bool = False):
_output_format = output_format.name if output_format else None
output = TestRun.executor.run(
get_param_promotion_cmd(
cache_id=str(cache_id), output_format=_output_format, shortcut=shortcut
)
)
if output.exit_code != 0:
raise CmdException("Getting promotion policy failed.", output)
return output


def get_param_promotion_nhit(
cache_id: int, output_format: OutputFormat = None, shortcut: bool = False
):
_output_format = output_format.name if output_format else None
output = TestRun.executor.run(
get_param_promotion_nhit_cmd(
cache_id=str(cache_id), output_format=_output_format, shortcut=shortcut
)
)
if output.exit_code != 0:
raise CmdException("Getting promotion policy nhit params failed.", output)
return output


def set_cache_mode(
cache_mode: CacheMode, cache_id: int, flush=None, shortcut: bool = False
) -> Output:
Expand Down

0 comments on commit bf4c4a1

Please sign in to comment.