diff --git a/test/functional/api/cas/cache.py b/test/functional/api/cas/cache.py index 8efd00119..165f1a817 100644 --- a/test/functional/api/cas/cache.py +++ b/test/functional/api/cas/cache.py @@ -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(), diff --git a/test/functional/api/cas/cache_config.py b/test/functional/api/cas/cache_config.py index a7bc21ea2..7bb5d6fd7 100644 --- a/test/functional/api/cas/cache_config.py +++ b/test/functional/api/cas/cache_config.py @@ -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 diff --git a/test/functional/api/cas/casadm.py b/test/functional/api/cas/casadm.py index 6b693a69f..57a7bd301 100644 --- a/test/functional/api/cas/casadm.py +++ b/test/functional/api/cas/casadm.py @@ -13,6 +13,7 @@ SeqCutOffPolicy, CleaningPolicy, KernelParameters, + PromotionPolicy, ) from api.cas.casadm_params import OutputFormat, StatsFilter from api.cas.cli import * @@ -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: @@ -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=None, shortcut: bool = False ) -> Output: