Merge pull request #1269 from kmajzero/fix_test_with_metadata_size_calculation
Fix for tests using get_metadata_size()
This commit is contained in:
commit
dc027bd368
2
ocf
2
ocf
@ -1 +1 @@
|
||||
Subproject commit 2defff1da0cd2a54591d11506b448753e00f4939
|
||||
Subproject commit eb5f4f79e4c3f7c783aa6578b8f057353e685702
|
@ -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):
|
||||
|
@ -405,13 +405,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)
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user