From 7f60aa0dd68421698477da50ca389098eb8a4a37 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Mon, 20 Dec 2021 15:25:38 +0100 Subject: [PATCH] pyocf: fix error handling in Cache::stop() Write error in cache stop means the instance was in fact stopped. Signed-off-by: Adam Rutkowski --- tests/functional/pyocf/types/cache.py | 6 +++++- tests/functional/pyocf/types/shared.py | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/functional/pyocf/types/cache.py b/tests/functional/pyocf/types/cache.py index 5434391..b440977 100644 --- a/tests/functional/pyocf/types/cache.py +++ b/tests/functional/pyocf/types/cache.py @@ -700,7 +700,8 @@ class Cache: self.owner.lib.ocf_mngt_cache_stop(self.cache_handle, c, None) c.wait() - if c.results["error"]: + err = OcfErrorCode(-1 * c.results["error"]) + if err != OcfErrorCode.OCF_OK and err != OcfErrorCode.OCF_ERR_WRITE_CACHE: self.write_unlock() raise OcfError("Failed stopping cache", c.results["error"]) @@ -712,6 +713,9 @@ class Cache: self.owner.caches.remove(self) + if err != OcfErrorCode.OCF_OK: + raise OcfError("Failed stopping cache", c.results["error"]) + def flush(self): self.write_lock() diff --git a/tests/functional/pyocf/types/shared.py b/tests/functional/pyocf/types/shared.py index 8c2c274..d15d8a5 100644 --- a/tests/functional/pyocf/types/shared.py +++ b/tests/functional/pyocf/types/shared.py @@ -12,6 +12,7 @@ from ..utils import Size as S class OcfErrorCode(IntEnum): + OCF_OK = 0 OCF_ERR_INVAL = 1000000 OCF_ERR_AGAIN = auto() OCF_ERR_INTR = auto()