From 5226f62cf26372e1422aac216e44646577ace8c0 Mon Sep 17 00:00:00 2001 From: Kamil Gierszewski Date: Wed, 30 Oct 2024 00:42:42 +0100 Subject: [PATCH 1/6] test-framework: Make BaseLogResult comparable Signed-off-by: Kamil Gierszewski --- log/base_log.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/log/base_log.py b/log/base_log.py index 0f717a4..29c5b60 100644 --- a/log/base_log.py +++ b/log/base_log.py @@ -1,13 +1,14 @@ # # Copyright(c) 2019-2021 Intel Corporation +# Copyright(c) 2024 Huawei Technologies # SPDX-License-Identifier: BSD-3-Clause # -from enum import Enum +from enum import IntEnum from re import sub -class BaseLogResult(Enum): +class BaseLogResult(IntEnum): DEBUG = 10 PASSED = 11 WORKAROUND = 12 From 5bbbf559fd0e1d60cab94e8f9232f943cabd1338 Mon Sep 17 00:00:00 2001 From: Kamil Gierszewski Date: Wed, 30 Oct 2024 00:43:17 +0100 Subject: [PATCH 2/6] test-framework: Make pre-logger exceptions readable Signed-off-by: Kamil Gierszewski --- core/test_run_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/test_run_utils.py b/core/test_run_utils.py index 3871bab..c06fd70 100644 --- a/core/test_run_utils.py +++ b/core/test_run_utils.py @@ -186,6 +186,8 @@ TestRun.setup = __setup @classmethod def __makereport(cls, item, call, res): + if cls.LOGGER is None: + return None cls.outcome = res.outcome step_info = { 'result': res.outcome, From 7b741e2c96e1be38289a62f81821c8606de7be48 Mon Sep 17 00:00:00 2001 From: Kamil Gierszewski Date: Wed, 30 Oct 2024 00:50:50 +0100 Subject: [PATCH 3/6] test-framework: Parallelize SATA plug_all command Signed-off-by: Kamil Gierszewski --- storage_devices/disk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage_devices/disk.py b/storage_devices/disk.py index 8e2cbbc..00bd486 100644 --- a/storage_devices/disk.py +++ b/storage_devices/disk.py @@ -288,8 +288,8 @@ class SataDisk(Disk): @classmethod def plug_all(cls) -> Output: cmd = ( - f"for i in $(find -H /sys/devices/ -path '*/scsi_host/*/scan' -type f); do echo " - f"'- - -' > $i; done;" + "find -H /sys/devices/ -path '*/scsi_host/*/scan' -type f |" + " xargs -P20 -I % sh -c \"echo '- - -' | tee %\"" ) output = TestRun.executor.run_expect_success(cmd) return output From f59fc28ef2ea25f9c60ec3311681f93548d812db Mon Sep 17 00:00:00 2001 From: Kamil Gierszewski Date: Wed, 30 Oct 2024 00:53:14 +0100 Subject: [PATCH 4/6] test-framework: Wait for raids after creating, not while discovering Signed-off-by: Kamil Gierszewski --- test_tools/mdadm.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test_tools/mdadm.py b/test_tools/mdadm.py index ae962bb..db5e60a 100644 --- a/test_tools/mdadm.py +++ b/test_tools/mdadm.py @@ -1,11 +1,14 @@ # # Copyright(c) 2020-2021 Intel Corporation +# Copyright(c) 2024 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # + import re from core.test_run import TestRun from test_utils.size import Unit +from test_utils.os_utils import Udev class Mdadm: @@ -33,7 +36,11 @@ class Mdadm: if conf.size: cmd += f"--size={int(conf.size.get_value(Unit.KibiByte))} " cmd += device_paths - return TestRun.executor.run_expect_success(cmd) + ret = TestRun.executor.run_expect_success(cmd) + Udev.trigger() + Udev.settle() + + return ret @staticmethod def detail(raid_device_paths: str): @@ -76,8 +83,6 @@ class Mdadm: raids = [] uuid_path_prefix = "/dev/disk/by-id/md-uuid-" - # sometimes links for RAIDs are not properly created, force udev to create them - TestRun.executor.run("udevadm trigger && udevadm settle") for line in output.stdout.splitlines(): split_line = line.split() From 0edba4f01baf13178e59ee086353533d1d443930 Mon Sep 17 00:00:00 2001 From: Kamil Gierszewski Date: Wed, 30 Oct 2024 00:55:34 +0100 Subject: [PATCH 5/6] test-framework: Make kill_all_io faster Signed-off-by: Kamil Gierszewski --- test_utils/os_utils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test_utils/os_utils.py b/test_utils/os_utils.py index c0bb0e2..e9c01f1 100644 --- a/test_utils/os_utils.py +++ b/test_utils/os_utils.py @@ -381,10 +381,13 @@ def get_udev_service_path(unit_name): return path -def kill_all_io(): - # TERM signal should be used in preference to the KILL signal, since a - # process may install a handler for the TERM signal in order to perform - # clean-up steps before terminating in an orderly fashion. +def kill_all_io(graceful=True): + if graceful: + # TERM signal should be used in preference to the KILL signal, since a + # process may install a handler for the TERM signal in order to perform + # clean-up steps before terminating in an orderly fashion. + TestRun.executor.run("killall -q --signal TERM dd fio blktrace") + time.sleep(3) TestRun.executor.run("killall -q --signal TERM dd fio blktrace") time.sleep(3) TestRun.executor.run("killall -q --signal KILL dd fio blktrace") From 6ea1c16066b22b65faa39ff7b5400c5655c51bda Mon Sep 17 00:00:00 2001 From: Kamil Gierszewski Date: Wed, 30 Oct 2024 00:57:12 +0100 Subject: [PATCH 6/6] test-framework: Fail the test if something broke in prepare Signed-off-by: Kamil Gierszewski --- core/test_run_utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/test_run_utils.py b/core/test_run_utils.py index c06fd70..51e6435 100644 --- a/core/test_run_utils.py +++ b/core/test_run_utils.py @@ -186,8 +186,6 @@ TestRun.setup = __setup @classmethod def __makereport(cls, item, call, res): - if cls.LOGGER is None: - return None cls.outcome = res.outcome step_info = { 'result': res.outcome, @@ -213,7 +211,7 @@ def __makereport(cls, item, call, res): if res.outcome == "skipped": cls.LOGGER.skip("Test skipped.") - if res.when == "call" and cls.LOGGER.get_result() == BaseLogResult.FAILED: + if res.when in ["call", "setup"] and cls.LOGGER.get_result() >= BaseLogResult.FAILED: res.outcome = "failed" # To print additional message in final test report, assign it to res.longrepr