pyocf: Test detaching cache with cleaning policy

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
Michal Mielewczyk 2025-03-14 13:36:23 +01:00
parent 69987bd20c
commit 98a3aaea89

View File

@ -11,6 +11,7 @@ import pytest
from pyocf.types.cache import ( from pyocf.types.cache import (
Cache, Cache,
CacheMode, CacheMode,
CleaningPolicy,
) )
from pyocf.types.core import Core from pyocf.types.core import Core
from pyocf.types.data import Data from pyocf.types.data import Data
@ -67,6 +68,23 @@ def test_detach_cache_twice(pyocf_ctx):
cache.stop() cache.stop()
@pytest.mark.parametrize("cleaning_policy", CleaningPolicy)
def test_detach_cache_with_cleaning(pyocf_ctx, cleaning_policy):
cache_device = RamVolume(Size.from_MiB(100))
core_device = RamVolume(Size.from_MiB(100))
cache = Cache.start_on_device(cache_device)
core = Core.using_device(core_device)
cache.add_core(core)
cache.set_cleaning_policy(cleaning_policy)
cache.detach_device()
cache.stop()
def test_detach_cache_zero_superblock(pyocf_ctx): def test_detach_cache_zero_superblock(pyocf_ctx):
"""Check if superblock is zeroed after detach and the cache device can be reattached without """Check if superblock is zeroed after detach and the cache device can be reattached without
--force option. --force option.