From 838870fa10d36356d34044e48c9b5aec1ee25930 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Tue, 19 Oct 2021 14:43:02 +0200 Subject: [PATCH] pyocf: Use abstract Volume in generic code paths Signed-off-by: Adam Rutkowski --- tests/functional/pyocf/rio.py | 6 +++--- tests/functional/pyocf/types/core.py | 4 ++-- tests/functional/pyocf/types/ctx.py | 4 +--- tests/functional/tests/management/test_start_stop.py | 6 +++--- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/functional/pyocf/rio.py b/tests/functional/pyocf/rio.py index fcbe040..1462c16 100644 --- a/tests/functional/pyocf/rio.py +++ b/tests/functional/pyocf/rio.py @@ -13,7 +13,7 @@ from threading import Thread, Condition, Event from copy import deepcopy from pyocf.utils import Size -from pyocf.types.volume import RamVolume +from pyocf.types.volume import Volume from pyocf.types.io import Io, IoDir from pyocf.types.data import Data @@ -67,7 +67,7 @@ class JobSpec: qd: int = 1 size: Size = Size(0) io_size: Size = Size(0) - target: RamVolume = None + target: Volume = None time_based: bool = False time: timedelta = None continue_on_error: bool = False @@ -211,7 +211,7 @@ class Rio: self.global_jobspec.qd = qd return self - def target(self, target: RamVolume): + def target(self, target: Volume): self.global_jobspec.target = target return self diff --git a/tests/functional/pyocf/types/core.py b/tests/functional/pyocf/types/core.py index 88a28dc..33d076e 100644 --- a/tests/functional/pyocf/types/core.py +++ b/tests/functional/pyocf/types/core.py @@ -29,7 +29,7 @@ from .queue import Queue from .shared import Uuid, OcfCompletion, OcfError, SeqCutOffPolicy from .stats.core import CoreInfo from .stats.shared import UsageStats, RequestsStats, BlocksStats, ErrorsStats -from .volume import RamVolume +from .volume import Volume from ..ocf import OcfLib from ..utils import Size, struct_to_dict @@ -58,7 +58,7 @@ class Core: def __init__( self, - device: RamVolume, + device: Volume, name: str = "core", seq_cutoff_threshold: int = DEFAULT_SEQ_CUTOFF_THRESHOLD, seq_cutoff_promotion_count: int = DEFAULT_SEQ_CUTOFF_PROMOTION_COUNT, diff --git a/tests/functional/pyocf/types/ctx.py b/tests/functional/pyocf/types/ctx.py index dfa0939..d26ec35 100644 --- a/tests/functional/pyocf/types/ctx.py +++ b/tests/functional/pyocf/types/ctx.py @@ -12,8 +12,6 @@ from .cleaner import CleanerOps, Cleaner from .shared import OcfError from ..ocf import OcfLib from .queue import Queue -from .volume import RamVolume - class OcfCtxOps(Structure): _fields_ = [ @@ -84,7 +82,7 @@ class OcfCtx: byref(self.volume_types[self.volume_types_count].get_props()), ) if result != 0: - raise OcfError("RamVolume type registration failed", result) + raise OcfError("Volume type registration failed", result) self.volume_types_count += 1 diff --git a/tests/functional/tests/management/test_start_stop.py b/tests/functional/tests/management/test_start_stop.py index 2bdd8fc..0886def 100644 --- a/tests/functional/tests/management/test_start_stop.py +++ b/tests/functional/tests/management/test_start_stop.py @@ -24,7 +24,7 @@ from pyocf.types.core import Core from pyocf.types.data import Data from pyocf.types.io import IoDir from pyocf.types.shared import OcfError, OcfCompletion, CacheLineSize, SeqCutOffPolicy -from pyocf.types.volume import RamVolume +from pyocf.types.volume import Volume, RamVolume from pyocf.utils import Size logger = logging.getLogger(__name__) @@ -342,14 +342,14 @@ def test_start_cache_huge_device(pyocf_ctx_log_buffer, cls): pass_criteria: - Starting cache on device too big to handle should fail """ - class HugeDevice(RamVolume): + class HugeDevice(Volume): def get_length(self): return Size.from_B((cls * c_uint32(-1).value)) def submit_io(self, io): io.contents._end(io, 0) - cache_device = HugeDevice(Size.from_MiB(50)) + cache_device = HugeDevice() with pytest.raises(OcfError, match="OCF_ERR_INVAL_CACHE_DEV"): cache = Cache.start_on_device(cache_device, cache_line_size=cls, metadata_volatile=True)