Skip to content

Commit

Permalink
Merge pull request #1523 from katlapinka/kasiat/promotion-api
Browse files Browse the repository at this point in the history
Add API for setting promotion policy params
  • Loading branch information
robertbaldyga authored Oct 2, 2024
2 parents 67d9379 + 8c0f4f5 commit d692204
Show file tree
Hide file tree
Showing 3 changed files with 71 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 @@ -188,6 +188,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
60 changes: 60 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,37 @@ 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
) -> Output:
_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 +266,34 @@ def get_param_cleaning_acp(
return output


def get_param_promotion(
cache_id: int, output_format: OutputFormat = None, shortcut: bool = False
) -> Output:
_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:
_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: bool = None, shortcut: bool = False
) -> Output:
Expand Down

0 comments on commit d692204

Please sign in to comment.