diff --git a/tests/functional/tests/management/test_attach_cache.py b/tests/functional/tests/management/test_attach_cache.py index 42d026f..4f294c0 100644 --- a/tests/functional/tests/management/test_attach_cache.py +++ b/tests/functional/tests/management/test_attach_cache.py @@ -27,6 +27,7 @@ from pyocf.types.shared import ( CacheLines, CacheLineSize, SeqCutOffPolicy, + OcfError, ) from pyocf.types.volume import RamVolume from pyocf.types.volume_core import CoreVolume @@ -47,6 +48,21 @@ def test_add_remove_core_detached_cache(pyocf_ctx): cache.stop() +def test_attach_cache_twice(pyocf_ctx): + cache_device_1 = RamVolume(Size.from_MiB(50)) + cache_device_2 = RamVolume(Size.from_MiB(50)) + + cache = Cache(owner=pyocf_ctx) + cache.start_cache() + + cache.attach_device(cache_device_1) + + with pytest.raises(OcfError, match="Attaching cache device failed"): + cache.attach_device(cache_device_2) + + cache.stop() + + @pytest.mark.parametrize("cls", CacheLineSize) @pytest.mark.parametrize("mode", [CacheMode.WB, CacheMode.WT, CacheMode.WO]) @pytest.mark.parametrize("new_cache_size", [80, 120])