pyocf: Rename Volume to RamVolume

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski 2021-10-19 14:46:06 +02:00
parent 062f63e4ff
commit 16f9d58f28
22 changed files with 198 additions and 196 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2021 Intel Corporation
# Copyright(c) 2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -13,7 +13,7 @@ from threading import Thread, Condition, Event
from copy import deepcopy
from pyocf.utils import Size
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
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: Volume = None
target: RamVolume = 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: Volume):
def target(self, target: RamVolume):
self.global_jobspec.target = target
return self

View File

@ -38,7 +38,7 @@ from .stats.cache import CacheInfo
from .ioclass import IoClassesInfo, IoClassInfo
from .stats.shared import UsageStats, RequestsStats, BlocksStats, ErrorsStats
from .ctx import OcfCtx
from .volume import Volume
from .volume import RamVolume
class Backfill(Structure):
@ -603,7 +603,7 @@ class Cache:
raise OcfError("Failed getting core by name", result)
uuid = self.owner.lib.ocf_core_get_uuid_wrapper(core_handle)
device = Volume.get_by_uuid(uuid.contents._data.decode("ascii"))
device = RamVolume.get_by_uuid(uuid.contents._data.decode("ascii"))
core = Core(device)
core.cache = self
core.handle = core_handle

View File

@ -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 Volume
from .volume import RamVolume
from ..ocf import OcfLib
from ..utils import Size, struct_to_dict
@ -58,7 +58,7 @@ class Core:
def __init__(
self,
device: Volume,
device: RamVolume,
name: str = "core",
seq_cutoff_threshold: int = DEFAULT_SEQ_CUTOFF_THRESHOLD,
seq_cutoff_promotion_count: int = DEFAULT_SEQ_CUTOFF_PROMOTION_COUNT,

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -12,7 +12,7 @@ from .cleaner import CleanerOps, Cleaner
from .shared import OcfError
from ..ocf import OcfLib
from .queue import Queue
from .volume import Volume
from .volume import RamVolume
class OcfCtxOps(Structure):
@ -84,7 +84,7 @@ class OcfCtx:
byref(self.volume_types[self.volume_types_count].get_props()),
)
if result != 0:
raise OcfError("Volume type registration failed", result)
raise OcfError("RamVolume type registration failed", result)
self.volume_types_count += 1

View File

@ -77,7 +77,7 @@ class VolumeIoPriv(Structure):
VOLUME_POISON = 0x13
class Volume():
class RamVolume():
_instances_ = weakref.WeakValueDictionary()
_uuid_ = weakref.WeakValueDictionary()
@ -89,7 +89,7 @@ class Volume():
if uuid:
if uuid in type(self)._uuid_:
raise Exception(
"Volume with uuid {} already created".format(uuid)
"RamVolume with uuid {} already created".format(uuid)
)
self.uuid = uuid
else:
@ -105,7 +105,7 @@ class Volume():
self.opened = False
def get_copy(self):
new_volume = Volume(self.size)
new_volume = RamVolume(self.size)
memmove(new_volume.data, self.data, self.size)
return new_volume
@ -152,7 +152,7 @@ class Volume():
@VolumeOps.SUBMIT_IO
def _submit_io(io):
io_structure = cast(io, POINTER(Io))
volume = Volume.get_instance(
volume = RamVolume.get_instance(
OcfLib.getInstance().ocf_io_get_volume(io_structure)
)
@ -162,7 +162,7 @@ class Volume():
@VolumeOps.SUBMIT_FLUSH
def _submit_flush(flush):
io_structure = cast(flush, POINTER(Io))
volume = Volume.get_instance(
volume = RamVolume.get_instance(
OcfLib.getInstance().ocf_io_get_volume(io_structure)
)
@ -177,7 +177,7 @@ class Volume():
@VolumeOps.SUBMIT_DISCARD
def _submit_discard(discard):
io_structure = cast(discard, POINTER(Io))
volume = Volume.get_instance(
volume = RamVolume.get_instance(
OcfLib.getInstance().ocf_io_get_volume(io_structure)
)
@ -196,35 +196,35 @@ class Volume():
)
uuid = str(uuid_ptr.contents._data, encoding="ascii")
try:
volume = Volume.get_by_uuid(uuid)
volume = RamVolume.get_by_uuid(uuid)
except: # noqa E722 TODO:Investigate whether this really should be so broad
print("Tried to access unallocated volume {}".format(uuid))
print("{}".format(Volume._uuid_))
print("{}".format(RamVolume._uuid_))
return -1
if volume.opened:
return -OcfErrorCode.OCF_ERR_NOT_OPEN_EXC
Volume._instances_[ref] = volume
RamVolume._instances_[ref] = volume
return volume.open()
@staticmethod
@VolumeOps.CLOSE
def _close(ref):
volume = Volume.get_instance(ref)
volume = RamVolume.get_instance(ref)
volume.close()
volume.opened = False
@staticmethod
@VolumeOps.GET_MAX_IO_SIZE
def _get_max_io_size(ref):
return Volume.get_instance(ref).get_max_io_size()
return RamVolume.get_instance(ref).get_max_io_size()
@staticmethod
@VolumeOps.GET_LENGTH
def _get_length(ref):
return Volume.get_instance(ref).get_length()
return RamVolume.get_instance(ref).get_length()
@staticmethod
@IoOps.SET_DATA
@ -322,7 +322,7 @@ class Volume():
return string_at(self.data_ptr, self.size)
class ErrorDevice(Volume):
class ErrorDevice(RamVolume):
def __init__(
self,
size,
@ -384,7 +384,7 @@ class ErrorDevice(Volume):
self.stats["errors"] = {IoDir.WRITE: 0, IoDir.READ: 0}
class TraceDevice(Volume):
class TraceDevice(RamVolume):
def __init__(self, size, trace_fcn=None, uuid=None):
super().__init__(size, uuid)
self.trace_fcn = trace_fcn

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -8,7 +8,7 @@ from ctypes import c_int
from pyocf.types.cache import Cache
from pyocf.types.core import Core
from pyocf.types.volume import Volume, ErrorDevice
from pyocf.types.volume import RamVolume, ErrorDevice
from pyocf.types.data import Data
from pyocf.types.io import IoDir
from pyocf.utils import Size as S
@ -21,8 +21,8 @@ def test_ctx_fixture(pyocf_ctx):
def test_simple_wt_write(pyocf_ctx):
cache_device = Volume(S.from_MiB(50))
core_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
core_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device)
core = Core.using_device(core_device)
@ -51,14 +51,14 @@ def test_start_corrupted_metadata_lba(pyocf_ctx):
def test_load_cache_no_preexisting_data(pyocf_ctx):
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
with pytest.raises(OcfError, match="OCF_ERR_NO_METADATA"):
cache = Cache.load_from_device(cache_device)
def test_load_cache(pyocf_ctx):
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device)
cache.stop()
@ -67,7 +67,7 @@ def test_load_cache(pyocf_ctx):
def test_load_cache_recovery(pyocf_ctx):
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device)
@ -80,8 +80,8 @@ def test_load_cache_recovery(pyocf_ctx):
@pytest.mark.parametrize("open_cores", [True, False])
def test_load_cache_with_cores(pyocf_ctx, open_cores):
cache_device = Volume(S.from_MiB(40))
core_device = Volume(S.from_MiB(40))
cache_device = RamVolume(S.from_MiB(40))
core_device = RamVolume(S.from_MiB(40))
cache = Cache.start_on_device(cache_device)
core = Core.using_device(core_device, name="test_core")

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -10,7 +10,7 @@ import gc
sys.path.append(os.path.join(os.path.dirname(__file__), os.path.pardir))
from pyocf.types.logger import LogLevel, DefaultLogger, BufferLogger
from pyocf.types.volume import Volume, ErrorDevice
from pyocf.types.volume import RamVolume, ErrorDevice
from pyocf.types.ctx import OcfCtx
@ -21,7 +21,7 @@ def pytest_configure(config):
@pytest.fixture()
def pyocf_ctx():
c = OcfCtx.with_defaults(DefaultLogger(LogLevel.WARN))
c.register_volume_type(Volume)
c.register_volume_type(RamVolume)
c.register_volume_type(ErrorDevice)
yield c
c.exit()
@ -32,7 +32,7 @@ def pyocf_ctx():
def pyocf_ctx_log_buffer():
logger = BufferLogger(LogLevel.DEBUG)
c = OcfCtx.with_defaults(logger)
c.register_volume_type(Volume)
c.register_volume_type(RamVolume)
c.register_volume_type(ErrorDevice)
yield logger
c.exit()

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2020-2021 Intel Corporation
# Copyright(c) 2020-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -12,7 +12,7 @@ import pytest
from pyocf.types.cache import Cache, CacheMode
from pyocf.types.core import Core
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.types.data import Data
from pyocf.types.io import IoDir
from pyocf.utils import Size
@ -53,7 +53,7 @@ def io_to_exp_obj(core, address, size, data, offset, direction, flags):
)
class FlagsValVolume(Volume):
class FlagsValVolume(RamVolume):
def __init__(self, size, flags):
self.flags = flags
self.check = False

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -10,7 +10,7 @@ from datetime import timedelta
from pyocf.types.cache import Cache, PromotionPolicy, NhitParams
from pyocf.types.core import Core
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.types.data import Data
from pyocf.types.io import IoDir
from pyocf.utils import Size
@ -28,8 +28,8 @@ def test_init_nhit(pyocf_ctx, promotion_policy):
* verify that promotion policy type is properly reflected in stats
"""
cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
core_device = RamVolume(Size.from_MiB(50))
cache = Cache.start_on_device(cache_device, promotion_policy=promotion_policy)
core = Core.using_device(core_device)
@ -55,8 +55,8 @@ def test_change_to_nhit_and_back_io_in_flight(pyocf_ctx):
"""
# Step 1
cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
core_device = RamVolume(Size.from_MiB(50))
cache = Cache.start_on_device(cache_device)
core = Core.using_device(core_device)
@ -137,8 +137,8 @@ def test_promoted_after_hits_various_thresholds(
"""
# Step 1
cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
core_device = RamVolume(Size.from_MiB(50))
cache = Cache.start_on_device(cache_device, promotion_policy=PromotionPolicy.NHIT)
core = Core.using_device(core_device)
@ -207,8 +207,8 @@ def test_partial_hit_promotion(pyocf_ctx):
"""
# Step 1
cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
core_device = RamVolume(Size.from_MiB(50))
cache = Cache.start_on_device(cache_device)
core = Core.using_device(core_device)

View File

@ -1,4 +1,5 @@
# Copyright(c) 2019-2021 Intel Corporation
#
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -13,7 +14,7 @@ from datetime import datetime
from pyocf.types.cache import Cache, CacheMode
from pyocf.types.core import Core
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.types.data import Data
from pyocf.types.io import IoDir
from pyocf.utils import Size
@ -259,8 +260,8 @@ def test_read_data_consistency(pyocf_ctx, cacheline_size, cache_mode, rand_seed)
result_b = bytes(WORKSET_SIZE)
cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
core_device = RamVolume(Size.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=CacheMode.WO, cache_line_size=cacheline_size

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2020-2021 Intel Corporation
# Copyright(c) 2020-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -10,7 +10,7 @@ import pytest
from pyocf.types.cache import Cache, CacheMode
from pyocf.types.core import Core
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.types.data import Data
from pyocf.types.io import IoDir
from pyocf.utils import Size
@ -90,8 +90,8 @@ def test_seq_cutoff_max_streams(pyocf_ctx):
non_active_stream = choice(streams)
streams.remove(non_active_stream)
cache = Cache.start_on_device(Volume(Size.from_MiB(200)), cache_mode=CacheMode.WT)
core = Core.using_device(Volume(core_size), seq_cutoff_promotion_count=1)
cache = Cache.start_on_device(RamVolume(Size.from_MiB(200)), cache_mode=CacheMode.WT)
core = Core.using_device(RamVolume(core_size), seq_cutoff_promotion_count=1)
cache.add_core(core)

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -14,7 +14,7 @@ from pyocf.types.core import Core
from pyocf.types.data import Data
from pyocf.types.io import IoDir
from pyocf.types.shared import OcfCompletion, CacheLineSize, SeqCutOffPolicy, CacheLines
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.utils import Size
logger = logging.getLogger(__name__)
@ -24,10 +24,10 @@ logger = logging.getLogger(__name__)
@pytest.mark.parametrize("mode", [CacheMode.WT])
def test_eviction_two_cores(pyocf_ctx, mode: CacheMode, cls: CacheLineSize):
"""Test if eviction works correctly when remapping cachelines between distinct cores."""
cache_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
core_device1 = Volume(Size.from_MiB(40))
core_device2 = Volume(Size.from_MiB(40))
core_device1 = RamVolume(Size.from_MiB(40))
core_device2 = RamVolume(Size.from_MiB(40))
cache = Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)
cache.set_seq_cut_off_policy(SeqCutOffPolicy.NEVER)
cache_size = cache.get_stats()["conf"]["size"]
@ -52,9 +52,9 @@ def test_eviction_two_cores(pyocf_ctx, mode: CacheMode, cls: CacheLineSize):
@pytest.mark.parametrize("mode", [CacheMode.WT, CacheMode.WB, CacheMode.WO])
def test_write_size_greater_than_cache(pyocf_ctx, mode: CacheMode, cls: CacheLineSize):
"""Test if eviction does not occur when IO greater than cache size is submitted."""
cache_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(200))
core_device = RamVolume(Size.from_MiB(200))
cache = Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)
cache_size = cache.get_stats()["conf"]["size"]
core_exported = Core.using_device(core_device)
@ -106,8 +106,8 @@ def test_write_size_greater_than_cache(pyocf_ctx, mode: CacheMode, cls: CacheLin
@pytest.mark.parametrize("cls", CacheLineSize)
def test_evict_overflown_pinned(pyocf_ctx, cls: CacheLineSize):
""" Verify if overflown pinned ioclass is evicted """
cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(100))
cache_device = RamVolume(Size.from_MiB(50))
core_device = RamVolume(Size.from_MiB(100))
cache = Cache.start_on_device(
cache_device, cache_mode=CacheMode.WT, cache_line_size=cls
)

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2020-2021 Intel Corporation
# Copyright(c) 2020-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -12,7 +12,7 @@ import pytest
from pyocf.types.cache import Cache, CacheMode
from pyocf.types.core import Core
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.types.data import Data
from pyocf.types.io import IoDir
from pyocf.utils import Size
@ -53,7 +53,7 @@ def io_to_exp_obj(core, address, size, data, offset, direction, flags):
)
class FlushValVolume(Volume):
class FlushValVolume(RamVolume):
def __init__(self, size):
self.flush_last = False
super().__init__(size)

View File

@ -1,4 +1,5 @@
# Copyright(c) 2019-2021 Intel Corporation
#
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -8,7 +9,7 @@ from ctypes import c_int
from random import randint
from pyocf.types.cache import Cache, CacheMode
from pyocf.types.core import Core
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.types.data import Data
from pyocf.types.io import IoDir
from pyocf.utils import Size as S
@ -19,13 +20,13 @@ from pyocf.types.shared import OcfError, OcfCompletion, CacheLineSize
@pytest.mark.parametrize("cls", CacheLineSize)
def test_adding_core(pyocf_ctx, cache_mode, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
# Check statistics before adding core
@ -44,13 +45,13 @@ def test_adding_core(pyocf_ctx, cache_mode, cls):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_removing_core(pyocf_ctx, cache_mode, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
# Add core to cache
@ -68,13 +69,13 @@ def test_removing_core(pyocf_ctx, cache_mode, cls):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_remove_dirty_no_flush(pyocf_ctx, cache_mode, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
cache.add_core(core)
@ -90,11 +91,11 @@ def test_remove_dirty_no_flush(pyocf_ctx, cache_mode, cls):
def test_30add_remove(pyocf_ctx):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
# Add and remove core device in a loop 100 times
@ -111,11 +112,11 @@ def test_30add_remove(pyocf_ctx):
def test_10add_remove_with_io(pyocf_ctx):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
# Add and remove core 10 times in a loop with io in between
@ -143,7 +144,7 @@ def test_10add_remove_with_io(pyocf_ctx):
def test_add_remove_30core(pyocf_ctx):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device)
core_devices = []
core_amount = 30
@ -152,7 +153,7 @@ def test_add_remove_30core(pyocf_ctx):
for i in range(0, core_amount):
stats = cache.get_stats()
assert stats["conf"]["core_count"] == i
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device, name=f"core{i}")
core_devices.append(core)
cache.add_core(core)
@ -176,13 +177,13 @@ def test_adding_to_random_cache(pyocf_ctx):
# Create 5 cache devices
for i in range(0, cache_amount):
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, name=f"cache{i}")
cache_devices.append(cache)
# Create 50 core devices and add to random cache
for i in range(0, core_amount):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device, name=f"core{i}")
core_devices[core] = randint(0, cache_amount - 1)
cache_devices[core_devices[core]].add_core(core)
@ -202,13 +203,13 @@ def test_adding_to_random_cache(pyocf_ctx):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_adding_core_twice(pyocf_ctx, cache_mode, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
# Add core
@ -227,19 +228,19 @@ def test_adding_core_twice(pyocf_ctx, cache_mode, cls):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_adding_core_already_used(pyocf_ctx, cache_mode, cls):
# Start first cache device
cache_device1 = Volume(S.from_MiB(50))
cache_device1 = RamVolume(S.from_MiB(50))
cache1 = Cache.start_on_device(
cache_device1, cache_mode=cache_mode, cache_line_size=cls, name="cache1"
)
# Start second cache device
cache_device2 = Volume(S.from_MiB(50))
cache_device2 = RamVolume(S.from_MiB(50))
cache2 = Cache.start_on_device(
cache_device2, cache_mode=cache_mode, cache_line_size=cls, name="cache2"
)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
# Add core to first cache
@ -261,7 +262,7 @@ def test_adding_core_already_used(pyocf_ctx, cache_mode, cls):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_add_remove_incrementally(pyocf_ctx, cache_mode, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
@ -270,7 +271,7 @@ def test_add_remove_incrementally(pyocf_ctx, cache_mode, cls):
# Create 5 core devices and add to cache
for i in range(0, core_amount):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device, name=f"core{i}")
core_devices.append(core)
cache.add_core(core)
@ -325,13 +326,13 @@ def test_try_add_core_with_changed_size(pyocf_ctx, cache_mode, cls):
:param cls: cache line size we start with
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
# Add core to cache
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
cache.add_core(core)
@ -359,13 +360,13 @@ def test_load_with_changed_core_size(pyocf_ctx, cache_mode, cls):
:param cls: cache line size we start with
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
# Add core to cache
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
cache.add_core(core)

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -27,7 +27,7 @@ from pyocf.types.shared import (
CacheLineSize,
SeqCutOffPolicy,
)
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.utils import Size
logger = logging.getLogger(__name__)
@ -43,8 +43,8 @@ def test_attach_different_size(
attach cache with different size and trigger IO. Verify if occupancy thresold is
respected with both original and new cache device.
"""
cache_device = Volume(Size.from_MiB(100))
core_device = Volume(Size.from_MiB(100))
cache_device = RamVolume(Size.from_MiB(100))
core_device = RamVolume(Size.from_MiB(100))
cache = Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)
core = Core.using_device(core_device)
cache.add_core(core)
@ -70,7 +70,7 @@ def test_attach_different_size(
assert part_current_size.blocks_4k == cache_size.blocks_4k * 0.5
cache.detach_device()
new_cache_device = Volume(Size.from_MiB(new_cache_size))
new_cache_device = RamVolume(Size.from_MiB(new_cache_size))
cache.attach_device(new_cache_device, force=True)
cache_size = cache.get_stats()["conf"]["size"]

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -7,7 +7,7 @@ import pytest
from pyocf.types.cache import Cache, CacheMode, CleaningPolicy, SeqCutOffPolicy
from pyocf.types.core import Core
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.utils import Size as S
from pyocf.types.shared import CacheLineSize
@ -17,7 +17,7 @@ from pyocf.types.shared import CacheLineSize
@pytest.mark.parametrize("cls", CacheLineSize)
def test_change_cache_mode(pyocf_ctx, from_cm, to_cm, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=from_cm, cache_line_size=cls
)
@ -32,7 +32,7 @@ def test_change_cache_mode(pyocf_ctx, from_cm, to_cm, cls):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_change_cleaning_policy(pyocf_ctx, cm, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cm, cache_line_size=cls
)
@ -57,15 +57,15 @@ def test_change_cleaning_policy(pyocf_ctx, cm, cls):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_cache_change_seq_cut_off_policy(pyocf_ctx, cm, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cm, cache_line_size=cls
)
# Create 2 core devices
core_device1 = Volume(S.from_MiB(10))
core_device1 = RamVolume(S.from_MiB(10))
core1 = Core.using_device(core_device1, name="core1")
core_device2 = Volume(S.from_MiB(10))
core_device2 = RamVolume(S.from_MiB(10))
core2 = Core.using_device(core_device2, name="core2")
# Add cores
@ -96,15 +96,15 @@ def test_cache_change_seq_cut_off_policy(pyocf_ctx, cm, cls):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_core_change_seq_cut_off_policy(pyocf_ctx, cm, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cm, cache_line_size=cls
)
# Create 2 core devices
core_device1 = Volume(S.from_MiB(10))
core_device1 = RamVolume(S.from_MiB(10))
core1 = Core.using_device(core_device1, name="core1")
core_device2 = Volume(S.from_MiB(10))
core_device2 = RamVolume(S.from_MiB(10))
core2 = Core.using_device(core_device2, name="core2")
# Add cores

View File

@ -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 Volume
from pyocf.types.volume import RamVolume
from pyocf.utils import Size
logger = logging.getLogger(__name__)
@ -34,8 +34,8 @@ def test_start_check_default(pyocf_ctx):
"""Test if default values are correct after start.
"""
cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(10))
cache_device = RamVolume(Size.from_MiB(50))
core_device = RamVolume(Size.from_MiB(10))
cache = Cache.start_on_device(cache_device)
core = Core.using_device(core_device)
@ -58,8 +58,8 @@ def test_start_write_first_and_check_mode(pyocf_ctx, mode: CacheMode, cls: Cache
After start check proper cache mode behaviour, starting with write operation.
"""
cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(10))
cache_device = RamVolume(Size.from_MiB(50))
core_device = RamVolume(Size.from_MiB(10))
cache = Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)
core_exported = Core.using_device(core_device)
@ -96,8 +96,8 @@ def test_start_read_first_and_check_mode(pyocf_ctx, mode: CacheMode, cls: CacheL
After start check proper cache mode behaviour, starting with read operation.
"""
cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(5))
cache_device = RamVolume(Size.from_MiB(50))
core_device = RamVolume(Size.from_MiB(5))
cache = Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)
core_exported = Core.using_device(core_device)
@ -139,7 +139,7 @@ def test_start_params(pyocf_ctx, mode: CacheMode, cls: CacheLineSize, layout: Me
Check if cache starts without errors.
If possible check whether cache reports properly set parameters.
"""
cache_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
queue_size = randrange(60000, 2**32)
unblock_size = randrange(1, queue_size)
volatile_metadata = randrange(2) == 1
@ -176,8 +176,8 @@ def test_stop(pyocf_ctx, mode: CacheMode, cls: CacheLineSize, with_flush: bool):
Check if cache is stopped properly in different modes with or without preceding flush operation.
"""
cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(5))
cache_device = RamVolume(Size.from_MiB(50))
core_device = RamVolume(Size.from_MiB(5))
cache = Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)
core_exported = Core.using_device(core_device)
cache.add_core(core_exported)
@ -211,7 +211,7 @@ def test_start_stop_multiple(pyocf_ctx):
caches = []
caches_no = randrange(6, 11)
for i in range(1, caches_no):
cache_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
cache_name = f"cache{i}"
cache_mode = CacheMode(randrange(0, len(CacheMode)))
size = 4096 * 2**randrange(0, len(CacheLineSize))
@ -243,7 +243,7 @@ def test_100_start_stop(pyocf_ctx):
"""
for i in range(1, 101):
cache_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
cache_name = f"cache{i}"
cache_mode = CacheMode(randrange(0, len(CacheMode)))
size = 4096 * 2**randrange(0, len(CacheLineSize))
@ -278,7 +278,7 @@ def test_start_stop_incrementally(pyocf_ctx):
while run:
if add:
for i in range(0, randrange(3, 5) if increase else randrange(1, 3)):
cache_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
cache_name = f"cache{next(counter)}"
cache_mode = CacheMode(randrange(0, len(CacheMode)))
size = 4096 * 2**randrange(0, len(CacheLineSize))
@ -318,8 +318,8 @@ def test_start_cache_same_id(pyocf_ctx, mode, cls):
Check that OCF does not allow for 2 caches to be started with the same cache_name
"""
cache_device1 = Volume(Size.from_MiB(50))
cache_device2 = Volume(Size.from_MiB(50))
cache_device1 = RamVolume(Size.from_MiB(50))
cache_device2 = RamVolume(Size.from_MiB(50))
cache_name = "cache"
cache = Cache.start_on_device(cache_device1,
cache_mode=mode,
@ -342,7 +342,7 @@ 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(Volume):
class HugeDevice(RamVolume):
def get_length(self):
return Size.from_B((cls * c_uint32(-1).value))
@ -367,7 +367,7 @@ def test_start_cache_same_device(pyocf_ctx, mode, cls):
Check that OCF does not allow for 2 caches using the same cache device to be started
"""
cache_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=mode, cache_line_size=cls, name="cache1"
)
@ -387,7 +387,7 @@ def test_start_too_small_device(pyocf_ctx, mode, cls):
Check if starting cache with device below minimum size is blocked
"""
cache_device = Volume(Size.from_B(20 * 1024 * 1024 - 1))
cache_device = RamVolume(Size.from_B(20 * 1024 * 1024 - 1))
with pytest.raises(OcfError, match="OCF_ERR_INVAL_CACHE_DEV"):
Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -18,7 +18,7 @@ from pyocf.types.cache import (
ConfValidValues,
)
from pyocf.types.core import Core
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.utils import Size as S
from tests.utils.random import (
Range,
@ -41,7 +41,7 @@ def test_neg_change_cache_mode(pyocf_ctx, cm, cls):
:param cls: cache line size we start with
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Change cache mode to invalid one and check if failed
@ -65,7 +65,7 @@ def test_neg_set_cleaning_policy(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Set cleaning policy to invalid one and check if failed
@ -90,7 +90,7 @@ def test_neg_attach_cls(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache(owner=cache_device.owner, cache_mode=cm, cache_line_size=cls)
cache.start_cache()
@ -115,13 +115,13 @@ def test_neg_cache_set_seq_cut_off_policy(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Create 2 core devices
core_device1 = Volume(S.from_MiB(10))
core_device1 = RamVolume(S.from_MiB(10))
core1 = Core.using_device(core_device1, name="core1")
core_device2 = Volume(S.from_MiB(10))
core_device2 = RamVolume(S.from_MiB(10))
core2 = Core.using_device(core_device2, name="core2")
# Add cores
@ -149,13 +149,13 @@ def test_neg_cache_set_seq_cut_off_promotion(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Create 2 core devices
core_device1 = Volume(S.from_MiB(10))
core_device1 = RamVolume(S.from_MiB(10))
core1 = Core.using_device(core_device1, name="core1")
core_device2 = Volume(S.from_MiB(10))
core_device2 = RamVolume(S.from_MiB(10))
core2 = Core.using_device(core_device2, name="core2")
# Add cores
@ -185,11 +185,11 @@ def test_neg_core_set_seq_cut_off_promotion(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Create core device
core_device1 = Volume(S.from_MiB(10))
core_device1 = RamVolume(S.from_MiB(10))
core1 = Core.using_device(core_device1, name="core1")
# Add core
@ -218,13 +218,13 @@ def test_neg_cache_set_seq_cut_off_threshold(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Create 2 core devices
core_device1 = Volume(S.from_MiB(10))
core_device1 = RamVolume(S.from_MiB(10))
core1 = Core.using_device(core_device1, name="core1")
core_device2 = Volume(S.from_MiB(10))
core_device2 = RamVolume(S.from_MiB(10))
core2 = Core.using_device(core_device2, name="core2")
# Add cores
@ -254,11 +254,11 @@ def test_neg_core_set_seq_cut_off_threshold(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device, name="core")
# Add core
@ -287,11 +287,11 @@ def test_neg_core_set_seq_cut_off_policy(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
# Add core
@ -318,7 +318,7 @@ def test_neg_set_alru_param(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Change invalid alru param and check if failed
@ -355,7 +355,7 @@ def test_neg_set_alru_param_value(pyocf_ctx, cm, cls, param):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
cache.set_cleaning_policy(CleaningPolicy.ALRU)
@ -382,7 +382,7 @@ def test_neg_set_acp_param(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Change invalid acp param and check if failed
@ -415,7 +415,7 @@ def test_neg_set_acp_param_value(pyocf_ctx, cm, cls, param):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
cache.set_cleaning_policy(CleaningPolicy.ACP)
@ -442,7 +442,7 @@ def test_neg_set_promotion_policy(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Change to invalid promotion policy and check if failed
@ -466,7 +466,7 @@ def test_neg_set_nhit_promotion_policy_param(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device,
cache_mode=cm,
@ -496,7 +496,7 @@ def test_neg_set_nhit_promotion_policy_param_trigger(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device,
cache_mode=cm,
@ -528,7 +528,7 @@ def test_neg_set_nhit_promotion_policy_param_threshold(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device,
cache_mode=cm,
@ -559,7 +559,7 @@ def test_neg_set_ioclass_max_size(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Set invalid max size and check if failed
@ -589,7 +589,7 @@ def test_neg_set_ioclass_priority(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Set invalid priority and check if failed
@ -619,7 +619,7 @@ def test_neg_set_ioclass_cache_mode(pyocf_ctx, cm, cls):
:return:
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Set invalid cache mode and check if failed
@ -644,7 +644,7 @@ def test_neg_set_ioclass_name(pyocf_ctx):
invalid_chars += [",", '"']
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=CacheMode.WT, cache_line_size=CacheLineSize.LINE_4KiB
)
@ -669,7 +669,7 @@ def test_neg_set_ioclass_name_len(pyocf_ctx):
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=CacheMode.WT, cache_line_size=CacheLineSize.LINE_4KiB
)

View File

@ -9,7 +9,7 @@ import pytest
from pyocf.types.cache import Cache, CacheMode, MetadataLayout, PromotionPolicy
from pyocf.types.shared import OcfError, CacheLineSize
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.utils import Size
from tests.utils.random import RandomGenerator, DefaultRanges, Range
@ -17,7 +17,7 @@ logger = logging.getLogger(__name__)
def try_start_cache(**config):
cache_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
cache = Cache.start_on_device(cache_device, **config)
cache.stop()
@ -58,7 +58,7 @@ def test_fuzzy_start_name(pyocf_ctx, string_randomize, cm, cls):
:param cm: cache mode value to start cache with
:param cls: cache line size value to start cache with
"""
cache_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
incorrect_values = ['']
try:
cache = Cache.start_on_device(cache_device, name=string_randomize, cache_mode=cm,

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -12,7 +12,7 @@ from pyocf.types.cache import Cache, Core
from pyocf.types.data import Data
from pyocf.types.io import IoDir
from pyocf.types.shared import OcfCompletion
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.utils import Size
@ -183,8 +183,8 @@ def test_neg_io_direction(pyocf_ctx, c_int_randomize):
def prepare_cache_and_core(core_size: Size, cache_size: Size = Size.from_MiB(50)):
cache_device = Volume(cache_size)
core_device = Volume(core_size)
cache_device = RamVolume(cache_size)
core_device = RamVolume(core_size)
cache = Cache.start_on_device(cache_device)
core = Core.using_device(core_device)

View File

@ -1,5 +1,5 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -8,7 +8,7 @@ from ctypes import c_int
from pyocf.types.cache import Cache, CacheMode
from pyocf.types.core import Core
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.utils import Size as S
from pyocf.types.data import Data, DataOps
from pyocf.types.ctx import OcfCtx
@ -75,12 +75,12 @@ def test_secure_erase_simple_io_read_misses(cache_mode):
Cleaner,
)
ctx.register_volume_type(Volume)
ctx.register_volume_type(RamVolume)
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cache_mode)
core_device = Volume(S.from_MiB(50))
core_device = RamVolume(S.from_MiB(50))
core = Core.using_device(core_device)
cache.add_core(core)
@ -168,12 +168,12 @@ def test_secure_erase_simple_io_cleaning():
Cleaner,
)
ctx.register_volume_type(Volume)
ctx.register_volume_type(RamVolume)
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=CacheMode.WB)
core_device = Volume(S.from_MiB(100))
core_device = RamVolume(S.from_MiB(100))
core = Core.using_device(core_device)
cache.add_core(core)

View File

@ -17,7 +17,7 @@ from pyocf.types.cache import (
)
from pyocf.types.data import Data
from pyocf.types.core import Core
from pyocf.types.volume import ErrorDevice, Volume, VOLUME_POISON
from pyocf.types.volume import ErrorDevice, RamVolume, VOLUME_POISON
from pyocf.types.io import IoDir
from pyocf.types.ioclass import IoClassesInfo, IoClassInfo
from pyocf.utils import Size as S
@ -118,7 +118,7 @@ def mngmt_op_surprise_shutdown_test(
# power failure during core insert
@pytest.mark.security
def test_surprise_shutdown_add_core(pyocf_ctx):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
def check_core(cache, error_triggered):
stats = cache.get_stats()
@ -138,7 +138,7 @@ def test_surprise_shutdown_add_core(pyocf_ctx):
@pytest.mark.security
@pytest.mark.long
def test_surprise_shutdown_remove_core(pyocf_ctx):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
def prepare_func(cache):
@ -158,7 +158,7 @@ def test_surprise_shutdown_remove_core(pyocf_ctx):
@pytest.mark.long
def test_surprise_shutdown_remove_core_with_data(pyocf_ctx):
io_offset = mngmt_op_surprise_shutdown_test_io_offset
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device, name="core1")
def prepare_func(cache):
@ -184,8 +184,8 @@ def test_surprise_shutdown_remove_core_with_data(pyocf_ctx):
@pytest.mark.security
@pytest.mark.long
def test_surprise_shutdown_swap_core(pyocf_ctx):
core_device_1 = Volume(S.from_MiB(10), uuid="dev1")
core_device_2 = Volume(S.from_MiB(10), uuid="dev2")
core_device_1 = RamVolume(S.from_MiB(10), uuid="dev1")
core_device_2 = RamVolume(S.from_MiB(10), uuid="dev2")
core1 = Core.using_device(core_device_1, name="core1")
core2 = Core.using_device(core_device_2, name="core2")
@ -219,8 +219,8 @@ def test_surprise_shutdown_swap_core(pyocf_ctx):
@pytest.mark.security
@pytest.mark.long
def test_surprise_shutdown_swap_core_with_data(pyocf_ctx):
core_device_1 = Volume(S.from_MiB(10), uuid="dev1")
core_device_2 = Volume(S.from_MiB(10), uuid="dev2")
core_device_1 = RamVolume(S.from_MiB(10), uuid="dev1")
core_device_2 = RamVolume(S.from_MiB(10), uuid="dev2")
core1 = Core.using_device(core_device_1, name="core1")
core2 = Core.using_device(core_device_2, name="core2")
@ -312,7 +312,7 @@ def test_surprise_shutdown_start_cache(pyocf_ctx):
@pytest.mark.security
@pytest.mark.long
def test_surprise_shutdown_stop_cache(pyocf_ctx):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
error_triggered = True
error_io_seq_no = 0
io_offset = mngmt_op_surprise_shutdown_test_io_offset
@ -371,7 +371,7 @@ def test_surprise_shutdown_stop_cache(pyocf_ctx):
@pytest.mark.security
def test_surprise_shutdown_cache_reinit(pyocf_ctx):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
error_io = {IoDir.WRITE: 0}
@ -440,7 +440,7 @@ def test_surprise_shutdown_cache_reinit(pyocf_ctx):
def _test_surprise_shutdown_mngmt_generic(pyocf_ctx, func):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core(device=core_device)
def prepare(cache):
@ -464,7 +464,7 @@ def test_surprise_shutdown_change_cache_mode(pyocf_ctx):
@pytest.mark.security
@pytest.mark.long
def test_surprise_shutdown_set_cleaning_policy(pyocf_ctx):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core(device=core_device)
for c1 in CleaningPolicy:
@ -485,7 +485,7 @@ def test_surprise_shutdown_set_cleaning_policy(pyocf_ctx):
@pytest.mark.security
@pytest.mark.long
def test_surprise_shutdown_set_seq_cut_off_policy(pyocf_ctx):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core(device=core_device)
for s1 in SeqCutOffPolicy:
@ -522,7 +522,7 @@ def test_surprise_shutdown_set_seq_cut_off_threshold(pyocf_ctx):
@pytest.mark.security
@pytest.mark.long
def test_surprise_shutdown_set_cleaning_policy_param(pyocf_ctx):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core(device=core_device)
for pol in CleaningPolicy:
@ -574,7 +574,7 @@ def test_surprise_shutdown_set_cleaning_policy_param(pyocf_ctx):
@pytest.mark.security
@pytest.mark.long
def test_surprise_shutdown_set_promotion_policy(pyocf_ctx):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core(device=core_device)
for pp1 in PromotionPolicy:
@ -595,7 +595,7 @@ def test_surprise_shutdown_set_promotion_policy(pyocf_ctx):
@pytest.mark.security
@pytest.mark.long
def test_surprise_shutdown_set_promotion_policy_param(pyocf_ctx):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core(device=core_device)
for pp in PromotionPolicy:
@ -633,7 +633,7 @@ def test_surprise_shutdown_set_promotion_policy_param(pyocf_ctx):
@pytest.mark.security
@pytest.mark.long
def test_surprise_shutdown_set_io_class_config(pyocf_ctx):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core(device=core_device)
class_range = range(0, IoClassesInfo.MAX_IO_CLASSES)