tests: fault_injection: Fix block to request calculation
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
This commit is contained in:
parent
783e0229a5
commit
779d9e96b4
@ -5,6 +5,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import math
|
||||||
from api.cas import casadm
|
from api.cas import casadm
|
||||||
from api.cas.cache_config import (
|
from api.cas.cache_config import (
|
||||||
CacheMode,
|
CacheMode,
|
||||||
@ -76,26 +77,18 @@ def test_cache_insert_error(cache_mode, block_size):
|
|||||||
if occupancy != 0:
|
if occupancy != 0:
|
||||||
TestRun.fail(f"Occupancy is not zero, but {occupancy}")
|
TestRun.fail(f"Occupancy is not zero, but {occupancy}")
|
||||||
|
|
||||||
# Convert cache writes from bytes to I/O count, assuming cache I/O is sent
|
# Convert cache writes from bytes to I/O count.
|
||||||
# with cacheline granularity.
|
# Cache errors are accounted with request granularity.
|
||||||
cache_writes_per_block = max(block_size.get_value() // int(cache_line_size), 1)
|
# Blocks are expressed with 4k granularity.
|
||||||
cache_writes = stats.block_stats.cache.writes / block_size * cache_writes_per_block
|
correction = int(math.ceil(Size(1, Unit.Blocks4096) / block_size))
|
||||||
|
cache_writes_upper = int(stats.block_stats.cache.writes / block_size)
|
||||||
|
cache_writes_lower = cache_writes_upper - correction + 1
|
||||||
cache_errors = stats.error_stats.cache.total
|
cache_errors = stats.error_stats.cache.total
|
||||||
|
|
||||||
# Cache error count is accurate, however cache writes is rounded up to 4K in OCF.
|
if not cache_writes_lower <= cache_errors <= cache_writes_upper:
|
||||||
# Need to take this into account and round up cache errors accordingly for the
|
|
||||||
# comparison.
|
|
||||||
cache_writes_accuracy = max(Size(4, Unit.KibiByte) / block_size, 1)
|
|
||||||
rounded_cache_errors = (
|
|
||||||
(cache_errors + cache_writes_accuracy - 1)
|
|
||||||
// cache_writes_accuracy
|
|
||||||
* cache_writes_accuracy
|
|
||||||
)
|
|
||||||
if cache_writes != rounded_cache_errors:
|
|
||||||
TestRun.fail(
|
TestRun.fail(
|
||||||
f"Cache errors ({rounded_cache_errors}) should equal to number of"
|
f"Cache errors ({cache_errors}) should equal to number of"
|
||||||
f" requests to cache ({cache_writes})"
|
f" requests to cache (range {cache_writes_lower}-{cache_writes_upper})"
|
||||||
)
|
)
|
||||||
|
|
||||||
if cache_mode not in CacheMode.with_traits(CacheModeTrait.LazyWrites):
|
if cache_mode not in CacheMode.with_traits(CacheModeTrait.LazyWrites):
|
||||||
@ -147,9 +140,12 @@ def test_error_cache_verify_core(cache_mode, block_size):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrizex("cache_mode", CacheMode.with_traits(CacheModeTrait.LazyWrites))
|
@pytest.mark.parametrizex("cache_mode", CacheMode.with_traits(CacheModeTrait.LazyWrites))
|
||||||
|
@pytest.mark.parametrizex(
|
||||||
|
"block_size", [start_size, Size(1024, Unit.Byte), Size(4, Unit.KibiByte), stop_size]
|
||||||
|
)
|
||||||
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
@pytest.mark.require_disk("cache", DiskTypeSet([DiskType.optane, DiskType.nand]))
|
||||||
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
@pytest.mark.require_disk("core", DiskTypeLowerThan("cache"))
|
||||||
def test_cache_write_lazy_insert_error(cache_mode):
|
def test_cache_write_lazy_insert_error(cache_mode, block_size):
|
||||||
"""
|
"""
|
||||||
title: Cache insert test with error device for writes on lazy writes cache mode
|
title: Cache insert test with error device for writes on lazy writes cache mode
|
||||||
description: |
|
description: |
|
||||||
@ -170,7 +166,7 @@ def test_cache_write_lazy_insert_error(cache_mode):
|
|||||||
.create_command()
|
.create_command()
|
||||||
.io_engine(IoEngine.libaio)
|
.io_engine(IoEngine.libaio)
|
||||||
.size(core.size)
|
.size(core.size)
|
||||||
.blocksize_range([(start_size.get_value(), stop_size.get_value())])
|
.block_size(block_size)
|
||||||
.read_write(ReadWrite.randwrite)
|
.read_write(ReadWrite.randwrite)
|
||||||
.target(core)
|
.target(core)
|
||||||
.continue_on_error(ErrorFilter.io)
|
.continue_on_error(ErrorFilter.io)
|
||||||
@ -188,13 +184,18 @@ def test_cache_write_lazy_insert_error(cache_mode):
|
|||||||
if occupancy != 0:
|
if occupancy != 0:
|
||||||
TestRun.fail(f"Occupancy is not zero, but {occupancy}")
|
TestRun.fail(f"Occupancy is not zero, but {occupancy}")
|
||||||
|
|
||||||
cache_writes = stats.block_stats.cache.writes / cache_line_size.value
|
# Convert cache writes from bytes to I/O count.
|
||||||
|
# Cache errors are accounted with request granularity.
|
||||||
|
# Blocks are expressed with 4k granularity.
|
||||||
|
correction = int(math.ceil(Size(1, Unit.Blocks4096) / block_size))
|
||||||
|
cache_writes_upper = int(stats.block_stats.cache.writes / block_size)
|
||||||
|
cache_writes_lower = cache_writes_upper - correction + 1
|
||||||
cache_errors = stats.error_stats.cache.total
|
cache_errors = stats.error_stats.cache.total
|
||||||
|
|
||||||
if cache_writes != cache_errors:
|
if not cache_writes_lower <= cache_errors <= cache_writes_upper:
|
||||||
TestRun.fail(
|
TestRun.fail(
|
||||||
f"Cache errors ({cache_errors}) should equal to number of requests to"
|
f"Cache errors ({cache_errors}) should equal to number of"
|
||||||
f" cache ({cache_writes})"
|
f" requests to cache (range {cache_writes_lower}-{cache_writes_upper})"
|
||||||
)
|
)
|
||||||
|
|
||||||
state = cache.get_status()
|
state = cache.get_status()
|
||||||
|
Loading…
Reference in New Issue
Block a user