Fix for tests using get_metadata_size()

Since OCF has changed how metadata size is reported (OCF PR #744),
get_metadata_size() became get_metadata_size_on_device() and tests
using it are changed accordingly.

OCF version with required changes included in this commit

Signed-off-by: Krzysztof Majzerowicz-Jaszcz <krzysztof.majzerowicz-jaszcz@intel.com>
This commit is contained in:
Krzysztof Majzerowicz-Jaszcz 2022-07-06 15:55:12 +02:00
parent ede99f4db4
commit fce070cace
5 changed files with 12 additions and 25 deletions

2
ocf

@ -1 +1 @@
Subproject commit 2defff1da0cd2a54591d11506b448753e00f4939 Subproject commit eb5f4f79e4c3f7c783aa6578b8f057353e685702

View File

@ -8,13 +8,13 @@ import re
from test_utils.size import Size, Unit from test_utils.size import Size, Unit
def get_metadata_size(dmesg): def get_metadata_size_on_device(dmesg):
for s in dmesg.split("\n"): for s in dmesg.split("\n"):
if "Metadata capacity:" in s: m = re.search(r'Metadata size on device: ([0-9]*) kiB', s)
size = re.search("[0-9]* MiB", s).group() if m:
return Size(int(re.search("[0-9]*", size).group()), Unit.MebiByte) return Size(int(m.groups()[0]), Unit.KibiByte)
raise ValueError("Can't find the metadata size in the privded dmesg output") raise ValueError("Can't find the metadata size in the provided dmesg output")
def _get_metadata_info(dmesg, section_name): def _get_metadata_info(dmesg, section_name):

View File

@ -404,13 +404,12 @@ def test_activate_neg_cache_line_size():
with TestRun.step("Create dump file with cache metadata"): with TestRun.step("Create dump file with cache metadata"):
with TestRun.step("Get metadata size"): with TestRun.step("Get metadata size"):
dmesg_out = TestRun.executor.run_expect_success("dmesg").stdout dmesg_out = TestRun.executor.run_expect_success("dmesg").stdout
md_size = dmesg.get_metadata_size(dmesg_out) md_size = dmesg.get_metadata_size_on_device(dmesg_out)
with TestRun.step("Dump the metadata of the cache"): with TestRun.step("Dump the metadata of the cache"):
dump_file_path = "/tmp/test_activate_corrupted.dump" dump_file_path = "/tmp/test_activate_corrupted.dump"
md_dump = File(dump_file_path) md_dump = File(dump_file_path)
md_dump.remove(force=True, ignore_errors=True) md_dump.remove(force=True, ignore_errors=True)
dd_count = int(md_size / Size(1, Unit.MebiByte)) + 1 dd_count = int(md_size / Size(1, Unit.MebiByte)) + 1
( (
Dd().input(active_cache_dev.path) Dd().input(active_cache_dev.path)

View File

@ -207,7 +207,7 @@ def prepare_md_dump(cache_device, core_device, cls, cache_id):
with TestRun.step("Get metadata size"): with TestRun.step("Get metadata size"):
dmesg_out = TestRun.executor.run_expect_success("dmesg").stdout dmesg_out = TestRun.executor.run_expect_success("dmesg").stdout
md_size = dmesg.get_metadata_size(dmesg_out) md_size = dmesg.get_metadata_size_on_device(dmesg_out)
with TestRun.step("Dump the metadata of the cache"): with TestRun.step("Dump the metadata of the cache"):
dump_file_path = "/tmp/test_activate_corrupted.dump" dump_file_path = "/tmp/test_activate_corrupted.dump"

View File

@ -1,5 +1,5 @@
# #
# Copyright(c) 2020-2021 Intel Corporation # Copyright(c) 2020-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
@ -7,6 +7,7 @@ import pytest
import re import re
from api.cas import casadm from api.cas import casadm
from api.cas.dmesg import get_metadata_size_on_device
from core.test_run import TestRun from core.test_run import TestRun
from test_utils import os_utils from test_utils import os_utils
from test_utils.size import Size, Unit from test_utils.size import Size, Unit
@ -51,7 +52,8 @@ def test_trim_start_discard():
with TestRun.step("Starting cache"): with TestRun.step("Starting cache"):
cache = casadm.start_cache(cas_part, force=True) cache = casadm.start_cache(cas_part, force=True)
metadata_size = get_metadata_size_from_dmesg() dmesg_out = TestRun.executor.run_expect_success("dmesg").stdout
metadata_size = get_metadata_size_on_device(dmesg_out)
with TestRun.step("Stop blktrace and check if discard requests were issued"): with TestRun.step("Stop blktrace and check if discard requests were issued"):
cache_reqs = blktrace.stop_monitoring() cache_reqs = blktrace.stop_monitoring()
@ -90,17 +92,3 @@ def write_pattern(device):
.direct() .direct()
.verification_with_pattern() .verification_with_pattern()
) )
def get_metadata_size_from_dmesg():
dmesg_out = TestRun.executor.run_expect_success("dmesg").stdout
for s in dmesg_out.split("\n"):
if "Hash offset" in s:
offset = re.search("[0-9]* kiB", s).group()
offset = Size(int(re.search("[0-9]*", offset).group()), Unit.KibiByte)
if "Hash size" in s:
size = re.search("[0-9]* kiB", s).group()
size = Size(int(re.search("[0-9]*", size).group()), Unit.KibiByte)
# Metadata is 128KiB aligned
return (offset + size).align_up(128 * Unit.KibiByte.value)