Remove cache id - test update
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
parent
1100cb0b4f
commit
a32ca74519
@ -42,7 +42,6 @@ class Backfill(Structure):
|
|||||||
|
|
||||||
class CacheConfig(Structure):
|
class CacheConfig(Structure):
|
||||||
_fields_ = [
|
_fields_ = [
|
||||||
("_id", c_uint16),
|
|
||||||
("_name", c_char_p),
|
("_name", c_char_p),
|
||||||
("_cache_mode", c_uint32),
|
("_cache_mode", c_uint32),
|
||||||
("_eviction_policy", c_uint32),
|
("_eviction_policy", c_uint32),
|
||||||
@ -134,7 +133,6 @@ class Cache:
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
owner,
|
owner,
|
||||||
cache_id: int = DEFAULT_ID,
|
|
||||||
name: str = "cache",
|
name: str = "cache",
|
||||||
cache_mode: CacheMode = CacheMode.DEFAULT,
|
cache_mode: CacheMode = CacheMode.DEFAULT,
|
||||||
eviction_policy: EvictionPolicy = EvictionPolicy.DEFAULT,
|
eviction_policy: EvictionPolicy = EvictionPolicy.DEFAULT,
|
||||||
@ -154,7 +152,6 @@ class Cache:
|
|||||||
self.cache_line_size = cache_line_size
|
self.cache_line_size = cache_line_size
|
||||||
|
|
||||||
self.cfg = CacheConfig(
|
self.cfg = CacheConfig(
|
||||||
_id=cache_id,
|
|
||||||
_name=cast(create_string_buffer(name.encode("ascii")), c_char_p),
|
_name=cast(create_string_buffer(name.encode("ascii")), c_char_p),
|
||||||
_cache_mode=cache_mode,
|
_cache_mode=cache_mode,
|
||||||
_eviction_policy=eviction_policy,
|
_eviction_policy=eviction_policy,
|
||||||
@ -437,7 +434,7 @@ class Cache:
|
|||||||
raise OcfError("Failed getting stats", status)
|
raise OcfError("Failed getting stats", status)
|
||||||
|
|
||||||
line_size = CacheLineSize(cache_info.cache_line_size)
|
line_size = CacheLineSize(cache_info.cache_line_size)
|
||||||
cache_id = self.owner.lib.ocf_cache_get_id(self)
|
cache_name = self.owner.lib.ocf_cache_get_name(self).decode("ascii")
|
||||||
|
|
||||||
self.read_unlock()
|
self.read_unlock()
|
||||||
return {
|
return {
|
||||||
@ -468,7 +465,7 @@ class Cache:
|
|||||||
"core_count": cache_info.core_count,
|
"core_count": cache_info.core_count,
|
||||||
"metadata_footprint": Size(cache_info.metadata_footprint),
|
"metadata_footprint": Size(cache_info.metadata_footprint),
|
||||||
"metadata_end_offset": Size(cache_info.metadata_end_offset),
|
"metadata_end_offset": Size(cache_info.metadata_end_offset),
|
||||||
"cache_id": cache_id,
|
"cache_name": cache_name,
|
||||||
},
|
},
|
||||||
"block": struct_to_dict(block),
|
"block": struct_to_dict(block),
|
||||||
"req": struct_to_dict(req),
|
"req": struct_to_dict(req),
|
||||||
|
@ -118,5 +118,5 @@ def get_default_ctx(logger):
|
|||||||
|
|
||||||
|
|
||||||
lib = OcfLib.getInstance()
|
lib = OcfLib.getInstance()
|
||||||
lib.ocf_mngt_cache_get_by_id.argtypes = [c_void_p, c_void_p, c_void_p]
|
lib.ocf_mngt_cache_get_by_name.argtypes = [c_void_p, c_void_p, c_void_p]
|
||||||
lib.ocf_mngt_cache_get_by_id.restype = c_int
|
lib.ocf_mngt_cache_get_by_name.restype = c_int
|
||||||
|
@ -135,7 +135,6 @@ def test_start_params(pyocf_ctx, mode: CacheMode, cls: CacheLineSize, layout: Me
|
|||||||
cache_device = Volume(Size.from_MiB(20))
|
cache_device = Volume(Size.from_MiB(20))
|
||||||
queue_size = randrange(60000, 2**32)
|
queue_size = randrange(60000, 2**32)
|
||||||
unblock_size = randrange(1, queue_size)
|
unblock_size = randrange(1, queue_size)
|
||||||
cache_id = randrange(1, 16385)
|
|
||||||
volatile_metadata = randrange(2) == 1
|
volatile_metadata = randrange(2) == 1
|
||||||
unaligned_io = randrange(2) == 1
|
unaligned_io = randrange(2) == 1
|
||||||
submit_fast = randrange(2) == 1
|
submit_fast = randrange(2) == 1
|
||||||
@ -146,7 +145,6 @@ def test_start_params(pyocf_ctx, mode: CacheMode, cls: CacheLineSize, layout: Me
|
|||||||
cache_device,
|
cache_device,
|
||||||
cache_mode=mode,
|
cache_mode=mode,
|
||||||
cache_line_size=cls,
|
cache_line_size=cls,
|
||||||
cache_id=cache_id,
|
|
||||||
name=name,
|
name=name,
|
||||||
metadata_layout=MetadataLayout.SEQUENTIAL,
|
metadata_layout=MetadataLayout.SEQUENTIAL,
|
||||||
metadata_volatile=volatile_metadata,
|
metadata_volatile=volatile_metadata,
|
||||||
@ -159,7 +157,6 @@ def test_start_params(pyocf_ctx, mode: CacheMode, cls: CacheLineSize, layout: Me
|
|||||||
assert stats["conf"]["cache_mode"] == mode, "Cache mode"
|
assert stats["conf"]["cache_mode"] == mode, "Cache mode"
|
||||||
assert stats["conf"]["cache_line_size"] == cls, "Cache line size"
|
assert stats["conf"]["cache_line_size"] == cls, "Cache line size"
|
||||||
assert stats["conf"]["eviction_policy"] == EvictionPolicy.DEFAULT, "Eviction policy"
|
assert stats["conf"]["eviction_policy"] == EvictionPolicy.DEFAULT, "Eviction policy"
|
||||||
assert stats["conf"]["cache_id"] == cache_id, "Cache id"
|
|
||||||
assert cache.get_name() == name, "Cache name"
|
assert cache.get_name() == name, "Cache name"
|
||||||
# TODO: metadata_layout, metadata_volatile, max_queue_size,
|
# TODO: metadata_layout, metadata_volatile, max_queue_size,
|
||||||
# queue_unblock_size, pt_unaligned_io, use_submit_fast
|
# queue_unblock_size, pt_unaligned_io, use_submit_fast
|
||||||
@ -224,15 +221,15 @@ def test_start_stop_multiple(pyocf_ctx):
|
|||||||
stats = cache.get_stats()
|
stats = cache.get_stats()
|
||||||
assert stats["conf"]["cache_mode"] == cache_mode, "Cache mode"
|
assert stats["conf"]["cache_mode"] == cache_mode, "Cache mode"
|
||||||
assert stats["conf"]["cache_line_size"] == cache_line_size, "Cache line size"
|
assert stats["conf"]["cache_line_size"] == cache_line_size, "Cache line size"
|
||||||
assert stats["conf"]["cache_id"] == i, "Cache id"
|
assert stats["conf"]["cache_name"] == cache_name, "Cache name"
|
||||||
|
|
||||||
caches.sort(key=lambda e: randrange(1000))
|
caches.sort(key=lambda e: randrange(1000))
|
||||||
for cache in caches:
|
for cache in caches:
|
||||||
logger.info("Getting stats before stopping cache")
|
logger.info("Getting stats before stopping cache")
|
||||||
stats = cache.get_stats()
|
stats = cache.get_stats()
|
||||||
cache_id = stats["conf"]["cache_id"]
|
cache_name = stats["conf"]["cache_name"]
|
||||||
cache.stop()
|
cache.stop()
|
||||||
assert get_cache_by_id(pyocf_ctx, cache_id) != 0, "Try getting cache after stopping it"
|
assert get_cache_by_name(pyocf_ctx, cache_name) != 0, "Try getting cache after stopping it"
|
||||||
|
|
||||||
|
|
||||||
def test_100_start_stop(pyocf_ctx):
|
def test_100_start_stop(pyocf_ctx):
|
||||||
@ -255,9 +252,9 @@ def test_100_start_stop(pyocf_ctx):
|
|||||||
stats = cache.get_stats()
|
stats = cache.get_stats()
|
||||||
assert stats["conf"]["cache_mode"] == cache_mode, "Cache mode"
|
assert stats["conf"]["cache_mode"] == cache_mode, "Cache mode"
|
||||||
assert stats["conf"]["cache_line_size"] == cache_line_size, "Cache line size"
|
assert stats["conf"]["cache_line_size"] == cache_line_size, "Cache line size"
|
||||||
assert stats["conf"]["cache_id"] == 1, "Cache id"
|
assert stats["conf"]["cache_name"] == cache_name, "Cache name"
|
||||||
cache.stop()
|
cache.stop()
|
||||||
assert get_cache_by_id(pyocf_ctx, 1) != 0, "Try getting cache after stopping it"
|
assert get_cache_by_name(pyocf_ctx, "cache1") != 0, "Try getting cache after stopping it"
|
||||||
|
|
||||||
|
|
||||||
def test_start_stop_incrementally(pyocf_ctx):
|
def test_start_stop_incrementally(pyocf_ctx):
|
||||||
@ -291,7 +288,7 @@ def test_start_stop_incrementally(pyocf_ctx):
|
|||||||
stats = cache.get_stats()
|
stats = cache.get_stats()
|
||||||
assert stats["conf"]["cache_mode"] == cache_mode, "Cache mode"
|
assert stats["conf"]["cache_mode"] == cache_mode, "Cache mode"
|
||||||
assert stats["conf"]["cache_line_size"] == cache_line_size, "Cache line size"
|
assert stats["conf"]["cache_line_size"] == cache_line_size, "Cache line size"
|
||||||
assert stats["conf"]["cache_id"] == len(caches), "Cache id"
|
assert stats["conf"]["cache_name"] == cache_name, "Cache name"
|
||||||
if len(caches) == caches_limit:
|
if len(caches) == caches_limit:
|
||||||
increase = False
|
increase = False
|
||||||
else:
|
else:
|
||||||
@ -302,28 +299,26 @@ def test_start_stop_incrementally(pyocf_ctx):
|
|||||||
cache = caches.pop()
|
cache = caches.pop()
|
||||||
logger.info("Getting stats before stopping cache")
|
logger.info("Getting stats before stopping cache")
|
||||||
stats = cache.get_stats()
|
stats = cache.get_stats()
|
||||||
cache_id = stats["conf"]["cache_id"]
|
cache_name = stats["conf"]["cache_name"]
|
||||||
cache.stop()
|
cache.stop()
|
||||||
assert get_cache_by_id(pyocf_ctx, cache_id) !=\
|
assert get_cache_by_name(pyocf_ctx, cache_name) != 0, \
|
||||||
0, "Try getting cache after stopping it"
|
"Try getting cache after stopping it"
|
||||||
add = not add
|
add = not add
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("mode", CacheMode)
|
@pytest.mark.parametrize("mode", CacheMode)
|
||||||
@pytest.mark.parametrize("cls", CacheLineSize)
|
@pytest.mark.parametrize("cls", CacheLineSize)
|
||||||
def test_start_cache_same_id(pyocf_ctx, mode, cls):
|
def test_start_cache_same_id(pyocf_ctx, mode, cls):
|
||||||
"""Adding two caches with the same cache_id
|
"""Adding two caches with the same name
|
||||||
Check that OCF does not allow for 2 caches to be started with the same cache_id
|
Check that OCF does not allow for 2 caches to be started with the same cache_name
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cache_device1 = Volume(Size.from_MiB(20))
|
cache_device1 = Volume(Size.from_MiB(20))
|
||||||
cache_device2 = Volume(Size.from_MiB(20))
|
cache_device2 = Volume(Size.from_MiB(20))
|
||||||
cache_name = "cache"
|
cache_name = "cache"
|
||||||
cache_id = randrange(1, 16385)
|
|
||||||
cache = Cache.start_on_device(cache_device1,
|
cache = Cache.start_on_device(cache_device1,
|
||||||
cache_mode=mode,
|
cache_mode=mode,
|
||||||
cache_line_size=cls,
|
cache_line_size=cls,
|
||||||
cache_id=cache_id,
|
|
||||||
name=cache_name)
|
name=cache_name)
|
||||||
cache.get_stats()
|
cache.get_stats()
|
||||||
|
|
||||||
@ -331,7 +326,6 @@ def test_start_cache_same_id(pyocf_ctx, mode, cls):
|
|||||||
cache = Cache.start_on_device(cache_device2,
|
cache = Cache.start_on_device(cache_device2,
|
||||||
cache_mode=mode,
|
cache_mode=mode,
|
||||||
cache_line_size=cls,
|
cache_line_size=cls,
|
||||||
cache_id=cache_id,
|
|
||||||
name=cache_name)
|
name=cache_name)
|
||||||
cache.get_stats()
|
cache.get_stats()
|
||||||
|
|
||||||
@ -519,8 +513,8 @@ def check_md5_sums(exported_obj: Core, mode: CacheMode):
|
|||||||
"MD5 check: core device vs exported object"
|
"MD5 check: core device vs exported object"
|
||||||
|
|
||||||
|
|
||||||
def get_cache_by_id(ctx, cache_id):
|
def get_cache_by_name(ctx, cache_name):
|
||||||
cache_pointer = c_void_p()
|
cache_pointer = c_void_p()
|
||||||
return OcfLib.getInstance().ocf_mngt_cache_get_by_id(ctx.ctx_handle,
|
return OcfLib.getInstance().ocf_mngt_cache_get_by_name(
|
||||||
cache_id,
|
ctx.ctx_handle, cache_name, byref(cache_pointer)
|
||||||
byref(cache_pointer))
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user