Merge pull request #898 from karolinavelkaja/cleanup_framework_eviction_policy

cleanup framework - eviction policy
This commit is contained in:
Robert Baldyga 2021-08-20 10:21:32 +02:00 committed by GitHub
commit 1c506bfa8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 36 deletions

View File

@ -40,11 +40,6 @@ class Cache:
cp = stats.config_stats.cleaning_policy cp = stats.config_stats.cleaning_policy
return CleaningPolicy[cp] return CleaningPolicy[cp]
def get_eviction_policy(self):
stats = self.get_statistics()
ep = stats.config_stats.eviction_policy
return EvictionPolicy[ep]
def get_metadata_mode(self): def get_metadata_mode(self):
if self.__metadata_mode is None: if self.__metadata_mode is None:
stats = self.get_statistics() stats = self.get_statistics()
@ -183,5 +178,4 @@ class Cache:
return CacheConfig(self.get_cache_line_size(), return CacheConfig(self.get_cache_line_size(),
self.get_cache_mode(), self.get_cache_mode(),
self.get_cleaning_policy(), self.get_cleaning_policy(),
self.get_eviction_policy(),
self.get_metadata_mode()) self.get_metadata_mode())

View File

@ -82,14 +82,6 @@ class SeqCutOffPolicy(Enum):
raise ValueError(f"{name} is not a valid sequential cut off name") raise ValueError(f"{name} is not a valid sequential cut off name")
class EvictionPolicy(Enum):
lru = "LRU"
DEFAULT = lru
def __str__(self):
return self.value
class MetadataMode(Enum): class MetadataMode(Enum):
normal = "normal" normal = "normal"
atomic = "atomic" atomic = "atomic"
@ -378,14 +370,12 @@ class CacheConfig:
cache_line_size=CacheLineSize.DEFAULT, cache_line_size=CacheLineSize.DEFAULT,
cache_mode=CacheMode.DEFAULT, cache_mode=CacheMode.DEFAULT,
cleaning_policy=CleaningPolicy.DEFAULT, cleaning_policy=CleaningPolicy.DEFAULT,
eviction_policy=EvictionPolicy.DEFAULT,
metadata_mode=MetadataMode.normal, metadata_mode=MetadataMode.normal,
kernel_parameters=None kernel_parameters=None
): ):
self.cache_line_size = cache_line_size self.cache_line_size = cache_line_size
self.cache_mode = cache_mode self.cache_mode = cache_mode
self.cleaning_policy = cleaning_policy self.cleaning_policy = cleaning_policy
self.eviction_policy = eviction_policy
self.metadata_mode = metadata_mode self.metadata_mode = metadata_mode
self.kernel_parameters = kernel_parameters self.kernel_parameters = kernel_parameters
@ -394,7 +384,6 @@ class CacheConfig:
self.cache_line_size == other.cache_line_size self.cache_line_size == other.cache_line_size
and self.cache_mode == other.cache_mode and self.cache_mode == other.cache_mode
and self.cleaning_policy == other.cleaning_policy and self.cleaning_policy == other.cleaning_policy
and self.eviction_policy == other.eviction_policy
and self.metadata_mode == other.metadata_mode and self.metadata_mode == other.metadata_mode
and equal_or_default( and equal_or_default(
self.kernel_parameters, other.kernel_parameters, KernelParameters.DEFAULT self.kernel_parameters, other.kernel_parameters, KernelParameters.DEFAULT

View File

@ -5,18 +5,18 @@
import time import time
from datetime import timedelta
import pytest import pytest
from datetime import timedelta
from api.cas import casadm from api.cas import casadm
from api.cas.cache_config import CacheMode from api.cas.cache_config import CacheMode
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
from core.test_run import TestRun from core.test_run import TestRun
from test_utils.size import Size, Unit from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
from test_utils.os_utils import Udev, sync
from test_tools.fio.fio import Fio from test_tools.fio.fio import Fio
from test_tools.fio.fio_param import ReadWrite, IoEngine, VerifyMethod from test_tools.fio.fio_param import ReadWrite, IoEngine, VerifyMethod
from test_utils.os_utils import Udev, sync
from test_utils.size import Size, Unit
io_size = Size(10000, Unit.Blocks4096) io_size = Size(10000, Unit.Blocks4096)
@ -88,11 +88,6 @@ def test_cache_stop_and_load(cache_mode):
f"Cleaning policy is: {check_cache_config.cleaning_policy}, " f"Cleaning policy is: {check_cache_config.cleaning_policy}, "
f"should be: {cache.get_cleaning_policy()}\n" f"should be: {cache.get_cleaning_policy()}\n"
) )
if check_cache_config.eviction_policy != cache.get_eviction_policy():
failed_params += (
f"Eviction policy is: {check_cache_config.eviction_policy}, "
f"should be: {cache.get_eviction_policy()}\n"
)
if check_cache_config.cache_line_size != cache.get_cache_line_size(): if check_cache_config.cache_line_size != cache.get_cache_line_size():
failed_params += ( failed_params += (
f"Cache line size is: {check_cache_config.cache_line_size}, " f"Cache line size is: {check_cache_config.cache_line_size}, "

View File

@ -4,8 +4,10 @@
# #
import pytest
import time import time
from datetime import timedelta
import pytest
from api.cas import casadm from api.cas import casadm
from api.cas.cache_config import ( from api.cas.cache_config import (
@ -14,7 +16,6 @@ from api.cas.cache_config import (
CacheModeTrait, CacheModeTrait,
CacheStatus, CacheStatus,
CleaningPolicy, CleaningPolicy,
EvictionPolicy,
MetadataMode, MetadataMode,
PromotionPolicy, PromotionPolicy,
) )
@ -24,13 +25,11 @@ from api.cas.statistics import (
usage_stats, request_stats, block_stats_core, block_stats_cache, error_stats usage_stats, request_stats, block_stats_core, block_stats_cache, error_stats
) )
from core.test_run import TestRun from core.test_run import TestRun
from datetime import timedelta
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
from test_tools.fio.fio import Fio from test_tools.fio.fio import Fio
from test_tools.fio.fio_param import ReadWrite, IoEngine from test_tools.fio.fio_param import ReadWrite, IoEngine
from test_utils.size import Size, Unit from test_utils.size import Size, Unit
# One cache instance per every cache mode: # One cache instance per every cache mode:
caches_count = len(CacheMode) caches_count = len(CacheMode)
cores_per_cache = 4 cores_per_cache = 4
@ -275,11 +274,6 @@ def validate_cache_config_statistics(caches, after_io: bool = False):
failed_stats += ( failed_stats += (
f"For cache number {caches[i].cache_id} number of inactive core devices is " f"For cache number {caches[i].cache_id} number of inactive core devices is "
f"{caches_stats[i].config_stats.inactive_core_dev}, should be 0\n") f"{caches_stats[i].config_stats.inactive_core_dev}, should be 0\n")
if caches_stats[i].config_stats.eviction_policy.upper() != EvictionPolicy.DEFAULT.value:
failed_stats += (
f"For cache number {caches[i].cache_id} eviction policy is "
f"{caches_stats[i].config_stats.eviction_policy.upper()}, "
f"should be {EvictionPolicy.DEFAULT}\n")
if caches_stats[i].config_stats.cleaning_policy.upper() != CleaningPolicy.DEFAULT.value: if caches_stats[i].config_stats.cleaning_policy.upper() != CleaningPolicy.DEFAULT.value:
failed_stats += ( failed_stats += (
f"For cache number {caches[i].cache_id} cleaning policy is " f"For cache number {caches[i].cache_id} cleaning policy is "