fix for issue #1023
Better error for core size mismatch during activation/load adding pyocf test for new error code Signed-off-by: Piotr Debski <piotr.debski@intel.com>
This commit is contained in:
@@ -53,6 +53,7 @@ class OcfErrorCode(IntEnum):
|
||||
OCF_ERR_METADATA_LAYOUT_MISMATCH = auto()
|
||||
OCF_ERR_CACHE_LINE_SIZE_MISMATCH = auto()
|
||||
OCF_ERR_CACHE_STANDBY = auto()
|
||||
OCF_ERR_CORE_SIZE_MISMATCH = auto()
|
||||
OCF_ERR_STANDBY_ATTACHED = auto()
|
||||
|
||||
|
||||
|
@@ -256,6 +256,12 @@ class Volume(Structure):
|
||||
def get_length(self):
|
||||
return self.size
|
||||
|
||||
def resize(self, size):
|
||||
self.size = size
|
||||
self.data = create_string_buffer(int(self.size))
|
||||
memset(self.data, self.VOLUME_POISON, self.size)
|
||||
self._storage = cast(self.data, c_void_p)
|
||||
|
||||
def get_max_io_size(self):
|
||||
return S.from_KiB(128)
|
||||
|
||||
|
@@ -313,3 +313,69 @@ def _io_to_core(exported_obj: Core, data: Data):
|
||||
completion.wait()
|
||||
|
||||
assert completion.results["err"] == 0, "IO to exported object completion"
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
@pytest.mark.parametrize("cache_mode", CacheMode)
|
||||
@pytest.mark.parametrize("cls", CacheLineSize)
|
||||
def test_try_add_with_changed_core_size(pyocf_ctx, cache_mode, cls):
|
||||
"""
|
||||
Test changing volume size before load
|
||||
:param pyocf_ctx: basic pyocf context fixture
|
||||
:param cm: cache mode we start with
|
||||
:param cls: cache line size we start with
|
||||
"""
|
||||
# Start cache device
|
||||
cache_device = Volume(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 = Core.using_device(core_device)
|
||||
cache.add_core(core)
|
||||
|
||||
# Stop cache
|
||||
cache.stop()
|
||||
|
||||
# Change core device size
|
||||
core_device.resize(S.from_MiB(12))
|
||||
|
||||
# Load cache with changed core size
|
||||
cache = Cache.load_from_device(cache_device, open_cores=False)
|
||||
core = Core(device=core_device, try_add=True)
|
||||
|
||||
with pytest.raises(OcfError, match="OCF_ERR_CORE_SIZE_MISMATCH"):
|
||||
cache.add_core(core)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cache_mode", CacheMode)
|
||||
@pytest.mark.parametrize("cls", CacheLineSize)
|
||||
def test_load_with_changed_core_size(pyocf_ctx, cache_mode, cls):
|
||||
"""
|
||||
Test changing volume size before load
|
||||
:param pyocf_ctx: basic pyocf context fixture
|
||||
:param cm: cache mode we start with
|
||||
:param cls: cache line size we start with
|
||||
"""
|
||||
# Start cache device
|
||||
cache_device = Volume(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 = Core.using_device(core_device)
|
||||
cache.add_core(core)
|
||||
|
||||
# Stop cache
|
||||
cache.stop()
|
||||
|
||||
# Change core device size
|
||||
core_device.resize(S.from_MiB(12))
|
||||
|
||||
# Load cache with changed core size
|
||||
with pytest.raises(OcfError, match="OCF_ERR_CORE_SIZE_MISMATCH"):
|
||||
cache = Cache.load_from_device(cache_device)
|
||||
|
Reference in New Issue
Block a user