pyocf: Rename Volume to RamVolume

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski
2021-10-19 14:46:06 +02:00
parent 062f63e4ff
commit 16f9d58f28
22 changed files with 198 additions and 196 deletions

View File

@@ -1,4 +1,5 @@
# Copyright(c) 2019-2021 Intel Corporation
#
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -8,7 +9,7 @@ from ctypes import c_int
from random import randint
from pyocf.types.cache import Cache, CacheMode
from pyocf.types.core import Core
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.types.data import Data
from pyocf.types.io import IoDir
from pyocf.utils import Size as S
@@ -19,13 +20,13 @@ from pyocf.types.shared import OcfError, OcfCompletion, CacheLineSize
@pytest.mark.parametrize("cls", CacheLineSize)
def test_adding_core(pyocf_ctx, cache_mode, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
# Check statistics before adding core
@@ -44,13 +45,13 @@ def test_adding_core(pyocf_ctx, cache_mode, cls):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_removing_core(pyocf_ctx, cache_mode, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
# Add core to cache
@@ -68,13 +69,13 @@ def test_removing_core(pyocf_ctx, cache_mode, cls):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_remove_dirty_no_flush(pyocf_ctx, cache_mode, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
cache.add_core(core)
@@ -90,11 +91,11 @@ def test_remove_dirty_no_flush(pyocf_ctx, cache_mode, cls):
def test_30add_remove(pyocf_ctx):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
# Add and remove core device in a loop 100 times
@@ -111,11 +112,11 @@ def test_30add_remove(pyocf_ctx):
def test_10add_remove_with_io(pyocf_ctx):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
# Add and remove core 10 times in a loop with io in between
@@ -143,7 +144,7 @@ def test_10add_remove_with_io(pyocf_ctx):
def test_add_remove_30core(pyocf_ctx):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device)
core_devices = []
core_amount = 30
@@ -152,7 +153,7 @@ def test_add_remove_30core(pyocf_ctx):
for i in range(0, core_amount):
stats = cache.get_stats()
assert stats["conf"]["core_count"] == i
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device, name=f"core{i}")
core_devices.append(core)
cache.add_core(core)
@@ -176,13 +177,13 @@ 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(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(cache_device, name=f"cache{i}")
cache_devices.append(cache)
# Create 50 core devices and add to random cache
for i in range(0, core_amount):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device, name=f"core{i}")
core_devices[core] = randint(0, cache_amount - 1)
cache_devices[core_devices[core]].add_core(core)
@@ -202,13 +203,13 @@ def test_adding_to_random_cache(pyocf_ctx):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_adding_core_twice(pyocf_ctx, cache_mode, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
# Add core
@@ -227,19 +228,19 @@ def test_adding_core_twice(pyocf_ctx, cache_mode, cls):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_adding_core_already_used(pyocf_ctx, cache_mode, cls):
# Start first cache device
cache_device1 = Volume(S.from_MiB(50))
cache_device1 = RamVolume(S.from_MiB(50))
cache1 = Cache.start_on_device(
cache_device1, cache_mode=cache_mode, cache_line_size=cls, name="cache1"
)
# Start second cache device
cache_device2 = Volume(S.from_MiB(50))
cache_device2 = RamVolume(S.from_MiB(50))
cache2 = Cache.start_on_device(
cache_device2, cache_mode=cache_mode, cache_line_size=cls, name="cache2"
)
# Create core device
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
# Add core to first cache
@@ -261,7 +262,7 @@ def test_adding_core_already_used(pyocf_ctx, cache_mode, cls):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_add_remove_incrementally(pyocf_ctx, cache_mode, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
@@ -270,7 +271,7 @@ def test_add_remove_incrementally(pyocf_ctx, cache_mode, cls):
# Create 5 core devices and add to cache
for i in range(0, core_amount):
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device, name=f"core{i}")
core_devices.append(core)
cache.add_core(core)
@@ -325,13 +326,13 @@ def test_try_add_core_with_changed_size(pyocf_ctx, cache_mode, cls):
:param cls: cache line size we start with
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
# Add core to cache
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
cache.add_core(core)
@@ -359,13 +360,13 @@ def test_load_with_changed_core_size(pyocf_ctx, cache_mode, cls):
:param cls: cache line size we start with
"""
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cache_mode, cache_line_size=cls
)
# Add core to cache
core_device = Volume(S.from_MiB(10))
core_device = RamVolume(S.from_MiB(10))
core = Core.using_device(core_device)
cache.add_core(core)

View File

@@ -1,5 +1,5 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -27,7 +27,7 @@ from pyocf.types.shared import (
CacheLineSize,
SeqCutOffPolicy,
)
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.utils import Size
logger = logging.getLogger(__name__)
@@ -43,8 +43,8 @@ def test_attach_different_size(
attach cache with different size and trigger IO. Verify if occupancy thresold is
respected with both original and new cache device.
"""
cache_device = Volume(Size.from_MiB(100))
core_device = Volume(Size.from_MiB(100))
cache_device = RamVolume(Size.from_MiB(100))
core_device = RamVolume(Size.from_MiB(100))
cache = Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)
core = Core.using_device(core_device)
cache.add_core(core)
@@ -70,7 +70,7 @@ def test_attach_different_size(
assert part_current_size.blocks_4k == cache_size.blocks_4k * 0.5
cache.detach_device()
new_cache_device = Volume(Size.from_MiB(new_cache_size))
new_cache_device = RamVolume(Size.from_MiB(new_cache_size))
cache.attach_device(new_cache_device, force=True)
cache_size = cache.get_stats()["conf"]["size"]

View File

@@ -1,5 +1,5 @@
#
# Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2019-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -7,7 +7,7 @@ import pytest
from pyocf.types.cache import Cache, CacheMode, CleaningPolicy, SeqCutOffPolicy
from pyocf.types.core import Core
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.utils import Size as S
from pyocf.types.shared import CacheLineSize
@@ -17,7 +17,7 @@ from pyocf.types.shared import CacheLineSize
@pytest.mark.parametrize("cls", CacheLineSize)
def test_change_cache_mode(pyocf_ctx, from_cm, to_cm, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
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)
def test_change_cleaning_policy(pyocf_ctx, cm, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cm, cache_line_size=cls
)
@@ -57,15 +57,15 @@ def test_change_cleaning_policy(pyocf_ctx, cm, cls):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_cache_change_seq_cut_off_policy(pyocf_ctx, cm, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cm, cache_line_size=cls
)
# Create 2 core devices
core_device1 = Volume(S.from_MiB(10))
core_device1 = RamVolume(S.from_MiB(10))
core1 = Core.using_device(core_device1, name="core1")
core_device2 = Volume(S.from_MiB(10))
core_device2 = RamVolume(S.from_MiB(10))
core2 = Core.using_device(core_device2, name="core2")
# Add cores
@@ -96,15 +96,15 @@ def test_cache_change_seq_cut_off_policy(pyocf_ctx, cm, cls):
@pytest.mark.parametrize("cls", CacheLineSize)
def test_core_change_seq_cut_off_policy(pyocf_ctx, cm, cls):
# Start cache device
cache_device = Volume(S.from_MiB(50))
cache_device = RamVolume(S.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=cm, cache_line_size=cls
)
# Create 2 core devices
core_device1 = Volume(S.from_MiB(10))
core_device1 = RamVolume(S.from_MiB(10))
core1 = Core.using_device(core_device1, name="core1")
core_device2 = Volume(S.from_MiB(10))
core_device2 = RamVolume(S.from_MiB(10))
core2 = Core.using_device(core_device2, name="core2")
# Add cores

View File

@@ -24,7 +24,7 @@ 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, SeqCutOffPolicy
from pyocf.types.volume import Volume
from pyocf.types.volume import RamVolume
from pyocf.utils import Size
logger = logging.getLogger(__name__)
@@ -34,8 +34,8 @@ def test_start_check_default(pyocf_ctx):
"""Test if default values are correct after start.
"""
cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(10))
cache_device = RamVolume(Size.from_MiB(50))
core_device = RamVolume(Size.from_MiB(10))
cache = Cache.start_on_device(cache_device)
core = Core.using_device(core_device)
@@ -58,8 +58,8 @@ 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.
"""
cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(10))
cache_device = RamVolume(Size.from_MiB(50))
core_device = RamVolume(Size.from_MiB(10))
cache = Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)
core_exported = Core.using_device(core_device)
@@ -96,8 +96,8 @@ 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.
"""
cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(5))
cache_device = RamVolume(Size.from_MiB(50))
core_device = RamVolume(Size.from_MiB(5))
cache = Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)
core_exported = Core.using_device(core_device)
@@ -139,7 +139,7 @@ def test_start_params(pyocf_ctx, mode: CacheMode, cls: CacheLineSize, layout: Me
Check if cache starts without errors.
If possible check whether cache reports properly set parameters.
"""
cache_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
queue_size = randrange(60000, 2**32)
unblock_size = randrange(1, queue_size)
volatile_metadata = randrange(2) == 1
@@ -176,8 +176,8 @@ 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.
"""
cache_device = Volume(Size.from_MiB(50))
core_device = Volume(Size.from_MiB(5))
cache_device = RamVolume(Size.from_MiB(50))
core_device = RamVolume(Size.from_MiB(5))
cache = Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)
core_exported = Core.using_device(core_device)
cache.add_core(core_exported)
@@ -211,7 +211,7 @@ def test_start_stop_multiple(pyocf_ctx):
caches = []
caches_no = randrange(6, 11)
for i in range(1, caches_no):
cache_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
cache_name = f"cache{i}"
cache_mode = CacheMode(randrange(0, len(CacheMode)))
size = 4096 * 2**randrange(0, len(CacheLineSize))
@@ -243,7 +243,7 @@ def test_100_start_stop(pyocf_ctx):
"""
for i in range(1, 101):
cache_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
cache_name = f"cache{i}"
cache_mode = CacheMode(randrange(0, len(CacheMode)))
size = 4096 * 2**randrange(0, len(CacheLineSize))
@@ -278,7 +278,7 @@ def test_start_stop_incrementally(pyocf_ctx):
while run:
if add:
for i in range(0, randrange(3, 5) if increase else randrange(1, 3)):
cache_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
cache_name = f"cache{next(counter)}"
cache_mode = CacheMode(randrange(0, len(CacheMode)))
size = 4096 * 2**randrange(0, len(CacheLineSize))
@@ -318,8 +318,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
"""
cache_device1 = Volume(Size.from_MiB(50))
cache_device2 = Volume(Size.from_MiB(50))
cache_device1 = RamVolume(Size.from_MiB(50))
cache_device2 = RamVolume(Size.from_MiB(50))
cache_name = "cache"
cache = Cache.start_on_device(cache_device1,
cache_mode=mode,
@@ -342,7 +342,7 @@ def test_start_cache_huge_device(pyocf_ctx_log_buffer, cls):
pass_criteria:
- Starting cache on device too big to handle should fail
"""
class HugeDevice(Volume):
class HugeDevice(RamVolume):
def get_length(self):
return Size.from_B((cls * c_uint32(-1).value))
@@ -367,7 +367,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
"""
cache_device = Volume(Size.from_MiB(50))
cache_device = RamVolume(Size.from_MiB(50))
cache = Cache.start_on_device(
cache_device, cache_mode=mode, cache_line_size=cls, name="cache1"
)
@@ -387,7 +387,7 @@ def test_start_too_small_device(pyocf_ctx, mode, cls):
Check if starting cache with device below minimum size is blocked
"""
cache_device = Volume(Size.from_B(20 * 1024 * 1024 - 1))
cache_device = RamVolume(Size.from_B(20 * 1024 * 1024 - 1))
with pytest.raises(OcfError, match="OCF_ERR_INVAL_CACHE_DEV"):
Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)