def flush_cache(cache_id): casadm.flush(cache_id=cache_id) sync() casadm.reset_counters(cache_id=cache_id) stats = casadm_parser.get_statistics(cache_id=cache_id, filter=[StatsFilter.blk]) for key, value in stats.items(): assert value.get_value(Unit.Blocks4096) == 0
def test_write_fetch_partial_misses(cache_mode, cache_line_size): """ title: No caching of partial write miss operations description: | Validate CAS ability to not cache entire cache line size for partial write miss operations pass_criteria: - Appropriate number of write partial misses, write hits and writes to cache in cache statistics - Appropriate number of writes to cache in iostat """ pattern = f"0x{uuid.uuid4().hex}" io_size = Size(600, Unit.MebiByte) with TestRun.step("Prepare devices."): cache_disk = TestRun.disks['cache'] core_disk = TestRun.disks['core'] core_disk.create_partitions([io_size + Size(1, Unit.MebiByte)]) core_part = core_disk.partitions[0] with TestRun.step("Fill core partition with pattern."): cache_mode_traits = CacheMode.get_traits(cache_mode) if CacheModeTrait.InsertRead in cache_mode_traits: run_fio(target=core_part.path, operation_type=ReadWrite.write, blocksize=Size(4, Unit.KibiByte), io_size=io_size, verify=True, pattern=pattern) else: TestRun.LOGGER.info(f"Skipped for {cache_mode} cache mode.") with TestRun.step("Start cache and add core."): cache = casadm.start_cache(cache_disk, cache_mode, cache_line_size) Udev.disable() core = cache.add_core(core_part) with TestRun.step("Cache half of file."): operation_type = ReadWrite.read if CacheModeTrait.InsertRead in cache_mode_traits \ else ReadWrite.write run_fio(target=core.path, operation_type=operation_type, skip=cache_line_size.value, blocksize=cache_line_size.value, io_size=io_size, verify=True, pattern=pattern) if CacheModeTrait.InsertRead not in cache_mode_traits: cache.flush_cache() casadm.reset_counters(cache.cache_id, core.core_id) with TestRun.step("Run writes to CAS device using fio."): io_stats_before_io = cache_disk.get_io_stats() blocksize = cache_line_size.value / 2 * 3 skip_size = cache_line_size.value / 2 run_fio(target=core.path, operation_type=ReadWrite.write, skip=skip_size, blocksize=blocksize, io_size=io_size) with TestRun.step( "Verify CAS statistics for partial misses, write hits and writes to cache." ): check_statistics(cache=cache, blocksize=blocksize, skip_size=skip_size, io_size=io_size, partial_misses=True) with TestRun.step( "Verify number of writes to cache device using iostat. Shall be 0.75 of " f"io size ({str(io_size * 0.75)}) + metadata for cache mode with write " f"insert feature."): check_io_stats(cache_disk=cache_disk, cache=cache, io_stats_before=io_stats_before_io, io_size=io_size, blocksize=blocksize, skip_size=skip_size)
def reset_counters(self): return casadm.reset_counters(self.cache_id, self.core_id)