From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 85F01A00C5; Fri, 4 Nov 2022 12:06:22 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5DB0142D4F; Fri, 4 Nov 2022 12:05:42 +0100 (CET) Received: from lb.pantheon.sk (lb.pantheon.sk [46.229.239.20]) by mails.dpdk.org (Postfix) with ESMTP id BCC5B42D42 for ; Fri, 4 Nov 2022 12:05:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by lb.pantheon.sk (Postfix) with ESMTP id BF5811BA5AE; Fri, 4 Nov 2022 12:05:39 +0100 (CET) X-Virus-Scanned: amavisd-new at siecit.sk Received: from lb.pantheon.sk ([127.0.0.1]) by localhost (lb.pantheon.sk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uVcao2E68788; Fri, 4 Nov 2022 12:05:38 +0100 (CET) Received: from entguard.lab.pantheon.local (unknown [46.229.239.141]) by lb.pantheon.sk (Postfix) with ESMTP id E06951BA5B5; Fri, 4 Nov 2022 12:05:29 +0100 (CET) From: =?UTF-8?q?Juraj=20Linke=C5=A1?= To: thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, ohilyard@iol.unh.edu, lijuan.tu@intel.com, kda@semihalf.com, bruce.richardson@intel.com Cc: dev@dpdk.org, =?UTF-8?q?Juraj=20Linke=C5=A1?= Subject: [PATCH v8 8/9] dts: add dts workflow module Date: Fri, 4 Nov 2022 11:05:22 +0000 Message-Id: <20221104110523.511367-9-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221104110523.511367-1-juraj.linkes@pantheon.tech> References: <20221103151934.450887-1-juraj.linkes@pantheon.tech> <20221104110523.511367-1-juraj.linkes@pantheon.tech> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The module implements methods needed to run DTS. It handles the creation of objects and eventually the whole DTS workflow, such as running node setups, test gathering, setup and execution and various cleanups. Signed-off-by: Owen Hilyard Signed-off-by: Juraj Linkeš --- dts/framework/dts.py | 67 ++++++++++++++++++++++++++++++++++++++++++ dts/framework/utils.py | 18 ++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 dts/framework/dts.py diff --git a/dts/framework/dts.py b/dts/framework/dts.py new file mode 100644 index 0000000000..d23cfc4526 --- /dev/null +++ b/dts/framework/dts.py @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2010-2019 Intel Corporation +# Copyright(c) 2022 PANTHEON.tech s.r.o. +# Copyright(c) 2022 University of New Hampshire + +import sys +import traceback +from collections.abc import Iterable + +from framework.testbed_model.node import Node + +from .config import CONFIGURATION +from .logger import DTSLOG, getLogger +from .utils import check_dts_python_version + +dts_logger: DTSLOG | None = None + + +def run_all() -> None: + """ + Main process of DTS, it will run all test suites in the config file. + """ + + global dts_logger + + # check the python version of the server that run dts + check_dts_python_version() + + dts_logger = getLogger("dts") + + nodes = {} + # This try/finally block means "Run the try block, if there is an exception, + # run the finally block before passing it upward. If there is not an exception, + # run the finally block after the try block is finished." This helps avoid the + # problem of python's interpreter exit context, which essentially prevents you + # from making certain system calls. This makes cleaning up resources difficult, + # since most of the resources in DTS are network-based, which is restricted. + try: + # for all Execution sections + for execution in CONFIGURATION.executions: + sut_config = execution.system_under_test + if sut_config.name not in nodes: + node = Node(sut_config) + nodes[sut_config.name] = node + node.send_command("echo Hello World") + + except Exception as e: + # sys.exit() doesn't produce a stack trace, need to print it explicitly + traceback.print_exc() + raise e + + finally: + quit_execution(nodes.values()) + + +def quit_execution(sut_nodes: Iterable[Node]) -> None: + """ + Close session to SUT and TG before quit. + Return exit status when failure occurred. + """ + for sut_node in sut_nodes: + # close all session + sut_node.node_exit() + + if dts_logger is not None: + dts_logger.info("DTS execution has ended.") + sys.exit(0) diff --git a/dts/framework/utils.py b/dts/framework/utils.py index 9c1975a22f..c28c8f1082 100644 --- a/dts/framework/utils.py +++ b/dts/framework/utils.py @@ -3,6 +3,24 @@ # Copyright(c) 2022 PANTHEON.tech s.r.o. # Copyright(c) 2022 University of New Hampshire +import sys + + +def check_dts_python_version() -> None: + if sys.version_info.major < 3 or ( + sys.version_info.major == 3 and sys.version_info.minor < 10 + ): + print( + RED( + ( + "WARNING: DTS execution node's python version is lower than" + "python 3.10, is deprecated and will not work in future releases." + ) + ), + file=sys.stderr, + ) + print(RED("Please use Python >= 3.10 instead"), file=sys.stderr) + def GREEN(text: str) -> str: return f"\u001B[32;1m{str(text)}\u001B[0m" -- 2.30.2