pyocf: Use bigger cache device size in tests

As amount of fixed size metadata allocated by OCF grows, we need to adjust
test to not try to start cache on device that is too small.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2021-12-13 15:57:25 +01:00
parent 99c8c05f3f
commit 98cb9bff70
14 changed files with 82 additions and 82 deletions

View File

@ -20,8 +20,8 @@ def test_ctx_fixture(pyocf_ctx):
def test_simple_wt_write(pyocf_ctx): def test_simple_wt_write(pyocf_ctx):
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
core_device = Volume(S.from_MiB(30)) core_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device) cache = Cache.start_on_device(cache_device)
core = Core.using_device(core_device) core = Core.using_device(core_device)
@ -52,21 +52,21 @@ def test_simple_wt_write(pyocf_ctx):
def test_start_corrupted_metadata_lba(pyocf_ctx): def test_start_corrupted_metadata_lba(pyocf_ctx):
cache_device = ErrorDevice(S.from_MiB(30), error_sectors=set([0])) cache_device = ErrorDevice(S.from_MiB(50), error_sectors=set([0]))
with pytest.raises(OcfError, match="OCF_ERR_WRITE_CACHE"): with pytest.raises(OcfError, match="OCF_ERR_WRITE_CACHE"):
cache = Cache.start_on_device(cache_device) cache = Cache.start_on_device(cache_device)
def test_load_cache_no_preexisting_data(pyocf_ctx): def test_load_cache_no_preexisting_data(pyocf_ctx):
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
with pytest.raises(OcfError, match="OCF_ERR_NO_METADATA"): with pytest.raises(OcfError, match="OCF_ERR_NO_METADATA"):
cache = Cache.load_from_device(cache_device) cache = Cache.load_from_device(cache_device)
def test_load_cache(pyocf_ctx): def test_load_cache(pyocf_ctx):
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device) cache = Cache.start_on_device(cache_device)
cache.stop() cache.stop()
@ -75,7 +75,7 @@ def test_load_cache(pyocf_ctx):
def test_load_cache_recovery(pyocf_ctx): def test_load_cache_recovery(pyocf_ctx):
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device) cache = Cache.start_on_device(cache_device)

View File

@ -84,8 +84,8 @@ def test_io_flags(pyocf_ctx, cache_mode):
data = bytes(block_size) data = bytes(block_size)
cache_device = FlagsValVolume(Size.from_MiB(30), flags) cache_device = FlagsValVolume(Size.from_MiB(50), flags)
core_device = FlagsValVolume(Size.from_MiB(30), flags) core_device = FlagsValVolume(Size.from_MiB(50), flags)
cache = Cache.start_on_device(cache_device, cache_mode=cache_mode) cache = Cache.start_on_device(cache_device, cache_mode=cache_mode)
core = Core.using_device(core_device) core = Core.using_device(core_device)

View File

@ -26,8 +26,8 @@ def test_init_nhit(pyocf_ctx, promotion_policy):
* verify that promotion policy type is properly reflected in stats * verify that promotion policy type is properly reflected in stats
""" """
cache_device = Volume(Size.from_MiB(30)) cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(30)) core_device = Volume(Size.from_MiB(50))
cache = Cache.start_on_device(cache_device, promotion_policy=promotion_policy) cache = Cache.start_on_device(cache_device, promotion_policy=promotion_policy)
core = Core.using_device(core_device) core = Core.using_device(core_device)
@ -53,8 +53,8 @@ def test_change_to_nhit_and_back_io_in_flight(pyocf_ctx):
""" """
# Step 1 # Step 1
cache_device = Volume(Size.from_MiB(30)) cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(30)) core_device = Volume(Size.from_MiB(50))
cache = Cache.start_on_device(cache_device) cache = Cache.start_on_device(cache_device)
core = Core.using_device(core_device) core = Core.using_device(core_device)
@ -177,8 +177,8 @@ def test_promoted_after_hits_various_thresholds(
""" """
# Step 1 # Step 1
cache_device = Volume(Size.from_MiB(30)) cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(30)) core_device = Volume(Size.from_MiB(50))
cache = Cache.start_on_device(cache_device, promotion_policy=PromotionPolicy.NHIT) cache = Cache.start_on_device(cache_device, promotion_policy=PromotionPolicy.NHIT)
core = Core.using_device(core_device) core = Core.using_device(core_device)
@ -260,8 +260,8 @@ def test_partial_hit_promotion(pyocf_ctx):
""" """
# Step 1 # Step 1
cache_device = Volume(Size.from_MiB(30)) cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(30)) core_device = Volume(Size.from_MiB(50))
cache = Cache.start_on_device(cache_device) cache = Cache.start_on_device(cache_device)
core = Core.using_device(core_device) core = Core.using_device(core_device)

View File

@ -259,8 +259,8 @@ def test_read_data_consistency(pyocf_ctx, cacheline_size, cache_mode, rand_seed)
result_b = bytes(WORKSET_SIZE) result_b = bytes(WORKSET_SIZE)
cache_device = Volume(Size.from_MiB(30)) cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(30)) core_device = Volume(Size.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_mode=CacheMode.WO, cache_line_size=cacheline_size cache_device, cache_mode=CacheMode.WO, cache_line_size=cacheline_size

View File

@ -24,7 +24,7 @@ logger = logging.getLogger(__name__)
@pytest.mark.parametrize("mode", [CacheMode.WT]) @pytest.mark.parametrize("mode", [CacheMode.WT])
def test_eviction_two_cores(pyocf_ctx, mode: CacheMode, cls: CacheLineSize): def test_eviction_two_cores(pyocf_ctx, mode: CacheMode, cls: CacheLineSize):
"""Test if eviction works correctly when remapping cachelines between distinct cores.""" """Test if eviction works correctly when remapping cachelines between distinct cores."""
cache_device = Volume(Size.from_MiB(20)) cache_device = Volume(Size.from_MiB(50))
core_device1 = Volume(Size.from_MiB(40)) core_device1 = Volume(Size.from_MiB(40))
core_device2 = Volume(Size.from_MiB(40)) core_device2 = Volume(Size.from_MiB(40))
@ -52,9 +52,9 @@ def test_eviction_two_cores(pyocf_ctx, mode: CacheMode, cls: CacheLineSize):
@pytest.mark.parametrize("mode", [CacheMode.WT, CacheMode.WB, CacheMode.WO]) @pytest.mark.parametrize("mode", [CacheMode.WT, CacheMode.WB, CacheMode.WO])
def test_write_size_greater_than_cache(pyocf_ctx, mode: CacheMode, cls: CacheLineSize): def test_write_size_greater_than_cache(pyocf_ctx, mode: CacheMode, cls: CacheLineSize):
"""Test if eviction does not occur when IO greater than cache size is submitted.""" """Test if eviction does not occur when IO greater than cache size is submitted."""
cache_device = Volume(Size.from_MiB(20)) cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(5)) core_device = Volume(Size.from_MiB(200))
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)
cache_size = cache.get_stats()["conf"]["size"] cache_size = cache.get_stats()["conf"]["size"]
core_exported = Core.using_device(core_device) core_exported = Core.using_device(core_device)
@ -74,10 +74,10 @@ def test_write_size_greater_than_cache(pyocf_ctx, mode: CacheMode, cls: CacheLin
), "Occupancy after first IO" ), "Occupancy after first IO"
prev_writes_to_core = stats["block"]["core_volume_wr"]["value"] prev_writes_to_core = stats["block"]["core_volume_wr"]["value"]
# Anything below 5 MiB is a valid size (less than core device size) # Anything below 200 MiB is a valid size (less than core device size)
# Writing over cache size (to the offset above first io) in this case should go # Writing over cache size (to the offset above first io) in this case should go
# directly to core and shouldn't trigger eviction # directly to core and shouldn't trigger eviction
io_size_bigger_than_cache = Size.from_MiB(2) io_size_bigger_than_cache = Size.from_MiB(100)
io_offset = valid_io_size io_offset = valid_io_size
test_data = Data(io_size_bigger_than_cache) test_data = Data(io_size_bigger_than_cache)
send_io(core_exported, test_data, io_offset) send_io(core_exported, test_data, io_offset)
@ -106,7 +106,7 @@ def test_write_size_greater_than_cache(pyocf_ctx, mode: CacheMode, cls: CacheLin
@pytest.mark.parametrize("cls", CacheLineSize) @pytest.mark.parametrize("cls", CacheLineSize)
def test_evict_overflown_pinned(pyocf_ctx, cls: CacheLineSize): def test_evict_overflown_pinned(pyocf_ctx, cls: CacheLineSize):
""" Verify if overflown pinned ioclass is evicted """ """ Verify if overflown pinned ioclass is evicted """
cache_device = Volume(Size.from_MiB(35)) cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(100)) core_device = Volume(Size.from_MiB(100))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_mode=CacheMode.WT, cache_line_size=cls cache_device, cache_mode=CacheMode.WT, cache_line_size=cls

View File

@ -75,8 +75,8 @@ def test_flush_after_mngmt(pyocf_ctx):
data = bytes(block_size) data = bytes(block_size)
cache_device = FlushValVolume(Size.from_MiB(30)) cache_device = FlushValVolume(Size.from_MiB(50))
core_device = FlushValVolume(Size.from_MiB(30)) core_device = FlushValVolume(Size.from_MiB(50))
# after start cache VC must be cleared # after start cache VC must be cleared
cache = Cache.start_on_device(cache_device, cache_mode=CacheMode.WT) cache = Cache.start_on_device(cache_device, cache_mode=CacheMode.WT)

View File

@ -19,7 +19,7 @@ from pyocf.types.shared import OcfError, OcfCompletion, CacheLineSize
@pytest.mark.parametrize("cls", CacheLineSize) @pytest.mark.parametrize("cls", CacheLineSize)
def test_adding_core(pyocf_ctx, cache_mode, cls): def test_adding_core(pyocf_ctx, cache_mode, cls):
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls cache_device, cache_mode=cache_mode, cache_line_size=cls
) )
@ -44,7 +44,7 @@ def test_adding_core(pyocf_ctx, cache_mode, cls):
@pytest.mark.parametrize("cls", CacheLineSize) @pytest.mark.parametrize("cls", CacheLineSize)
def test_removing_core(pyocf_ctx, cache_mode, cls): def test_removing_core(pyocf_ctx, cache_mode, cls):
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls cache_device, cache_mode=cache_mode, cache_line_size=cls
) )
@ -68,7 +68,7 @@ def test_removing_core(pyocf_ctx, cache_mode, cls):
@pytest.mark.parametrize("cls", CacheLineSize) @pytest.mark.parametrize("cls", CacheLineSize)
def test_remove_dirty_no_flush(pyocf_ctx, cache_mode, cls): def test_remove_dirty_no_flush(pyocf_ctx, cache_mode, cls):
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls cache_device, cache_mode=cache_mode, cache_line_size=cls
) )
@ -90,7 +90,7 @@ def test_remove_dirty_no_flush(pyocf_ctx, cache_mode, cls):
def test_30add_remove(pyocf_ctx): def test_30add_remove(pyocf_ctx):
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device) cache = Cache.start_on_device(cache_device)
# Create core device # Create core device
@ -111,7 +111,7 @@ def test_30add_remove(pyocf_ctx):
def test_10add_remove_with_io(pyocf_ctx): def test_10add_remove_with_io(pyocf_ctx):
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device) cache = Cache.start_on_device(cache_device)
# Create core device # Create core device
@ -143,7 +143,7 @@ def test_10add_remove_with_io(pyocf_ctx):
def test_add_remove_30core(pyocf_ctx): def test_add_remove_30core(pyocf_ctx):
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device) cache = Cache.start_on_device(cache_device)
core_devices = [] core_devices = []
core_amount = 30 core_amount = 30
@ -176,7 +176,7 @@ def test_adding_to_random_cache(pyocf_ctx):
# Create 5 cache devices # Create 5 cache devices
for i in range(0, cache_amount): for i in range(0, cache_amount):
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, name=f"cache{i}") cache = Cache.start_on_device(cache_device, name=f"cache{i}")
cache_devices.append(cache) cache_devices.append(cache)
@ -202,7 +202,7 @@ def test_adding_to_random_cache(pyocf_ctx):
@pytest.mark.parametrize("cls", CacheLineSize) @pytest.mark.parametrize("cls", CacheLineSize)
def test_adding_core_twice(pyocf_ctx, cache_mode, cls): def test_adding_core_twice(pyocf_ctx, cache_mode, cls):
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls cache_device, cache_mode=cache_mode, cache_line_size=cls
) )
@ -227,13 +227,13 @@ def test_adding_core_twice(pyocf_ctx, cache_mode, cls):
@pytest.mark.parametrize("cls", CacheLineSize) @pytest.mark.parametrize("cls", CacheLineSize)
def test_adding_core_already_used(pyocf_ctx, cache_mode, cls): def test_adding_core_already_used(pyocf_ctx, cache_mode, cls):
# Start first cache device # Start first cache device
cache_device1 = Volume(S.from_MiB(30)) cache_device1 = Volume(S.from_MiB(50))
cache1 = Cache.start_on_device( cache1 = Cache.start_on_device(
cache_device1, cache_mode=cache_mode, cache_line_size=cls, name="cache1" cache_device1, cache_mode=cache_mode, cache_line_size=cls, name="cache1"
) )
# Start second cache device # Start second cache device
cache_device2 = Volume(S.from_MiB(30)) cache_device2 = Volume(S.from_MiB(50))
cache2 = Cache.start_on_device( cache2 = Cache.start_on_device(
cache_device2, cache_mode=cache_mode, cache_line_size=cls, name="cache2" cache_device2, cache_mode=cache_mode, cache_line_size=cls, name="cache2"
) )
@ -261,7 +261,7 @@ def test_adding_core_already_used(pyocf_ctx, cache_mode, cls):
@pytest.mark.parametrize("cls", CacheLineSize) @pytest.mark.parametrize("cls", CacheLineSize)
def test_add_remove_incrementally(pyocf_ctx, cache_mode, cls): def test_add_remove_incrementally(pyocf_ctx, cache_mode, cls):
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls cache_device, cache_mode=cache_mode, cache_line_size=cls
) )

View File

@ -35,7 +35,7 @@ logger = logging.getLogger(__name__)
@pytest.mark.parametrize("cls", CacheLineSize) @pytest.mark.parametrize("cls", CacheLineSize)
@pytest.mark.parametrize("mode", [CacheMode.WB, CacheMode.WT, CacheMode.WO]) @pytest.mark.parametrize("mode", [CacheMode.WB, CacheMode.WT, CacheMode.WO])
@pytest.mark.parametrize("new_cache_size", [25, 45]) @pytest.mark.parametrize("new_cache_size", [80, 120])
def test_attach_different_size( def test_attach_different_size(
pyocf_ctx, new_cache_size, mode: CacheMode, cls: CacheLineSize pyocf_ctx, new_cache_size, mode: CacheMode, cls: CacheLineSize
): ):
@ -43,7 +43,7 @@ def test_attach_different_size(
attach cache with different size and trigger IO. Verify if occupancy thresold is attach cache with different size and trigger IO. Verify if occupancy thresold is
respected with both original and new cache device. respected with both original and new cache device.
""" """
cache_device = Volume(Size.from_MiB(35)) cache_device = Volume(Size.from_MiB(100))
core_device = Volume(Size.from_MiB(100)) core_device = Volume(Size.from_MiB(100))
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)
core = Core.using_device(core_device) core = Core.using_device(core_device)

View File

@ -17,7 +17,7 @@ from pyocf.types.shared import CacheLineSize
@pytest.mark.parametrize("cls", CacheLineSize) @pytest.mark.parametrize("cls", CacheLineSize)
def test_change_cache_mode(pyocf_ctx, from_cm, to_cm, cls): def test_change_cache_mode(pyocf_ctx, from_cm, to_cm, cls):
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_mode=from_cm, cache_line_size=cls cache_device, cache_mode=from_cm, cache_line_size=cls
) )
@ -32,7 +32,7 @@ def test_change_cache_mode(pyocf_ctx, from_cm, to_cm, cls):
@pytest.mark.parametrize("cls", CacheLineSize) @pytest.mark.parametrize("cls", CacheLineSize)
def test_change_cleaning_policy(pyocf_ctx, cm, cls): def test_change_cleaning_policy(pyocf_ctx, cm, cls):
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_mode=cm, cache_line_size=cls cache_device, cache_mode=cm, cache_line_size=cls
) )
@ -57,7 +57,7 @@ def test_change_cleaning_policy(pyocf_ctx, cm, cls):
@pytest.mark.parametrize("cls", CacheLineSize) @pytest.mark.parametrize("cls", CacheLineSize)
def test_cache_change_seq_cut_off_policy(pyocf_ctx, cm, cls): def test_cache_change_seq_cut_off_policy(pyocf_ctx, cm, cls):
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_mode=cm, cache_line_size=cls cache_device, cache_mode=cm, cache_line_size=cls
) )
@ -96,7 +96,7 @@ def test_cache_change_seq_cut_off_policy(pyocf_ctx, cm, cls):
@pytest.mark.parametrize("cls", CacheLineSize) @pytest.mark.parametrize("cls", CacheLineSize)
def test_core_change_seq_cut_off_policy(pyocf_ctx, cm, cls): def test_core_change_seq_cut_off_policy(pyocf_ctx, cm, cls):
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_mode=cm, cache_line_size=cls cache_device, cache_mode=cm, cache_line_size=cls
) )

View File

@ -26,7 +26,7 @@ def test_start_check_default(pyocf_ctx):
"""Test if default values are correct after start. """Test if default values are correct after start.
""" """
cache_device = Volume(Size.from_MiB(40)) cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(10)) core_device = Volume(Size.from_MiB(10))
cache = Cache.start_on_device(cache_device) cache = Cache.start_on_device(cache_device)
@ -50,7 +50,7 @@ def test_start_write_first_and_check_mode(pyocf_ctx, mode: CacheMode, cls: Cache
After start check proper cache mode behaviour, starting with write operation. After start check proper cache mode behaviour, starting with write operation.
""" """
cache_device = Volume(Size.from_MiB(40)) cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(10)) core_device = Volume(Size.from_MiB(10))
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)
core_exported = Core.using_device(core_device) core_exported = Core.using_device(core_device)
@ -88,7 +88,7 @@ def test_start_read_first_and_check_mode(pyocf_ctx, mode: CacheMode, cls: CacheL
After start check proper cache mode behaviour, starting with read operation. After start check proper cache mode behaviour, starting with read operation.
""" """
cache_device = Volume(Size.from_MiB(20)) cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(5)) core_device = Volume(Size.from_MiB(5))
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)
core_exported = Core.using_device(core_device) core_exported = Core.using_device(core_device)
@ -131,7 +131,7 @@ def test_start_params(pyocf_ctx, mode: CacheMode, cls: CacheLineSize, layout: Me
Check if cache starts without errors. Check if cache starts without errors.
If possible check whether cache reports properly set parameters. If possible check whether cache reports properly set parameters.
""" """
cache_device = Volume(Size.from_MiB(20)) cache_device = Volume(Size.from_MiB(50))
queue_size = randrange(60000, 2**32) queue_size = randrange(60000, 2**32)
unblock_size = randrange(1, queue_size) unblock_size = randrange(1, queue_size)
volatile_metadata = randrange(2) == 1 volatile_metadata = randrange(2) == 1
@ -169,7 +169,7 @@ def test_stop(pyocf_ctx, mode: CacheMode, cls: CacheLineSize, with_flush: bool):
Check if cache is stopped properly in different modes with or without preceding flush operation. Check if cache is stopped properly in different modes with or without preceding flush operation.
""" """
cache_device = Volume(Size.from_MiB(20)) cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(5)) core_device = Volume(Size.from_MiB(5))
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)
core_exported = Core.using_device(core_device) core_exported = Core.using_device(core_device)
@ -204,7 +204,7 @@ def test_start_stop_multiple(pyocf_ctx):
caches = [] caches = []
caches_no = randrange(6, 11) caches_no = randrange(6, 11)
for i in range(1, caches_no): for i in range(1, caches_no):
cache_device = Volume(Size.from_MiB(20)) cache_device = Volume(Size.from_MiB(50))
cache_name = f"cache{i}" cache_name = f"cache{i}"
cache_mode = CacheMode(randrange(0, len(CacheMode))) cache_mode = CacheMode(randrange(0, len(CacheMode)))
size = 4096 * 2**randrange(0, len(CacheLineSize)) size = 4096 * 2**randrange(0, len(CacheLineSize))
@ -236,7 +236,7 @@ def test_100_start_stop(pyocf_ctx):
""" """
for i in range(1, 101): for i in range(1, 101):
cache_device = Volume(Size.from_MiB(20)) cache_device = Volume(Size.from_MiB(50))
cache_name = f"cache{i}" cache_name = f"cache{i}"
cache_mode = CacheMode(randrange(0, len(CacheMode))) cache_mode = CacheMode(randrange(0, len(CacheMode)))
size = 4096 * 2**randrange(0, len(CacheLineSize)) size = 4096 * 2**randrange(0, len(CacheLineSize))
@ -271,7 +271,7 @@ def test_start_stop_incrementally(pyocf_ctx):
while run: while run:
if add: if add:
for i in range(0, randrange(3, 5) if increase else randrange(1, 3)): for i in range(0, randrange(3, 5) if increase else randrange(1, 3)):
cache_device = Volume(Size.from_MiB(20)) cache_device = Volume(Size.from_MiB(50))
cache_name = f"cache{next(counter)}" cache_name = f"cache{next(counter)}"
cache_mode = CacheMode(randrange(0, len(CacheMode))) cache_mode = CacheMode(randrange(0, len(CacheMode)))
size = 4096 * 2**randrange(0, len(CacheLineSize)) size = 4096 * 2**randrange(0, len(CacheLineSize))
@ -311,8 +311,8 @@ def test_start_cache_same_id(pyocf_ctx, mode, cls):
Check that OCF does not allow for 2 caches to be started with the same cache_name 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(50))
cache_device2 = Volume(Size.from_MiB(20)) cache_device2 = Volume(Size.from_MiB(50))
cache_name = "cache" cache_name = "cache"
cache = Cache.start_on_device(cache_device1, cache = Cache.start_on_device(cache_device1,
cache_mode=mode, cache_mode=mode,
@ -342,7 +342,7 @@ def test_start_cache_huge_device(pyocf_ctx_log_buffer, cls):
def submit_io(self, io): def submit_io(self, io):
io.contents._end(io, 0) io.contents._end(io, 0)
cache_device = HugeDevice(Size.from_MiB(20)) cache_device = HugeDevice(Size.from_MiB(50))
with pytest.raises(OcfError, match="OCF_ERR_INVAL_CACHE_DEV"): with pytest.raises(OcfError, match="OCF_ERR_INVAL_CACHE_DEV"):
cache = Cache.start_on_device(cache_device, cache_line_size=cls, metadata_volatile=True) cache = Cache.start_on_device(cache_device, cache_line_size=cls, metadata_volatile=True)
@ -360,7 +360,7 @@ def test_start_cache_same_device(pyocf_ctx, mode, cls):
Check that OCF does not allow for 2 caches using the same cache device to be started Check that OCF does not allow for 2 caches using the same cache device to be started
""" """
cache_device = Volume(Size.from_MiB(20)) cache_device = Volume(Size.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_mode=mode, cache_line_size=cls, name="cache1" cache_device, cache_mode=mode, cache_line_size=cls, name="cache1"
) )

View File

@ -41,7 +41,7 @@ def test_neg_change_cache_mode(pyocf_ctx, cm, cls):
:param cls: cache line size we start with :param cls: cache line size we start with
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Change cache mode to invalid one and check if failed # Change cache mode to invalid one and check if failed
@ -65,7 +65,7 @@ def test_neg_set_cleaning_policy(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Set cleaning policy to invalid one and check if failed # Set cleaning policy to invalid one and check if failed
@ -90,7 +90,7 @@ def test_neg_attach_cls(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache(owner=cache_device.owner, cache_mode=cm, cache_line_size=cls) cache = Cache(owner=cache_device.owner, cache_mode=cm, cache_line_size=cls)
cache.start_cache() cache.start_cache()
@ -115,7 +115,7 @@ def test_neg_cache_set_seq_cut_off_policy(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Create 2 core devices # Create 2 core devices
@ -149,7 +149,7 @@ def test_neg_cache_set_seq_cut_off_promotion(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Create 2 core devices # Create 2 core devices
@ -185,7 +185,7 @@ def test_neg_core_set_seq_cut_off_promotion(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Create core device # Create core device
@ -218,7 +218,7 @@ def test_neg_cache_set_seq_cut_off_threshold(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Create 2 core devices # Create 2 core devices
@ -254,7 +254,7 @@ def test_neg_core_set_seq_cut_off_threshold(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Create core device # Create core device
@ -287,7 +287,7 @@ def test_neg_core_set_seq_cut_off_policy(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Create core device # Create core device
@ -318,7 +318,7 @@ def test_neg_set_alru_param(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Change invalid alru param and check if failed # Change invalid alru param and check if failed
@ -355,7 +355,7 @@ def test_neg_set_alru_param_value(pyocf_ctx, cm, cls, param):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
cache.set_cleaning_policy(CleaningPolicy.ALRU) cache.set_cleaning_policy(CleaningPolicy.ALRU)
@ -382,7 +382,7 @@ def test_neg_set_acp_param(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Change invalid acp param and check if failed # Change invalid acp param and check if failed
@ -415,7 +415,7 @@ def test_neg_set_acp_param_value(pyocf_ctx, cm, cls, param):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
cache.set_cleaning_policy(CleaningPolicy.ACP) cache.set_cleaning_policy(CleaningPolicy.ACP)
@ -442,7 +442,7 @@ def test_neg_set_promotion_policy(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Change to invalid promotion policy and check if failed # Change to invalid promotion policy and check if failed
@ -466,7 +466,7 @@ def test_neg_set_nhit_promotion_policy_param(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_device,
cache_mode=cm, cache_mode=cm,
@ -496,7 +496,7 @@ def test_neg_set_nhit_promotion_policy_param_trigger(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_device,
cache_mode=cm, cache_mode=cm,
@ -528,7 +528,7 @@ def test_neg_set_nhit_promotion_policy_param_threshold(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_device,
cache_mode=cm, cache_mode=cm,
@ -559,7 +559,7 @@ def test_neg_set_ioclass_max_size(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Set invalid max size and check if failed # Set invalid max size and check if failed
@ -589,7 +589,7 @@ def test_neg_set_ioclass_priority(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Set invalid priority and check if failed # Set invalid priority and check if failed
@ -619,7 +619,7 @@ def test_neg_set_ioclass_cache_mode(pyocf_ctx, cm, cls):
:return: :return:
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls) cache = Cache.start_on_device(cache_device, cache_mode=cm, cache_line_size=cls)
# Set invalid cache mode and check if failed # Set invalid cache mode and check if failed
@ -644,7 +644,7 @@ def test_neg_set_ioclass_name(pyocf_ctx):
invalid_chars += [",", '"'] invalid_chars += [",", '"']
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_mode=CacheMode.WT, cache_line_size=CacheLineSize.LINE_4KiB cache_device, cache_mode=CacheMode.WT, cache_line_size=CacheLineSize.LINE_4KiB
) )
@ -669,7 +669,7 @@ def test_neg_set_ioclass_name_len(pyocf_ctx):
""" """
# Start cache device # Start cache device
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device( cache = Cache.start_on_device(
cache_device, cache_mode=CacheMode.WT, cache_line_size=CacheLineSize.LINE_4KiB cache_device, cache_mode=CacheMode.WT, cache_line_size=CacheLineSize.LINE_4KiB
) )

View File

@ -17,7 +17,7 @@ logger = logging.getLogger(__name__)
def try_start_cache(**config): def try_start_cache(**config):
cache_device = Volume(Size.from_MiB(30)) cache_device = Volume(Size.from_MiB(50))
cache = Cache.start_on_device(cache_device, **config) cache = Cache.start_on_device(cache_device, **config)
cache.stop() cache.stop()
@ -58,7 +58,7 @@ def test_fuzzy_start_name(pyocf_ctx, string_randomize, cm, cls):
:param cm: cache mode value to start cache with :param cm: cache mode value to start cache with
:param cls: cache line size value to start cache with :param cls: cache line size value to start cache with
""" """
cache_device = Volume(Size.from_MiB(30)) cache_device = Volume(Size.from_MiB(50))
incorrect_values = [''] incorrect_values = ['']
try: try:
cache = Cache.start_on_device(cache_device, name=string_randomize, cache_mode=cm, cache = Cache.start_on_device(cache_device, name=string_randomize, cache_mode=cm,

View File

@ -182,7 +182,7 @@ def test_neg_io_direction(pyocf_ctx, c_int_randomize):
assert completion.results["err"] != 0 assert completion.results["err"] != 0
def prepare_cache_and_core(core_size: Size, cache_size: Size = Size.from_MiB(20)): def prepare_cache_and_core(core_size: Size, cache_size: Size = Size.from_MiB(50)):
cache_device = Volume(cache_size) cache_device = Volume(cache_size)
core_device = Volume(core_size) core_device = Volume(core_size)

View File

@ -77,7 +77,7 @@ def test_secure_erase_simple_io_read_misses(cache_mode):
ctx.register_volume_type(Volume) ctx.register_volume_type(Volume)
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=cache_mode) cache = Cache.start_on_device(cache_device, cache_mode=cache_mode)
core_device = Volume(S.from_MiB(50)) core_device = Volume(S.from_MiB(50))
@ -170,7 +170,7 @@ def test_secure_erase_simple_io_cleaning():
ctx.register_volume_type(Volume) ctx.register_volume_type(Volume)
cache_device = Volume(S.from_MiB(30)) cache_device = Volume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, cache_mode=CacheMode.WB) cache = Cache.start_on_device(cache_device, cache_mode=CacheMode.WB)
core_device = Volume(S.from_MiB(100)) core_device = Volume(S.from_MiB(100))