From ad90a6928469d3840c20014f8f56609295790d06 Mon Sep 17 00:00:00 2001 From: Katarzyna Lapinska Date: Mon, 16 Dec 2019 12:23:51 +0100 Subject: [PATCH] Enable try-add method in CAS test-framework API --- test/functional/api/cas/casadm.py | 7 +++++++ test/functional/api/cas/cli.py | 5 +++++ test/functional/api/cas/core.py | 6 ++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/test/functional/api/cas/casadm.py b/test/functional/api/cas/casadm.py index ae943b5..e975dc1 100644 --- a/test/functional/api/cas/casadm.py +++ b/test/functional/api/cas/casadm.py @@ -72,6 +72,13 @@ def remove_detached(core_device: Device, shortcut: bool = False): return output +def try_add(core_device: Device, cache_id: int): + output = TestRun.executor.run(script_try_add_cmd(str(cache_id), core_device.system_path)) + if output.exit_code != 0: + raise CmdException("Failed to execute try add script command.", output) + return Core(core_device.system_path, cache_id) + + def reset_counters(cache_id: int, core_id: int = None, shortcut: bool = False): _core_id = None if core_id is None else str(core_id) output = TestRun.executor.run( diff --git a/test/functional/api/cas/cli.py b/test/functional/api/cas/cli.py index a29838d..9f222d2 100644 --- a/test/functional/api/cas/cli.py +++ b/test/functional/api/cas/cli.py @@ -19,6 +19,11 @@ def add_core_cmd(cache_id: str, core_dev: str, core_id: str = None, shortcut: bo return casadm_bin + command +def script_try_add_cmd(cache_id: str, core_dev: str): + return f"{casadm_bin} --script --add-core --try-add --cache-id {cache_id} " \ + f"--core-device {core_dev}" + + def remove_core_cmd(cache_id: str, core_id: str, force: bool = False, shortcut: bool = False): command = f" -R -i {cache_id} -j {core_id}" if shortcut \ else f" --remove-core --cache-id {cache_id} --core-id {core_id}" diff --git a/test/functional/api/cas/core.py b/test/functional/api/cas/core.py index b2e3839..88a67cc 100644 --- a/test/functional/api/cas/core.py +++ b/test/functional/api/cas/core.py @@ -32,8 +32,10 @@ class Core(Device): self.core_device = Device(core_device) self.system_path = None core_info = self.__get_core_info() - self.core_id = int(core_info["core_id"]) - Device.__init__(self, core_info["exp_obj"]) + 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 def __get_core_info(self):