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

Kamilg/fix bugs #1573

Merged
merged 6 commits into from
Oct 30, 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
2 changes: 1 addition & 1 deletion test/functional/api/cas/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def set_promotion_policy(self, policy: PromotionPolicy) -> Output:
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(),
threshold=promotion_params_nhit.threshold,
trigger=promotion_params_nhit.trigger
)

Expand Down
11 changes: 7 additions & 4 deletions test/functional/api/cas/cache_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def with_any_trait(flags: CacheModeTrait) -> list:


class SeqCutOffPolicy(Enum):
full = 0
always = 1
never = 2
full = "full"
always = "always"
never = "never"
DEFAULT = full

@classmethod
Expand All @@ -85,6 +85,9 @@ def from_name(cls, name):

raise ValueError(f"{name} is not a valid sequential cut off name")

def __str__(self):
return self.value

Deixx marked this conversation as resolved.
Show resolved Hide resolved

class MetadataMode(Enum):
normal = "normal"
Expand Down Expand Up @@ -240,7 +243,7 @@ def default_seq_cut_off_params():


class PromotionParametersNhit:
def __init__(self, threshold: Size = None, trigger: int = None):
def __init__(self, threshold: int = None, trigger: int = None):
self.threshold = threshold
self.trigger = trigger

Expand Down
41 changes: 36 additions & 5 deletions test/functional/api/cas/casadm_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,36 @@ def is_active(core):
]


def get_inactive_cores(cache_id: int) -> list:
from api.cas.core import Core, CoreStatus

cores_dict = get_cas_devices_dict()["cores"].values()

def is_inactive(core):
return CoreStatus[core["status"].lower()] == CoreStatus.inactive

return [
Core(core["device_path"], core["cache_id"])
for core in cores_dict
if is_inactive(core) and core["cache_id"] == cache_id
]


def get_detached_cores(cache_id: int) -> list:
from api.cas.core import Core, CoreStatus

cores_dict = get_cas_devices_dict()["cores"].values()

def is_detached(core):
return CoreStatus[core["status"].lower()] == CoreStatus.detached

return [
Core(core["device_path"], core["cache_id"])
for core in cores_dict
if is_detached(core) and core["cache_id"] == cache_id
]


def get_cas_devices_dict() -> dict:
device_list = list(csv.DictReader(casadm.list_caches(OutputFormat.csv).stdout.split("\n")))
devices = {"caches": {}, "cores": {}, "core_pool": {}}
Expand All @@ -92,9 +122,7 @@ def get_cas_devices_dict() -> dict:
]
if core_pool:
params.append(("core_pool", device))
devices["core_pool"][device["disk"]] = dict(
[(key, value) for key, value in params]
)
devices["core_pool"][device["disk"]] = dict([(key, value) for key, value in params])
else:
devices["cores"][(cache_id, int(device["id"]))] = dict(
[(key, value) for key, value in params]
Expand Down Expand Up @@ -205,11 +233,14 @@ def get_io_class_list(cache_id: int) -> list:
return ret


def get_core_info_by_path(core_disk_path) -> dict | None:
def get_core_info_for_cache_by_path(core_disk_path: str, target_cache_id: int) -> dict | None:
output = casadm.list_caches(OutputFormat.csv, by_id_path=True)
reader = csv.DictReader(io.StringIO(output.stdout))
cache_id = -1
for row in reader:
if row["type"] == "core" and row["disk"] == core_disk_path:
if row["type"] == "cache":
cache_id = int(row["id"])
if row["type"] == "core" and row["disk"] == core_disk_path and target_cache_id == cache_id:
return {
"core_id": row["id"],
"core_device": row["disk"],
Expand Down
7 changes: 4 additions & 3 deletions test/functional/api/cas/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from api.cas import casadm
from api.cas.cache_config import SeqCutOffParameters, SeqCutOffPolicy
from api.cas.casadm_params import StatsFilter
from api.cas.casadm_parser import get_seq_cut_off_parameters, get_core_info_by_path
from api.cas.casadm_parser import get_seq_cut_off_parameters, get_core_info_for_cache_by_path
from api.cas.statistics import CoreStats, CoreIoClassStats
from core.test_run_utils import TestRun
from storage_devices.device import Device
Expand All @@ -35,18 +35,19 @@ class Core(Device):
def __init__(self, core_device: str, cache_id: int):
self.core_device = Device(core_device)
self.path = None
self.cache_id = cache_id
core_info = self.__get_core_info()
# "-" is special case for cores in core pool
if core_info["core_id"] != "-":
self.core_id = int(core_info["core_id"])
if core_info["exp_obj"] != "-":
Device.__init__(self, core_info["exp_obj"])
self.cache_id = cache_id
self.partitions = []
self.block_size = None

def __get_core_info(self):
return get_core_info_by_path(self.core_device.path)
return get_core_info_for_cache_by_path(core_disk_path=self.core_device.path,
target_cache_id=self.cache_id)

def create_filesystem(self, fs_type: disk_utils.Filesystem, force=True, blocksize=None):
super().create_filesystem(fs_type, force, blocksize)
Expand Down
Loading