Check for FLUSH and FUA signals sent to cache device in lazy-write modes

Add test for checking for logs of requests insyslog from OpenCAS
when SCSI_DEBUG module is cache device.

Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
This commit is contained in:
Slawomir Jankowski 2020-05-28 18:51:58 +02:00
parent 153eb19c9b
commit c01956d0e1

View File

@ -121,6 +121,103 @@ def test_flush_signal_core(cache_mode):
cache.stop()
@pytest.mark.require_plugin("scsi_debug_fua_signals", dev_size_mb="2048", opts="1")
@pytest.mark.parametrize("cache_mode", CacheMode.with_traits(CacheModeTrait.LazyWrites))
@pytest.mark.require_disk("core", DiskTypeSet([DiskType.hdd, DiskType.hdd4k, DiskType.sata]))
def test_flush_signal_cache(cache_mode):
"""
title: Test for FLUSH and FUA signals sent to cache device in modes with lazy writes.
description: |
Test if OpenCAS transmits FLUSH and FUA signals to cache device in modes with lazy writes.
pass_criteria:
- FLUSH requests should be passed to cache device.
- FUA requests should be passed to cache device.
"""
with TestRun.step("Set mark in syslog to not read entries existing before the test."):
Logs._read_syslog(Logs.last_read_line)
with TestRun.step("Prepare devices for cache and core."):
core_dev = TestRun.disks['core']
core_dev.create_partitions([Size(4, Unit.GibiByte)])
core_part = core_dev.partitions[0]
cache_dev = TestRun.scsi_debug_devices[0]
with TestRun.step("Start SCSI device as cache and add core with xfs filesystem."):
cache = casadm.start_cache(cache_dev, cache_mode)
core_part.create_filesystem(Filesystem.xfs)
core = cache.add_core(core_part)
with TestRun.step("Mount exported object."):
if core.is_mounted():
core.unmount()
core.mount(mount_point)
with TestRun.step("Turn off cleaning policy."):
cache.set_cleaning_policy(CleaningPolicy.nop)
with TestRun.step("Create temporary file on exported object."):
tmp_file = create_random_test_file(f"{mount_point}/tmp.file", Size(1, Unit.GibiByte))
os_utils.sync()
with TestRun.step("Flush cache."):
cache.flush_cache()
os_utils.sync()
with TestRun.step(f"Check {syslog_path} for flush and FUA requests and delete temporary file."):
Logs.check_syslog_for_signals()
tmp_file.remove(True)
with TestRun.step("Create temporary file on exported object."):
tmp_file = create_random_test_file(f"{mount_point}/tmp.file", Size(1, Unit.GibiByte))
os_utils.sync()
with TestRun.step("Flush core."):
core.flush_core()
os_utils.sync()
with TestRun.step(f"Check {syslog_path} for flush request and delete temporary file."):
Logs.check_syslog_for_signals()
tmp_file.remove(True)
with TestRun.step("Turn on alru cleaning policy and set policy params."):
cache.set_cleaning_policy(CleaningPolicy.alru)
cache.set_params_alru(FlushParametersAlru(
Time(milliseconds=5000), 10000, Time(seconds=10), Time(seconds=10))
)
with TestRun.step("Create big temporary file on exported object."):
tmp_file = create_random_test_file(f"{mount_point}/tmp.file", Size(5, Unit.GibiByte))
os_utils.sync()
with TestRun.step("Wait for automatic flush from alru cleaning policy and check log."):
wait_time = (
int(cache.get_flush_parameters_alru().staleness_time.total_seconds())
+ int(cache.get_flush_parameters_alru().activity_threshold.total_seconds())
+ int(cache.get_flush_parameters_alru().wake_up_time.total_seconds())
+ 5
)
sleep(wait_time)
with TestRun.step(f"Check {syslog_path} for flush and FUA requests and delete temporary file."):
Logs.check_syslog_for_signals()
tmp_file.remove(True)
with TestRun.step("Create temporary file on exported object."):
create_random_test_file(f"{mount_point}/tmp.file", Size(1, Unit.GibiByte))
os_utils.sync()
with TestRun.step("Unmount exported object and remove it from cache."):
core.unmount()
core.remove_core()
os_utils.sync()
with TestRun.step(f"Check {syslog_path} for flush and FUA requests."):
Logs.check_syslog_for_signals()
with TestRun.step("Stop cache."):
cache.stop()
class Logs:
last_read_line = 1
FLUSH = re.compile(r"scsi_debug:[\s\S]*cmd 35")