tests: reformat test_trim_eviction

This commit doesn't introduce any changes to the flow of the tests.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk 2022-06-17 11:18:17 +02:00
parent 9ad1d878a2
commit 67aac6de1d

View File

@ -38,11 +38,11 @@ def test_trim_eviction(cache_mode, cache_line_size, filesystem, cleaning):
test_file_path = os.path.join(mount_point, "test_file")
with TestRun.step("Prepare devices."):
cache_disk = TestRun.disks['cache']
cache_disk = TestRun.disks["cache"]
cache_disk.create_partitions([Size(1, Unit.GibiByte)])
cache_dev = cache_disk.partitions[0]
core_disk = TestRun.disks['core']
core_disk = TestRun.disks["core"]
core_disk.create_partitions([Size(1, Unit.GibiByte)])
core_dev = core_disk.partitions[0]
@ -76,7 +76,9 @@ def test_trim_eviction(cache_mode, cache_line_size, filesystem, cleaning):
with TestRun.step("Remove file and create a new one."):
cache_iostats_before = cache_dev.get_io_stats()
data_reads_before = cache.get_io_class_statistics(io_class_id=0).block_stats.cache.reads
metadata_reads_before = cache.get_io_class_statistics(io_class_id=1).block_stats.cache.reads
metadata_reads_before = cache.get_io_class_statistics(
io_class_id=1
).block_stats.cache.reads
test_file.remove()
os_utils.sync()
os_utils.drop_caches()
@ -106,16 +108,19 @@ def test_trim_eviction(cache_mode, cache_line_size, filesystem, cleaning):
)
else:
TestRun.LOGGER.info(
"Number of reads from cache before and after removing test file is the same.")
"Number of reads from cache before and after removing test file is the same."
)
def create_file_with_ddrescue(core_dev, test_file_path):
dd = Dd() \
.block_size(Size(1, Unit.MebiByte)) \
.count(900) \
.input("/dev/urandom") \
.output(test_file_path) \
dd = (
Dd()
.block_size(Size(1, Unit.MebiByte))
.count(900)
.input("/dev/urandom")
.output(test_file_path)
.oflag("sync")
)
dd.run()
return File(test_file_path)