From 4a548d26cfb4e96a348f5436ecc75090c7ab1414 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Thu, 6 Jun 2019 16:03:03 -0400 Subject: [PATCH] functional tests: only send sector-aligned IO ... to satisfy OCF assumptions. Signed-off-by: Adam Rutkowski --- tests/functional/pyocf/types/data.py | 8 +++++++- .../functional/tests/management/test_start_stop.py | 14 +++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/functional/pyocf/types/data.py b/tests/functional/pyocf/types/data.py index c4054c6..3c49f46 100644 --- a/tests/functional/pyocf/types/data.py +++ b/tests/functional/pyocf/types/data.py @@ -107,7 +107,13 @@ class Data: @classmethod def from_string(cls, source: str, encoding: str = "ascii"): - return cls.from_bytes(bytes(source, encoding)) + b = bytes(source, encoding) + # duplicate string to fill space up to sector boundary + padding_len = S.from_B(len(b), sector_aligned = True).B - len(b) + padding = b * (padding_len // len(b) + 1) + padding = padding[:padding_len] + b = b + padding + return cls.from_bytes(b) @staticmethod @DataOps.ALLOC diff --git a/tests/functional/tests/management/test_start_stop.py b/tests/functional/tests/management/test_start_stop.py index 550fe42..648f3e0 100644 --- a/tests/functional/tests/management/test_start_stop.py +++ b/tests/functional/tests/management/test_start_stop.py @@ -62,11 +62,11 @@ def test_start_write_first_and_check_mode(pyocf_ctx, mode: CacheMode, cls: Cache core_device.reset_stats() test_data = Data.from_string("This is test data") - io_to_core(core_exported, test_data, 20) + io_to_core(core_exported, test_data, Size.from_sector(1).B) check_stats_write_empty(core_exported, mode, cls) logger.info("[STAGE] Read from exported object after initial write") - io_from_exported_object(core_exported, test_data.size, 20) + io_from_exported_object(core_exported, test_data.size, Size.from_sector(1).B) check_stats_read_after_write(core_exported, mode, cls, True) logger.info("[STAGE] Write to exported object after read") @@ -75,7 +75,7 @@ def test_start_write_first_and_check_mode(pyocf_ctx, mode: CacheMode, cls: Cache test_data = Data.from_string("Changed test data") - io_to_core(core_exported, test_data, 20) + io_to_core(core_exported, test_data, Size.from_sector(1).B) check_stats_write_after_read(core_exported, mode, cls) check_md5_sums(core_exported, mode) @@ -97,13 +97,13 @@ def test_start_read_first_and_check_mode(pyocf_ctx, mode: CacheMode, cls: CacheL logger.info("[STAGE] Initial write to core device") test_data = Data.from_string("This is test data") - io_to_core(core_exported, test_data, 20, True) + io_to_core(core_exported, test_data, Size.from_sector(1).B, True) cache_device.reset_stats() core_device.reset_stats() logger.info("[STAGE] Initial read from exported object") - io_from_exported_object(core_exported, test_data.size, 20) + io_from_exported_object(core_exported, test_data.size, Size.from_sector(1).B) check_stats_read_empty(core_exported, mode, cls) logger.info("[STAGE] Write to exported object after initial read") @@ -112,11 +112,11 @@ def test_start_read_first_and_check_mode(pyocf_ctx, mode: CacheMode, cls: CacheL test_data = Data.from_string("Changed test data") - io_to_core(core_exported, test_data, 20) + io_to_core(core_exported, test_data, Size.from_sector(1).B) check_stats_write_after_read(core_exported, mode, cls, True) logger.info("[STAGE] Read from exported object after write") - io_from_exported_object(core_exported, test_data.size, 20) + io_from_exported_object(core_exported, test_data.size, Size.from_sector(1).B) check_stats_read_after_write(core_exported, mode, cls) check_md5_sums(core_exported, mode)