Unique cache name - test update
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
parent
901b39031f
commit
9853814252
@ -135,7 +135,7 @@ class Cache:
|
||||
self,
|
||||
owner,
|
||||
cache_id: int = DEFAULT_ID,
|
||||
name: str = "",
|
||||
name: str = "cache",
|
||||
cache_mode: CacheMode = CacheMode.DEFAULT,
|
||||
eviction_policy: EvictionPolicy = EvictionPolicy.DEFAULT,
|
||||
promotion_policy: PromotionPolicy = PromotionPolicy.DEFAULT,
|
||||
@ -155,7 +155,7 @@ class Cache:
|
||||
|
||||
self.cfg = CacheConfig(
|
||||
_id=cache_id,
|
||||
_name=name.encode("ascii") if name else None,
|
||||
_name=cast(create_string_buffer(name.encode("ascii")), c_char_p),
|
||||
_cache_mode=cache_mode,
|
||||
_eviction_policy=eviction_policy,
|
||||
_promotion_policy=promotion_policy,
|
||||
|
@ -152,7 +152,7 @@ def test_adding_to_random_cache(pyocf_ctx):
|
||||
# Create 5 cache devices
|
||||
for i in range(0, cache_amount):
|
||||
cache_device = Volume(S.from_MiB(30))
|
||||
cache = Cache.start_on_device(cache_device)
|
||||
cache = Cache.start_on_device(cache_device, name=f"cache{i}")
|
||||
cache_devices.append(cache)
|
||||
|
||||
# Create 50 core devices and add to random cache
|
||||
@ -204,13 +204,13 @@ def test_adding_core_already_used(pyocf_ctx, cache_mode, cls):
|
||||
# Start first cache device
|
||||
cache_device1 = Volume(S.from_MiB(30))
|
||||
cache1 = Cache.start_on_device(
|
||||
cache_device1, cache_mode=cache_mode, cache_line_size=cls
|
||||
cache_device1, cache_mode=cache_mode, cache_line_size=cls, name="cache1"
|
||||
)
|
||||
|
||||
# Start second cache device
|
||||
cache_device2 = Volume(S.from_MiB(30))
|
||||
cache2 = Cache.start_on_device(
|
||||
cache_device2, cache_mode=cache_mode, cache_line_size=cls
|
||||
cache_device2, cache_mode=cache_mode, cache_line_size=cls, name="cache2"
|
||||
)
|
||||
|
||||
# Create core device
|
||||
|
@ -6,6 +6,7 @@
|
||||
import logging
|
||||
from ctypes import c_int, c_void_p, byref
|
||||
from random import randrange
|
||||
from itertools import count
|
||||
|
||||
import pytest
|
||||
|
||||
@ -209,12 +210,14 @@ def test_start_stop_multiple(pyocf_ctx):
|
||||
caches_no = randrange(6, 11)
|
||||
for i in range(1, caches_no):
|
||||
cache_device = Volume(Size.from_MiB(20))
|
||||
cache_name = f"cache{i}"
|
||||
cache_mode = CacheMode(randrange(0, len(CacheMode)))
|
||||
size = 4096 * 2**randrange(0, len(CacheLineSize))
|
||||
cache_line_size = CacheLineSize(size)
|
||||
|
||||
cache = Cache.start_on_device(
|
||||
cache_device,
|
||||
name=cache_name,
|
||||
cache_mode=cache_mode,
|
||||
cache_line_size=cache_line_size)
|
||||
caches.append(cache)
|
||||
@ -239,12 +242,14 @@ def test_100_start_stop(pyocf_ctx):
|
||||
|
||||
for i in range(1, 101):
|
||||
cache_device = Volume(Size.from_MiB(20))
|
||||
cache_name = f"cache{i}"
|
||||
cache_mode = CacheMode(randrange(0, len(CacheMode)))
|
||||
size = 4096 * 2**randrange(0, len(CacheLineSize))
|
||||
cache_line_size = CacheLineSize(size)
|
||||
|
||||
cache = Cache.start_on_device(
|
||||
cache_device,
|
||||
name=cache_name,
|
||||
cache_mode=cache_mode,
|
||||
cache_line_size=cache_line_size)
|
||||
stats = cache.get_stats()
|
||||
@ -262,6 +267,7 @@ def test_start_stop_incrementally(pyocf_ctx):
|
||||
and then proportions are reversed and number of caches gradually falls to 0.
|
||||
"""
|
||||
|
||||
counter = count()
|
||||
caches = []
|
||||
caches_limit = 10
|
||||
add = True
|
||||
@ -271,12 +277,14 @@ def test_start_stop_incrementally(pyocf_ctx):
|
||||
if add:
|
||||
for i in range(0, randrange(3, 5) if increase else randrange(1, 3)):
|
||||
cache_device = Volume(Size.from_MiB(20))
|
||||
cache_name = f"cache{next(counter)}"
|
||||
cache_mode = CacheMode(randrange(0, len(CacheMode)))
|
||||
size = 4096 * 2**randrange(0, len(CacheLineSize))
|
||||
cache_line_size = CacheLineSize(size)
|
||||
|
||||
cache = Cache.start_on_device(
|
||||
cache_device,
|
||||
name=cache_name,
|
||||
cache_mode=cache_mode,
|
||||
cache_line_size=cache_line_size)
|
||||
caches.append(cache)
|
||||
@ -310,18 +318,21 @@ def test_start_cache_same_id(pyocf_ctx, mode, cls):
|
||||
|
||||
cache_device1 = Volume(Size.from_MiB(20))
|
||||
cache_device2 = Volume(Size.from_MiB(20))
|
||||
cache_name = "cache"
|
||||
cache_id = randrange(1, 16385)
|
||||
cache = Cache.start_on_device(cache_device1,
|
||||
cache_mode=mode,
|
||||
cache_line_size=cls,
|
||||
cache_id=cache_id)
|
||||
cache_id=cache_id,
|
||||
name=cache_name)
|
||||
cache.get_stats()
|
||||
|
||||
with pytest.raises(OcfError, match="OCF_ERR_CACHE_EXIST"):
|
||||
cache = Cache.start_on_device(cache_device2,
|
||||
cache_mode=mode,
|
||||
cache_line_size=cls,
|
||||
cache_id=cache_id)
|
||||
cache_id=cache_id,
|
||||
name=cache_name)
|
||||
cache.get_stats()
|
||||
|
||||
|
||||
@ -333,11 +344,15 @@ def test_start_cache_same_device(pyocf_ctx, mode, cls):
|
||||
"""
|
||||
|
||||
cache_device = Volume(Size.from_MiB(20))
|
||||
cache = Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)
|
||||
cache = Cache.start_on_device(
|
||||
cache_device, cache_mode=mode, cache_line_size=cls, name="cache1"
|
||||
)
|
||||
cache.get_stats()
|
||||
|
||||
with pytest.raises(OcfError, match="OCF_ERR_NOT_OPEN_EXC"):
|
||||
cache = Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)
|
||||
cache = Cache.start_on_device(
|
||||
cache_device, cache_mode=mode, cache_line_size=cls, name="cache2"
|
||||
)
|
||||
cache.get_stats()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user