diff --git a/tests/functional/tests/management/test_change_params.py b/tests/functional/tests/management/test_change_params.py index a1dbf80..d607fe6 100644 --- a/tests/functional/tests/management/test_change_params.py +++ b/tests/functional/tests/management/test_change_params.py @@ -39,13 +39,13 @@ def test_change_cleaning_policy(pyocf_ctx, cm, cls): # Check all possible cleaning policy switches for cp_from 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_from.value) + + # Check if cleaning policy is correct + stats = cache.get_stats() + assert stats["conf"]["cleaning_policy"] == cp_from.value + cache.set_cleaning_policy(cp_to.value) # Check if cleaning policy is correct @@ -74,15 +74,15 @@ 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: - cache.set_seq_cut_off_policy(seq_from.value) - - # Check if seq cut off policy is correct - stats = core1.get_stats() - assert stats["seq_cutoff_policy"] == seq_from.value - stats = core2.get_stats() - assert stats["seq_cutoff_policy"] == seq_from.value - for seq_to in SeqCutOffPolicy: + cache.set_seq_cut_off_policy(seq_from.value) + + # Check if seq cut off policy is correct + stats = core1.get_stats() + assert stats["seq_cutoff_policy"] == seq_from.value + stats = core2.get_stats() + assert stats["seq_cutoff_policy"] == seq_from.value + cache.set_seq_cut_off_policy(seq_to.value) # Check if seq cut off policy is correct @@ -113,17 +113,17 @@ 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: - core1.set_seq_cut_off_policy(seq_from.value) - - # Check if seq cut off policy of the first core is correct - stats = core1.get_stats() - assert stats["seq_cutoff_policy"] == seq_from.value - - # Check if seq cut off policy of the second core did not change - stats = core2.get_stats() - assert stats["seq_cutoff_policy"] == SeqCutOffPolicy.DEFAULT - 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 + stats = core1.get_stats() + assert stats["seq_cutoff_policy"] == seq_from.value + + # Check if seq cut off policy of the second core did not change + stats = core2.get_stats() + assert stats["seq_cutoff_policy"] == SeqCutOffPolicy.DEFAULT + core1.set_seq_cut_off_policy(seq_to.value) # Check if seq cut off policy of the first core is correct diff --git a/tests/functional/tests/management/test_start_stop.py b/tests/functional/tests/management/test_start_stop.py index a907b57..b88972d 100644 --- a/tests/functional/tests/management/test_start_stop.py +++ b/tests/functional/tests/management/test_start_stop.py @@ -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):