pyocf: test update to handle zeroed metadata in attach

With atomic superblock commit during cache attach, it is possible
that power failure interrupts attach operation at a point where
neither new or old superblock is present - right after the superblock
is cleared.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski 2021-12-23 14:36:48 +01:00
parent 366d89a9c4
commit ae240f5aa8

View File

@ -427,14 +427,23 @@ def test_surprise_shutdown_cache_reinit(pyocf_ctx):
device.disarm() device.disarm()
cache = Cache.load_from_device(device) cache = None
status = OcfErrorCode.OCF_OK
try:
cache = Cache.load_from_device(device)
except OcfError as ex:
status = ex.error_code
stats = cache.get_stats() if not cache:
if stats["conf"]["core_count"] == 0: assert status == OcfErrorCode.OCF_ERR_NO_METADATA
cache.add_core(core) else:
assert ocf_read(cache, core, io_offset) == Volume.VOLUME_POISON stats = cache.get_stats()
if stats["conf"]["core_count"] == 0:
assert stats["usage"]["occupancy"]["value"] == 0
cache.add_core(core)
assert ocf_read(cache, core, io_offset) == Volume.VOLUME_POISON
cache.stop() cache.stop()
error_io[IoDir.WRITE] += 1 error_io[IoDir.WRITE] += 1