Pyocf test checking if default values are correct

Signed-off-by: Kamil Lepek <kamil.lepek94@gmail.com>
This commit is contained in:
Kamil Lepek 2019-05-22 15:54:15 +02:00
parent ecd492e562
commit 54c0e48fce
2 changed files with 48 additions and 26 deletions

View File

@ -39,13 +39,13 @@ def test_change_cleaning_policy(pyocf_ctx, cm, cls):
# Check all possible cleaning policy switches
for cp_from in CleaningPolicy:
for cp_to in CleaningPolicy:
cache.set_cleaning_policy(cp_from.value)
# Check if cleaning policy is correct
stats = cache.get_stats()
assert stats["conf"]["cleaning_policy"] == cp_from.value
for cp_to in CleaningPolicy:
cache.set_cleaning_policy(cp_to.value)
# Check if cleaning policy is correct
@ -74,6 +74,7 @@ def test_cache_change_seq_cut_off_policy(pyocf_ctx, cm, cls):
# Check all possible seq cut off policy switches
for seq_from in SeqCutOffPolicy:
for seq_to in SeqCutOffPolicy:
cache.set_seq_cut_off_policy(seq_from.value)
# Check if seq cut off policy is correct
@ -82,7 +83,6 @@ def test_cache_change_seq_cut_off_policy(pyocf_ctx, cm, cls):
stats = core2.get_stats()
assert stats["seq_cutoff_policy"] == seq_from.value
for seq_to in SeqCutOffPolicy:
cache.set_seq_cut_off_policy(seq_to.value)
# Check if seq cut off policy is correct
@ -113,6 +113,7 @@ def test_core_change_seq_cut_off_policy(pyocf_ctx, cm, cls):
# Check all possible seq cut off policy switches for first core
for seq_from in SeqCutOffPolicy:
for seq_to in SeqCutOffPolicy:
core1.set_seq_cut_off_policy(seq_from.value)
# Check if seq cut off policy of the first core is correct
@ -123,7 +124,6 @@ def test_core_change_seq_cut_off_policy(pyocf_ctx, cm, cls):
stats = core2.get_stats()
assert stats["seq_cutoff_policy"] == SeqCutOffPolicy.DEFAULT
for seq_to in SeqCutOffPolicy:
core1.set_seq_cut_off_policy(seq_to.value)
# Check if seq cut off policy of the first core is correct

View File

@ -10,17 +10,39 @@ from random import randrange
import pytest
from pyocf.ocf import OcfLib
from pyocf.types.cache import Cache, CacheMode, MetadataLayout, EvictionPolicy
from pyocf.types.cache import Cache, CacheMode, MetadataLayout, EvictionPolicy, CleaningPolicy
from pyocf.types.core import Core
from pyocf.types.data import Data
from pyocf.types.io import IoDir
from pyocf.types.shared import OcfError, OcfCompletion, CacheLineSize
from pyocf.types.shared import OcfError, OcfCompletion, CacheLineSize, SeqCutOffPolicy
from pyocf.types.volume import Volume
from pyocf.utils import Size
logger = logging.getLogger(__name__)
def test_start_check_default(pyocf_ctx):
"""Test if default values are correct after start.
"""
cache_device = Volume(Size.from_MiB(40))
core_device = Volume(Size.from_MiB(10))
cache = Cache.start_on_device(cache_device)
core = Core.using_device(core_device)
cache.add_core(core)
# Check if values are default
stats = cache.get_stats()
assert stats["conf"]["cleaning_policy"] == CleaningPolicy.DEFAULT
assert stats["conf"]["cache_mode"] == CacheMode.DEFAULT
assert stats["conf"]["cache_line_size"] == CacheLineSize.DEFAULT
assert stats["conf"]["eviction_policy"] == EvictionPolicy.DEFAULT
core_stats = core.get_stats()
assert core_stats["seq_cutoff_policy"] == SeqCutOffPolicy.DEFAULT
@pytest.mark.parametrize("cls", CacheLineSize)
@pytest.mark.parametrize("mode", CacheMode)
def test_start_write_first_and_check_mode(pyocf_ctx, mode: CacheMode, cls: CacheLineSize):