test-api: refactor to fix circular dependencies
Signed-off-by: Kamil Gierszewski <kamil.gierszewski@huawei.com>
This commit is contained in:
parent
0e24e52686
commit
3606472e60
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# Copyright(c) 2019-2022 Intel Corporation
|
# Copyright(c) 2019-2022 Intel Corporation
|
||||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd.
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -14,6 +14,7 @@ from typing import List
|
|||||||
from api.cas import casadm
|
from api.cas import casadm
|
||||||
from api.cas.cache_config import *
|
from api.cas.cache_config import *
|
||||||
from api.cas.casadm_params import *
|
from api.cas.casadm_params import *
|
||||||
|
from api.cas.core_config import CoreStatus
|
||||||
from api.cas.ioclass_config import IoClass
|
from api.cas.ioclass_config import IoClass
|
||||||
from api.cas.version import CasVersion
|
from api.cas.version import CasVersion
|
||||||
from core.test_run_utils import TestRun
|
from core.test_run_utils import TestRun
|
||||||
@ -54,7 +55,7 @@ def get_caches() -> list:
|
|||||||
|
|
||||||
|
|
||||||
def get_cores(cache_id: int) -> list:
|
def get_cores(cache_id: int) -> list:
|
||||||
from api.cas.core import Core, CoreStatus
|
from api.cas.core import Core
|
||||||
|
|
||||||
cores_dict = get_cas_devices_dict()["cores"].values()
|
cores_dict = get_cas_devices_dict()["cores"].values()
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ def get_cores(cache_id: int) -> list:
|
|||||||
|
|
||||||
|
|
||||||
def get_inactive_cores(cache_id: int) -> list:
|
def get_inactive_cores(cache_id: int) -> list:
|
||||||
from api.cas.core import Core, CoreStatus
|
from api.cas.core import Core
|
||||||
|
|
||||||
cores_dict = get_cas_devices_dict()["cores"].values()
|
cores_dict = get_cas_devices_dict()["cores"].values()
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ def get_inactive_cores(cache_id: int) -> list:
|
|||||||
|
|
||||||
|
|
||||||
def get_detached_cores(cache_id: int) -> list:
|
def get_detached_cores(cache_id: int) -> list:
|
||||||
from api.cas.core import Core, CoreStatus
|
from api.cas.core import Core
|
||||||
|
|
||||||
cores_dict = get_cas_devices_dict()["cores"].values()
|
cores_dict = get_cas_devices_dict()["cores"].values()
|
||||||
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
#
|
#
|
||||||
# Copyright(c) 2019-2021 Intel Corporation
|
# Copyright(c) 2019-2021 Intel Corporation
|
||||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd.
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import List
|
from typing import List
|
||||||
from enum import Enum
|
|
||||||
|
|
||||||
from api.cas import casadm
|
from api.cas import casadm
|
||||||
from api.cas.cache_config import SeqCutOffParameters, SeqCutOffPolicy
|
from api.cas.cache_config import SeqCutOffParameters, SeqCutOffPolicy
|
||||||
from api.cas.casadm_params import StatsFilter
|
from api.cas.casadm_params import StatsFilter
|
||||||
from api.cas.casadm_parser import get_seq_cut_off_parameters, get_core_info_for_cache_by_path
|
from api.cas.casadm_parser import get_seq_cut_off_parameters, get_cas_devices_dict
|
||||||
|
from api.cas.core_config import CoreStatus
|
||||||
from api.cas.statistics import CoreStats, CoreIoClassStats
|
from api.cas.statistics import CoreStats, CoreIoClassStats
|
||||||
from core.test_run_utils import TestRun
|
from core.test_run_utils import TestRun
|
||||||
from storage_devices.device import Device
|
from storage_devices.device import Device
|
||||||
@ -21,13 +21,6 @@ from test_tools.common.wait import wait
|
|||||||
from type_def.size import Unit, Size
|
from type_def.size import Unit, Size
|
||||||
|
|
||||||
|
|
||||||
class CoreStatus(Enum):
|
|
||||||
empty = 0
|
|
||||||
active = 1
|
|
||||||
inactive = 2
|
|
||||||
detached = 3
|
|
||||||
|
|
||||||
|
|
||||||
SEQ_CUTOFF_THRESHOLD_MAX = Size(4194181, Unit.KibiByte)
|
SEQ_CUTOFF_THRESHOLD_MAX = Size(4194181, Unit.KibiByte)
|
||||||
SEQ_CUT_OFF_THRESHOLD_DEFAULT = Size(1, Unit.MebiByte)
|
SEQ_CUT_OFF_THRESHOLD_DEFAULT = Size(1, Unit.MebiByte)
|
||||||
|
|
||||||
@ -46,9 +39,18 @@ class Core(Device):
|
|||||||
self.partitions = []
|
self.partitions = []
|
||||||
self.block_size = None
|
self.block_size = None
|
||||||
|
|
||||||
def __get_core_info(self):
|
def __get_core_info(self) -> dict | None:
|
||||||
return get_core_info_for_cache_by_path(core_disk_path=self.core_device.path,
|
core_dicts = get_cas_devices_dict()["cores"].values()
|
||||||
target_cache_id=self.cache_id)
|
return next(
|
||||||
|
iter(
|
||||||
|
[
|
||||||
|
core
|
||||||
|
for core in core_dicts
|
||||||
|
if core["cache_id"] == self.cache_id
|
||||||
|
and core["device_path"] == self.core_device.path
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def create_filesystem(self, fs_type: Filesystem, force=True, blocksize=None):
|
def create_filesystem(self, fs_type: Filesystem, force=True, blocksize=None):
|
||||||
super().create_filesystem(fs_type, force, blocksize)
|
super().create_filesystem(fs_type, force, blocksize)
|
||||||
|
16
test/functional/api/cas/core_config.py
Normal file
16
test/functional/api/cas/core_config.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#
|
||||||
|
# Copyright(c) 2024-2025 Huawei Technologies Co., Ltd.
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class CoreStatus(Enum):
|
||||||
|
empty = "empty"
|
||||||
|
active = "active"
|
||||||
|
inactive = "inactive"
|
||||||
|
detached = "detached"
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.value
|
Loading…
Reference in New Issue
Block a user