From 63c71ec6dff899e995b988ab801a65d29cd0351d Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Wed, 28 Aug 2019 14:46:56 -0400 Subject: [PATCH] pytest: basic cache recovery test Signed-off-by: Adam Rutkowski --- tests/functional/pyocf/types/volume.py | 5 +++++ tests/functional/tests/basic/test_pyocf.py | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/tests/functional/pyocf/types/volume.py b/tests/functional/pyocf/types/volume.py index 9fbf063..4bca10b 100644 --- a/tests/functional/pyocf/types/volume.py +++ b/tests/functional/pyocf/types/volume.py @@ -104,6 +104,11 @@ class Volume(Structure): self.reset_stats() self.opened = False + def get_copy(self): + new_volume = Volume(self.size) + memmove(new_volume.data, self.data, self.size) + return new_volume + @classmethod def get_props(cls): if not cls.props: diff --git a/tests/functional/tests/basic/test_pyocf.py b/tests/functional/tests/basic/test_pyocf.py index c012d85..b881abd 100644 --- a/tests/functional/tests/basic/test_pyocf.py +++ b/tests/functional/tests/basic/test_pyocf.py @@ -72,3 +72,15 @@ def test_load_cache(pyocf_ctx): cache.stop() 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)