functional tests: only send sector-aligned IO

... to satisfy OCF assumptions.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski 2019-06-06 16:03:03 -04:00
parent 31ab2b3fe6
commit 4a548d26cf
2 changed files with 14 additions and 8 deletions

View File

@ -107,7 +107,13 @@ class Data:
@classmethod @classmethod
def from_string(cls, source: str, encoding: str = "ascii"): 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 @staticmethod
@DataOps.ALLOC @DataOps.ALLOC

View File

@ -62,11 +62,11 @@ def test_start_write_first_and_check_mode(pyocf_ctx, mode: CacheMode, cls: Cache
core_device.reset_stats() core_device.reset_stats()
test_data = Data.from_string("This is test data") 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) check_stats_write_empty(core_exported, mode, cls)
logger.info("[STAGE] Read from exported object after initial write") 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) check_stats_read_after_write(core_exported, mode, cls, True)
logger.info("[STAGE] Write to exported object after read") 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") 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_stats_write_after_read(core_exported, mode, cls)
check_md5_sums(core_exported, mode) 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") logger.info("[STAGE] Initial write to core device")
test_data = Data.from_string("This is test data") 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() cache_device.reset_stats()
core_device.reset_stats() core_device.reset_stats()
logger.info("[STAGE] Initial read from exported object") 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) check_stats_read_empty(core_exported, mode, cls)
logger.info("[STAGE] Write to exported object after initial read") 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") 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) check_stats_write_after_read(core_exported, mode, cls, True)
logger.info("[STAGE] Read from exported object after write") 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_stats_read_after_write(core_exported, mode, cls)
check_md5_sums(core_exported, mode) check_md5_sums(core_exported, mode)