Skip to content
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
15 changes: 14 additions & 1 deletion test/functional/api/cas/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
FlushParametersAcp,
SeqCutOffParameters,
SeqCutOffPolicy,
SeqDetectParameters,
PromotionPolicy,
PromotionParametersNhit,
CacheConfig,
Expand Down Expand Up @@ -175,7 +176,6 @@ def set_seq_cutoff_parameters(self, seq_cutoff_param: SeqCutOffParameters) -> Ou
self.cache_id,
threshold=seq_cutoff_param.threshold,
policy=seq_cutoff_param.policy,
promotion_count=seq_cutoff_param.promotion_count,
)

def set_seq_cutoff_threshold(self, threshold: Size) -> Output:
Expand All @@ -184,6 +184,19 @@ def set_seq_cutoff_threshold(self, threshold: Size) -> Output:
def set_seq_cutoff_policy(self, policy: SeqCutOffPolicy) -> Output:
return casadm.set_param_cutoff(self.cache_id, threshold=None, policy=policy)

def set_seq_detect_parameters(self, seq_detect_param: SeqDetectParameters) -> Output:
return casadm.set_param_seq_detect(
self.cache_id,
promotion_count=seq_detect_param.promotion_count,
promotion_threshold=seq_detect_param.promotion_threshold,
)

def set_seq_detect_promotion_count(self, promotion_count: int) -> Output:
return casadm.set_param_seq_detect(self.cache_id, promotion_count=promotion_count)

def set_seq_detect_promotion_threshold(self, promotion_threshold: Size) -> Output:
return casadm.set_param_seq_detect(self.cache_id, promotion_threshold=promotion_threshold)

def set_cleaning_policy(self, cleaning_policy: CleaningPolicy) -> Output:
return casadm.set_param_cleaning(self.cache_id, cleaning_policy)

Expand Down
40 changes: 30 additions & 10 deletions test/functional/api/cas/cache_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,37 +261,57 @@ def default_acp_params():


class SeqCutOffParameters:
def __init__(
self, policy: SeqCutOffPolicy = None, threshold: Size = None, promotion_count: int = None
):
def __init__(self, policy: SeqCutOffPolicy = None, threshold: Size = None):
self.policy = policy
self.threshold = threshold
self.promotion_count = promotion_count

def __eq__(self, other):
def fill_default(p):
default = self.default_seq_cut_off_params()
p = copy.copy(p)
p.policy = p.policy or default.policy
p.threshold = p.threshold or default.threshold
p.promotion_count = p.promotion_count or default.promotion_count
return p

a = fill_default(self)
b = fill_default(other)

return (
a.policy == b.policy
and a.threshold == b.threshold
and a.promotion_count == b.promotion_count
)
return a.policy == b.policy and a.threshold == b.threshold

@staticmethod
def default_seq_cut_off_params():
return SeqCutOffParameters(
threshold=Size(1024, Unit.KibiByte),
policy=SeqCutOffPolicy.full,
)


class SeqDetectParameters:
def __init__(self, promotion_count: int = None, promotion_threshold: Size = None):
self.promotion_count = promotion_count
self.promotion_threshold = promotion_threshold

def __eq__(self, other):
def fill_default(p):
default = self.default_seq_detect_params()
p = copy.copy(p)
p.promotion_count = p.promotion_count or default.promotion_count
p.promotion_threshold = p.promotion_threshold or default.promotion_threshold
return p

a = fill_default(self)
b = fill_default(other)

return (
a.promotion_count == b.promotion_count
and a.promotion_threshold == b.promotion_threshold
)

@staticmethod
def default_seq_detect_params():
return SeqDetectParameters(
promotion_count=8,
promotion_threshold=Size(1024, Unit.KibiByte),
)


Expand Down
47 changes: 44 additions & 3 deletions test/functional/api/cas/casadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,16 @@ def set_param_cutoff(
core_id: int = None,
threshold: Size = None,
policy: SeqCutOffPolicy = None,
promotion_count: int = None,
shortcut: bool = False,
) -> Output:
_core_id = str(core_id) if core_id is not None else None
_threshold = str(int(threshold.get_value(Unit.KibiByte))) if threshold else None
_policy = policy.name if policy else None
_promotion_count = str(promotion_count) if promotion_count is not None else None
command = set_param_cutoff_cmd(
cache_id=str(cache_id),
core_id=_core_id,
threshold=_threshold,
policy=_policy,
promotion_count=_promotion_count,
shortcut=shortcut,
)
output = TestRun.executor.run(command)
Expand All @@ -171,6 +168,33 @@ def set_param_cutoff(
return output


def set_param_seq_detect(
cache_id: int,
core_id: int = None,
promotion_count: int = None,
promotion_threshold: Size = None,
shortcut: bool = False,
) -> Output:
_core_id = str(core_id) if core_id is not None else None
_promotion_count = str(promotion_count) if promotion_count is not None else None
_promotion_threshold = (
str(int(promotion_threshold.get_value(Unit.KibiByte)))
if promotion_threshold is not None
else None
)
command = set_param_seq_detect_cmd(
cache_id=str(cache_id),
core_id=_core_id,
promotion_count=_promotion_count,
promotion_threshold=_promotion_threshold,
shortcut=shortcut,
)
output = TestRun.executor.run(command)
if output.exit_code != 0:
raise CmdException("Error while setting sequence detector params.", output)
return output


def set_param_cleaning(cache_id: int, policy: CleaningPolicy, shortcut: bool = False) -> Output:
output = TestRun.executor.run(
set_param_cleaning_cmd(cache_id=str(cache_id), policy=policy.name, shortcut=shortcut)
Expand Down Expand Up @@ -279,6 +303,23 @@ def get_param_cutoff(
return output


def get_param_seq_detect(
cache_id: int, core_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_seq_detect_cmd(
cache_id=str(cache_id),
core_id=str(core_id),
output_format=_output_format,
shortcut=shortcut,
)
)
if output.exit_code != 0:
raise CmdException("Getting sequence detector params failed.", output)
return output


def get_param_cleaning(cache_id: int, output_format: OutputFormat = None, shortcut: bool = False):
_output_format = output_format.name if output_format else None
output = TestRun.executor.run(
Expand Down
2 changes: 2 additions & 0 deletions test/functional/api/cas/casadm_params.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd.
# Copyright(c) 2026 Unvertical
# SPDX-License-Identifier: BSD-3-Clause
#

Expand All @@ -9,6 +10,7 @@

class ParamName(Enum):
seq_cutoff = "seq-cutoff"
seq_detect = "seq-detect"
cleaning = "cleaning"
cleaning_alru = "cleaning-alru"
cleaning_acp = "cleaning-acp"
Expand Down
15 changes: 13 additions & 2 deletions test/functional/api/cas/casadm_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,22 @@ def get_seq_cut_off_parameters(cache_id: int, core_id: int):
seq_cut_off_params.threshold = Size(int(line.split(",")[1]), Unit.KibiByte)
if "Sequential cutoff policy" in line:
seq_cut_off_params.policy = SeqCutOffPolicy.from_name(line.split(",")[1])
if "Sequential cutoff promotion request count threshold" in line:
seq_cut_off_params.promotion_count = int(line.split(",")[1])
return seq_cut_off_params


def get_seq_detect_parameters(cache_id: int, core_id: int):
casadm_output = casadm.get_param_seq_detect(
cache_id, core_id, casadm.OutputFormat.csv
).stdout.splitlines()
seq_detect_params = SeqDetectParameters()
for line in casadm_output:
if "Sequence detector promotion request count" in line:
seq_detect_params.promotion_count = int(line.split(",")[1])
if "Sequence detector promotion threshold" in line:
seq_detect_params.promotion_threshold = Size(int(line.split(",")[1]), Unit.KibiByte)
return seq_detect_params


def get_casadm_version():
casadm_output = casadm.print_version(OutputFormat.csv).stdout.split("\n")
version_str = casadm_output[1].split(",")[-1]
Expand Down
31 changes: 30 additions & 1 deletion test/functional/api/cas/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def set_param_cutoff_cmd(
core_id: str = None,
threshold: str = None,
policy: str = None,
promotion_count: str = None,
shortcut: bool = False,
) -> str:
name = "seq-cutoff"
Expand All @@ -88,8 +87,24 @@ def set_param_cutoff_cmd(
command += (" -t " if shortcut else " --threshold ") + threshold
if policy:
command += (" -p " if shortcut else " --policy ") + policy
return casadm_bin + command


def set_param_seq_detect_cmd(
cache_id: str,
core_id: str = None,
promotion_count: str = None,
promotion_threshold: str = None,
shortcut: bool = False,
) -> str:
name = "seq-detect"
command = _set_param_cmd(name=name, cache_id=cache_id, shortcut=shortcut)
if core_id:
command += (" -j " if shortcut else " --core-id ") + core_id
if promotion_count:
command += " --promotion-count " + promotion_count
if promotion_threshold:
command += " --promotion-threshold " + promotion_threshold
return casadm_bin + command


Expand Down Expand Up @@ -188,6 +203,20 @@ def get_param_cutoff_cmd(
return casadm_bin + command


def get_param_seq_detect_cmd(
cache_id: str, core_id: str, output_format: str = None, shortcut: bool = False
) -> str:
name = "seq-detect"
command = _get_param_cmd(
name=name,
cache_id=cache_id,
output_format=output_format,
shortcut=shortcut,
)
command += (" -j " if shortcut else " --core-id ") + core_id
return casadm_bin + command


def get_param_promotion_cmd(
cache_id: str, output_format: str = None, shortcut: bool = False
) -> str:
Expand Down
15 changes: 13 additions & 2 deletions test/functional/api/cas/cli_help_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,26 @@
r"Usage: casadm --set-param --name \<NAME\>",
r"Set various runtime parameters",
r"Valid values of NAME are:",
r"seq-detect - Sequence detector parameters",
r"seq-cutoff - Sequential cutoff parameters",
r"cleaning - Cleaning policy parameters",
r"promotion - Promotion policy parameters",
r"promotion-nhit - Promotion policy NHIT parameters",
r"cleaning-alru - Cleaning policy ALRU parameters",
r"cleaning-acp - Cleaning policy ACP parameters",
r"Options that are valid with --set-param \(-X\) --name \(-n\) seq-detect are:",
r"-i --cache-id \<ID\> Identifier of cache instance \<1-16384\>",
r"-j --core-id \<ID\> Identifier of core \<0-4095\> within given cache "
r"instance",
r" --promotion-count \<NUMBER\> Sequence detector stream promotion request count",
r" --promotion-threshold \<KiB\> Sequence detector stream promotion threshold \[KiB\]",
r"Options that are valid with --set-param \(-X\) --name \(-n\) seq-cutoff are:",
r"-i --cache-id \<ID\> Identifier of cache instance \<1-16384\>",
r"-j --core-id \<ID\> Identifier of core \<0-4095\> within given cache "
r"instance",
r"-t --threshold \<KiB\> Sequential cutoff activation threshold \[KiB\]",
r"-p --policy \<POLICY\> Sequential cutoff policy\. Available policies: "
r"\{always|full|never\}",
r" --promotion-count \<NUMBER\> Sequential cutoff stream promotion request count "
r"threshold",
r"Options that are valid with --set-param \(-X\) --name \(-n\) cleaning are:",
r"-i --cache-id \<ID\> Identifier of cache instance \<1-16384\>",
r"-p --policy \<POLICY\> Cleaning policy type\. Available policy types: "
Expand Down Expand Up @@ -138,12 +143,18 @@
r"Usage: casadm --get-param --name \<NAME\>",
r"Get various runtime parameters",
r"Valid values of NAME are:",
r"seq-detect - Sequence detector parameters",
r"seq-cutoff - Sequential cutoff parameters",
r"cleaning - Cleaning policy parameters",
r"cleaning-alru - Cleaning policy ALRU parameters",
r"cleaning-acp - Cleaning policy ACP parameters",
r"promotion - Promotion policy parameters",
r"promotion-nhit - Promotion policy NHIT parameters",
r"Options that are valid with --get-param \(-G\) --name \(-n\) seq-detect are:",
r"-i --cache-id \<ID\> Identifier of cache instance \<1-16384\>",
r"-j --core-id \<ID\> Identifier of core \<0-4095\> within given cache "
r"instance",
r"-o --output-format \<FORMAT\> Output format: \{table|csv\}",
r"Options that are valid with --get-param \(-G\) --name \(-n\) seq-cutoff are:",
r"-i --cache-id \<ID\> Identifier of cache instance \<1-16384\>",
r"-j --core-id \<ID\> Identifier of core \<0-4095\> within given cache "
Expand Down
10 changes: 10 additions & 0 deletions test/functional/api/cas/cli_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@
r"Cannot parse configuration file - error in line 2 in column 1 \(IO class id\)\."
]

illegal_io_class_prefetch_name = [
r"IO class 33 must have the default name 'prefetch'\n"
r"Cannot parse configuration file - error in line 2 in column 2 \(IO class name\)\."
]

illegal_io_class_reserved_prefetch_name = [
r"The name 'prefetch' is reserved for IO class 33\n"
r"Cannot parse configuration file - error in line 2 in column 2 \(IO class name\)\."
]

illegal_io_class_invalid_priority = [
r"Invalid prio, must be a correct unsigned decimal integer\.\n"
r"Cannot parse configuration file - error in line 2 in column 3 \(Eviction priority\)"
Expand Down
Loading
Loading