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.
@@ -427,10 +427,19 @@ def test_surprise_shutdown_cache_reinit(pyocf_ctx):
device.disarm()
+ cache = None
+ status = OcfErrorCode.OCF_OK
+ try:
cache = Cache.load_from_device(device)
+ except OcfError as ex:
+ status = ex.error_code
+ if not cache:
+ assert status == OcfErrorCode.OCF_ERR_NO_METADATA
+ else:
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
