Merge pull request #736 from pdebski21/tests_disable_cleaner2
Tests disable cleaner
This commit is contained in:
@@ -4,9 +4,14 @@
|
||||
#
|
||||
|
||||
import pytest
|
||||
from pyocf.types.volume import RamVolume
|
||||
from pyocf.types.cache import Cache, CacheMetadataSegment
|
||||
from pyocf.types.core import Core
|
||||
from pyocf.types.shared import OcfError, OcfCompletion
|
||||
from pyocf.utils import Size as S
|
||||
from pyocf.helpers import get_metadata_segment_size
|
||||
from ctypes import c_int
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="not implemented")
|
||||
def test_attach_cleaner_disabled(pyocf_ctx):
|
||||
"""
|
||||
title: Attach cache with cleaner_disabled option set.
|
||||
@@ -29,10 +34,24 @@ def test_attach_cleaner_disabled(pyocf_ctx):
|
||||
- disable_cleaner::set_cleaner_disabled
|
||||
- disable_cleaner::cleaning_section_alocation
|
||||
"""
|
||||
pass
|
||||
cache_device = RamVolume(S.from_MiB(50))
|
||||
core_device = RamVolume(S.from_MiB(10))
|
||||
|
||||
cache = Cache.start_on_device(cache_device, disable_cleaner=True)
|
||||
core = Core.using_device(core_device)
|
||||
|
||||
stats = cache.get_stats()
|
||||
assert stats["conf"]["attached"] is True, "checking whether cache is attached properly"
|
||||
|
||||
cleaning_size = get_metadata_segment_size(cache, CacheMetadataSegment.CLEANING)
|
||||
assert (
|
||||
cleaning_size == 0
|
||||
), f'Metadata cleaning segment size expected: "0", got: "{cleaning_size}"'
|
||||
|
||||
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_cleaner_disabled(pyocf_ctx):
|
||||
"""
|
||||
title: Load cache in cleaner_disabled mode.
|
||||
@@ -57,7 +76,31 @@ def test_load_cleaner_disabled(pyocf_ctx):
|
||||
- disable_cleaner::load_cleaner_disabled
|
||||
- disable_cleaner::cleaning_section_alocation
|
||||
"""
|
||||
pass
|
||||
cache_device = RamVolume(S.from_MiB(50))
|
||||
core_device = RamVolume(S.from_MiB(10))
|
||||
|
||||
cache = Cache.start_on_device(cache_device, disable_cleaner=True)
|
||||
core = Core.using_device(core_device)
|
||||
|
||||
cache.add_core(core)
|
||||
|
||||
cache.stop()
|
||||
|
||||
cache = Cache.load_from_device(cache_device, open_cores=False, disable_cleaner=True)
|
||||
|
||||
cache.add_core(core, try_add=True)
|
||||
|
||||
stats = cache.get_stats()
|
||||
assert stats["conf"]["attached"] is True, "checking whether cache is attached properly"
|
||||
|
||||
cleaning_size = get_metadata_segment_size(cache, CacheMetadataSegment.CLEANING)
|
||||
assert (
|
||||
cleaning_size == 0
|
||||
), f'Metadata cleaning segment size expected: "0", got: "{cleaning_size}"'
|
||||
|
||||
cache.stop()
|
||||
assert Cache.get_by_name("cache1", pyocf_ctx) != 0, "Try getting cache after stopping it"
|
||||
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="not implemented")
|
||||
|
||||
@@ -265,7 +265,7 @@ def test_start_stop_multiple(pyocf_ctx):
|
||||
stats = cache.get_stats()
|
||||
cache_name = stats["conf"]["cache_name"]
|
||||
cache.stop()
|
||||
assert get_cache_by_name(pyocf_ctx, cache_name) != 0, "Try getting cache after stopping it"
|
||||
assert Cache.get_by_name(cache_name, pyocf_ctx) != 0, "Try getting cache after stopping it"
|
||||
|
||||
|
||||
def test_100_start_stop(pyocf_ctx):
|
||||
@@ -288,7 +288,7 @@ def test_100_start_stop(pyocf_ctx):
|
||||
assert stats["conf"]["cache_line_size"] == cache_line_size, "Cache line size"
|
||||
assert stats["conf"]["cache_name"] == cache_name, "Cache name"
|
||||
cache.stop()
|
||||
assert get_cache_by_name(pyocf_ctx, "cache1") != 0, "Try getting cache after stopping it"
|
||||
assert Cache.get_by_name("cache1", pyocf_ctx) != 0, "Try getting cache after stopping it"
|
||||
|
||||
|
||||
def test_start_stop_incrementally(pyocf_ctx):
|
||||
@@ -337,7 +337,7 @@ def test_start_stop_incrementally(pyocf_ctx):
|
||||
cache_name = stats["conf"]["cache_name"]
|
||||
cache.stop()
|
||||
assert (
|
||||
get_cache_by_name(pyocf_ctx, cache_name) != 0
|
||||
Cache.get_by_name(cache_name, pyocf_ctx) != 0
|
||||
), "Try getting cache after stopping it"
|
||||
add = not add
|
||||
|
||||
@@ -648,9 +648,3 @@ def check_md5_sums(core: Core, mode: CacheMode):
|
||||
core.device.md5() == core.get_front_volume().md5()
|
||||
), "MD5 check: core device vs exported object"
|
||||
|
||||
|
||||
def get_cache_by_name(ctx, cache_name):
|
||||
cache_pointer = c_void_p()
|
||||
return OcfLib.getInstance().ocf_mngt_cache_get_by_name(
|
||||
ctx.ctx_handle, cache_name, byref(cache_pointer)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user