Remove inactive commands tests and API update
Signed-off-by: Daniel Madej <daniel.madej@intel.com>
This commit is contained in:
@@ -121,9 +121,12 @@ class Cache:
|
||||
def add_core(self, core_dev, core_id: int = None):
|
||||
return casadm.add_core(self, core_dev, core_id)
|
||||
|
||||
def remove_core(self, core_id, force: bool = False):
|
||||
def remove_core(self, core_id: int, force: bool = False):
|
||||
return casadm.remove_core(self.cache_id, core_id, force)
|
||||
|
||||
def remove_inactive_core(self, core_id: int, force: bool = False):
|
||||
return casadm.remove_inactive(self.cache_id, core_id, force)
|
||||
|
||||
def reset_counters(self):
|
||||
return casadm.reset_counters(self.cache_id)
|
||||
|
||||
|
@@ -69,6 +69,14 @@ def remove_core(cache_id: int, core_id: int, force: bool = False, shortcut: bool
|
||||
raise CmdException("Failed to remove core.", output)
|
||||
|
||||
|
||||
def remove_inactive(cache_id: int, core_id: int, force: bool = False, shortcut: bool = False):
|
||||
output = TestRun.executor.run(
|
||||
remove_inactive_cmd(
|
||||
cache_id=str(cache_id), core_id=str(core_id), force=force, shortcut=shortcut))
|
||||
if output.exit_code != 0:
|
||||
raise CmdException("Failed to remove inactive core.", output)
|
||||
|
||||
|
||||
def remove_detached(core_device: Device, shortcut: bool = False):
|
||||
output = TestRun.executor.run(
|
||||
remove_detached_cmd(core_device=core_device.path, shortcut=shortcut))
|
||||
|
@@ -55,6 +55,14 @@ def remove_core_cmd(cache_id: str, core_id: str, force: bool = False, shortcut:
|
||||
return casadm_bin + command
|
||||
|
||||
|
||||
def remove_inactive_cmd(cache_id: str, core_id: str, force: bool = False, shortcut: bool = False):
|
||||
command = f" --remove-inactive {'-i' if shortcut else '--cache-id'} {cache_id} " \
|
||||
f"{'-j' if shortcut else '--core-id'} {core_id}"
|
||||
if force:
|
||||
command += " -f" if shortcut else " --force"
|
||||
return casadm_bin + command
|
||||
|
||||
|
||||
def remove_detached_cmd(core_device: str, shortcut: bool = False):
|
||||
command = " --remove-detached" + (" -d " if shortcut else " --device ") + core_device
|
||||
return casadm_bin + command
|
||||
|
@@ -30,9 +30,13 @@ reinitialize_with_force_or_recovery = [
|
||||
r" discard on-disk metadata and start fresh cache instance\."
|
||||
]
|
||||
|
||||
remove_inactive_core = [
|
||||
r"Error while removing core device \d+ from cache instance \d+",
|
||||
r"Core device is in inactive state"
|
||||
remove_inactive_core_with_remove_command = [
|
||||
r"Core is inactive\. To manage the inactive core use '--remove-inactive' command\."
|
||||
]
|
||||
|
||||
remove_inactive_dirty_core = [
|
||||
r"The cache contains dirty data assigned to the core\. If you want to ",
|
||||
r"continue, please use --force option\.\nWarning: the data will be lost"
|
||||
]
|
||||
|
||||
stop_cache_incomplete = [
|
||||
|
@@ -2,14 +2,21 @@
|
||||
# Copyright(c) 2019-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
||||
#
|
||||
from datetime import timedelta
|
||||
from typing import List
|
||||
|
||||
from aenum import Enum
|
||||
|
||||
from api.cas.casadm_parser import *
|
||||
from api.cas.cli import *
|
||||
from api.cas import casadm
|
||||
from api.cas.cache_config import SeqCutOffParameters, SeqCutOffPolicy
|
||||
from api.cas.casadm_params import OutputFormat, StatsFilter
|
||||
from api.cas.casadm_parser import get_statistics, get_seq_cut_off_parameters
|
||||
from api.cas.statistics import CoreStats, CoreIoClassStats
|
||||
from core.test_run_utils import TestRun
|
||||
from storage_devices.device import Device
|
||||
from test_tools import fs_utils, disk_utils
|
||||
from test_utils.os_utils import *
|
||||
from test_utils.os_utils import wait
|
||||
from test_utils.os_utils import wait, sync
|
||||
from test_utils.size import Unit, Size
|
||||
|
||||
|
||||
class CoreStatus(Enum):
|
||||
@@ -28,6 +35,7 @@ class Core(Device):
|
||||
self.core_device = Device(core_device)
|
||||
self.path = None
|
||||
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"] != "-":
|
||||
@@ -37,20 +45,15 @@ class Core(Device):
|
||||
self.block_size = None
|
||||
|
||||
def __get_core_info(self):
|
||||
output = TestRun.executor.run(
|
||||
list_cmd(OutputFormat.csv.name, by_id_path=False))
|
||||
if output.exit_code != 0:
|
||||
raise Exception("Failed to execute list caches command.")
|
||||
output_lines = output.stdout.splitlines()
|
||||
for line in output_lines:
|
||||
split_line = line.split(',')
|
||||
if split_line[0] == "core" and (
|
||||
split_line[2] == os.path.join("/dev", self.core_device.get_device_id())
|
||||
or split_line[5] == self.path):
|
||||
return {"core_id": split_line[1],
|
||||
"core_device": split_line[2],
|
||||
"status": split_line[3],
|
||||
"exp_obj": split_line[5]}
|
||||
output = casadm.list_caches(OutputFormat.csv, by_id_path=True)
|
||||
split_line = next(
|
||||
line.split(',') for line in output.stdout.splitlines()
|
||||
if line.startswith("core") and self.core_device.path in line
|
||||
)
|
||||
return {"core_id": split_line[1],
|
||||
"core_device": split_line[2],
|
||||
"status": split_line[3],
|
||||
"exp_obj": split_line[5]}
|
||||
|
||||
def create_filesystem(self, fs_type: disk_utils.Filesystem, force=True, blocksize=None):
|
||||
super().create_filesystem(fs_type, force, blocksize)
|
||||
@@ -104,6 +107,9 @@ class Core(Device):
|
||||
def remove_core(self, force: bool = False):
|
||||
return casadm.remove_core(self.cache_id, self.core_id, force)
|
||||
|
||||
def remove_inactive(self, force: bool = False):
|
||||
return casadm.remove_inactive(self.cache_id, self.core_id, force)
|
||||
|
||||
def reset_counters(self):
|
||||
return casadm.reset_counters(self.cache_id, self.core_id)
|
||||
|
||||
|
Reference in New Issue
Block a user