From 641649f6a9323f97319c58c84c59e7df9781b1d0 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Wed, 22 Jun 2022 16:32:35 +0200 Subject: [PATCH 1/2] pyocf: Refactor _cvol_io() function Signed-off-by: Piotr Debski Signed-off-by: Robert Baldyga --- tests/functional/tests/management/test_composite_volume.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/functional/tests/management/test_composite_volume.py b/tests/functional/tests/management/test_composite_volume.py index 19ee523..f9d9a7a 100644 --- a/tests/functional/tests/management/test_composite_volume.py +++ b/tests/functional/tests/management/test_composite_volume.py @@ -100,7 +100,12 @@ def test_add_max_subvolumes(pyocf_ctx): def _cvol_io(cvol, addr, size, func, flags=0): io = cvol.new_io( - queue=None, addr=addr, length=size, direction=IoDir.WRITE, io_class=0, flags=flags, + queue=None, + addr=addr, + length=size, + direction=IoDir.WRITE, + io_class=0, + flags=flags, ) completion = OcfCompletion([("err", c_int)]) io.callback = completion.callback From f4eb291235e34a57a54d6a85c4e20b8370ecc94f Mon Sep 17 00:00:00 2001 From: Piotr Debski Date: Tue, 14 Jun 2022 12:06:53 +0200 Subject: [PATCH 2/2] pyocf: Composite volume tests Signed-off-by: Piotr Debski Signed-off-by: Robert Baldyga --- .../tests/management/test_composite_volume.py | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/tests/functional/tests/management/test_composite_volume.py b/tests/functional/tests/management/test_composite_volume.py index f9d9a7a..6a10f0a 100644 --- a/tests/functional/tests/management/test_composite_volume.py +++ b/tests/functional/tests/management/test_composite_volume.py @@ -11,6 +11,7 @@ from pyocf.types.cvolume import CVolume from pyocf.types.data import Data from pyocf.types.io import IoDir from pyocf.types.shared import OcfError, OcfCompletion +from pyocf.types.cache import Cache from pyocf.utils import Size as S @@ -323,7 +324,6 @@ def test_io_completion(pyocf_ctx): pass -@pytest.mark.skip(reason="not implemented") def test_attach(pyocf_ctx): """ title: Attach composite volume. @@ -343,10 +343,22 @@ def test_attach(pyocf_ctx): requirements: - 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): """ title: Load composite volume. @@ -368,4 +380,25 @@ def test_load(pyocf_ctx): requirements: - 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"