pyocf: Composite volume tests

Signed-off-by: Piotr Debski <piotr.debski@intel.com>
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Piotr Debski 2022-06-14 12:06:53 +02:00 committed by Robert Baldyga
parent 641649f6a9
commit f4eb291235

View File

@ -11,6 +11,7 @@ from pyocf.types.cvolume import CVolume
from pyocf.types.data import Data from pyocf.types.data import Data
from pyocf.types.io import IoDir from pyocf.types.io import IoDir
from pyocf.types.shared import OcfError, OcfCompletion from pyocf.types.shared import OcfError, OcfCompletion
from pyocf.types.cache import Cache
from pyocf.utils import Size as S from pyocf.utils import Size as S
@ -323,7 +324,6 @@ def test_io_completion(pyocf_ctx):
pass pass
@pytest.mark.skip(reason="not implemented")
def test_attach(pyocf_ctx): def test_attach(pyocf_ctx):
""" """
title: Attach composite volume. title: Attach composite volume.
@ -343,10 +343,22 @@ def test_attach(pyocf_ctx):
requirements: requirements:
- composite_volume::cache_attach_load - composite_volume::cache_attach_load
""" """
pass
vols = [RamVolume(S.from_MiB(3)) for _ in range(16)]
cvol = CVolume(pyocf_ctx)
for vol in vols:
cvol.add(vol)
cache = Cache.start_on_device(cvol, name="cache1")
stats = cache.get_stats()
assert stats["conf"]["attached"] is True, "checking whether cache is attached properly"
assert stats["conf"]["volume_type"] == CVolume
cache.stop()
assert Cache.get_by_name("cache1", pyocf_ctx) != 0, "Try getting cache after stopping it"
@pytest.mark.skip(reason="not implemented")
def test_load(pyocf_ctx): def test_load(pyocf_ctx):
""" """
title: Load composite volume. title: Load composite volume.
@ -368,4 +380,25 @@ def test_load(pyocf_ctx):
requirements: requirements:
- composite_volume::cache_attach_load - composite_volume::cache_attach_load
""" """
pass vols = [RamVolume(S.from_MiB(3)) for _ in range(16)]
cvol = CVolume(pyocf_ctx)
for vol in vols:
cvol.add(vol)
cache = Cache.start_on_device(cvol, name="cache1")
cache.stop()
cvol = CVolume(pyocf_ctx)
for v in vols:
cvol.add(v)
cache = Cache.load_from_device(cvol, name="cache1", open_cores=False)
stats = cache.get_stats()
assert stats["conf"]["attached"] is True, "checking whether cache is attached properly"
assert stats["conf"]["volume_type"] == CVolume
cache.stop()
assert Cache.get_by_name("cache1", pyocf_ctx) != 0, "Try getting cache after stopping it"