pytest: basic cache recovery test

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski 2019-08-28 14:46:56 -04:00
parent 358c529eff
commit 63c71ec6df
2 changed files with 17 additions and 0 deletions

View File

@ -104,6 +104,11 @@ class Volume(Structure):
self.reset_stats() self.reset_stats()
self.opened = False self.opened = False
def get_copy(self):
new_volume = Volume(self.size)
memmove(new_volume.data, self.data, self.size)
return new_volume
@classmethod @classmethod
def get_props(cls): def get_props(cls):
if not cls.props: if not cls.props:

View File

@ -72,3 +72,15 @@ def test_load_cache(pyocf_ctx):
cache.stop() cache.stop()
cache = Cache.load_from_device(cache_device) cache = Cache.load_from_device(cache_device)
def test_load_cache_recovery(pyocf_ctx):
cache_device = Volume(S.from_MiB(30))
cache = Cache.start_on_device(cache_device)
device_copy = cache_device.get_copy()
cache.stop()
cache = Cache.load_from_device(device_copy)