Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API for setting promotion policy params #1523

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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=None, shortcut: bool = False
) -> Output:
Expand Down