From fce070cacecbdc22802c42efd1376a6522e227df Mon Sep 17 00:00:00 2001 From: Krzysztof Majzerowicz-Jaszcz Date: Wed, 6 Jul 2022 15:55:12 +0200 Subject: [PATCH] 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 --- ocf | 2 +- test/functional/api/cas/dmesg.py | 10 +++++----- test/functional/tests/cli/test_cli_standby.py | 3 +-- .../test_fault_injection_standby.py | 2 +- test/functional/tests/trim/test_trim.py | 20 ++++--------------- 5 files changed, 12 insertions(+), 25 deletions(-) diff --git a/ocf b/ocf index 2defff1..eb5f4f7 160000 --- a/ocf +++ b/ocf @@ -1 +1 @@ -Subproject commit 2defff1da0cd2a54591d11506b448753e00f4939 +Subproject commit eb5f4f79e4c3f7c783aa6578b8f057353e685702 diff --git a/test/functional/api/cas/dmesg.py b/test/functional/api/cas/dmesg.py index 344c129..9d022e7 100644 --- a/test/functional/api/cas/dmesg.py +++ b/test/functional/api/cas/dmesg.py @@ -8,13 +8,13 @@ import re 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"): - if "Metadata capacity:" in s: - size = re.search("[0-9]* MiB", s).group() - return Size(int(re.search("[0-9]*", size).group()), Unit.MebiByte) + m = re.search(r'Metadata size on device: ([0-9]*) kiB', s) + if m: + 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): diff --git a/test/functional/tests/cli/test_cli_standby.py b/test/functional/tests/cli/test_cli_standby.py index 42a237b..38d9378 100644 --- a/test/functional/tests/cli/test_cli_standby.py +++ b/test/functional/tests/cli/test_cli_standby.py @@ -404,13 +404,12 @@ def test_activate_neg_cache_line_size(): with TestRun.step("Create dump file with cache metadata"): with TestRun.step("Get metadata size"): 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"): dump_file_path = "/tmp/test_activate_corrupted.dump" md_dump = File(dump_file_path) md_dump.remove(force=True, ignore_errors=True) - dd_count = int(md_size / Size(1, Unit.MebiByte)) + 1 ( Dd().input(active_cache_dev.path) diff --git a/test/functional/tests/fault_injection/test_fault_injection_standby.py b/test/functional/tests/fault_injection/test_fault_injection_standby.py index 5339b9d..e83e185 100644 --- a/test/functional/tests/fault_injection/test_fault_injection_standby.py +++ b/test/functional/tests/fault_injection/test_fault_injection_standby.py @@ -207,7 +207,7 @@ def prepare_md_dump(cache_device, core_device, cls, cache_id): with TestRun.step("Get metadata size"): 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"): dump_file_path = "/tmp/test_activate_corrupted.dump" diff --git a/test/functional/tests/trim/test_trim.py b/test/functional/tests/trim/test_trim.py index ae1095b..f7bb0d1 100644 --- a/test/functional/tests/trim/test_trim.py +++ b/test/functional/tests/trim/test_trim.py @@ -1,5 +1,5 @@ # -# Copyright(c) 2020-2021 Intel Corporation +# Copyright(c) 2020-2022 Intel Corporation # SPDX-License-Identifier: BSD-3-Clause # @@ -7,6 +7,7 @@ import pytest import re from api.cas import casadm +from api.cas.dmesg import get_metadata_size_on_device from core.test_run import TestRun from test_utils import os_utils from test_utils.size import Size, Unit @@ -51,7 +52,8 @@ def test_trim_start_discard(): with TestRun.step("Starting cache"): 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"): cache_reqs = blktrace.stop_monitoring() @@ -90,17 +92,3 @@ def write_pattern(device): .direct() .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)