Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/136433/?format=api
http://patches.dpdk.org/api/patches/136433/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240206145716.71435-2-juraj.linkes@pantheon.tech/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20240206145716.71435-2-juraj.linkes@pantheon.tech>", "list_archive_url": "https://inbox.dpdk.org/dev/20240206145716.71435-2-juraj.linkes@pantheon.tech", "date": "2024-02-06T14:57:10", "name": "[v2,1/7] dts: convert dts.py methods to class", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "0fdaec185388fc7fa880f4c2941e515085593993", "submitter": { "id": 1626, "url": "http://patches.dpdk.org/api/people/1626/?format=api", "name": "Juraj Linkeš", "email": "juraj.linkes@pantheon.tech" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20240206145716.71435-2-juraj.linkes@pantheon.tech/mbox/", "series": [ { "id": 31012, "url": "http://patches.dpdk.org/api/series/31012/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=31012", "date": "2024-02-06T14:57:09", "name": "test case blocking and logging", "version": 2, "mbox": "http://patches.dpdk.org/series/31012/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/136433/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/136433/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 3ABBB43A73;\n\tTue, 6 Feb 2024 15:57:28 +0100 (CET)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 41BF642D0B;\n\tTue, 6 Feb 2024 15:57:21 +0100 (CET)", "from mail-lf1-f54.google.com (mail-lf1-f54.google.com\n [209.85.167.54]) by mails.dpdk.org (Postfix) with ESMTP id E15E941611\n for <dev@dpdk.org>; Tue, 6 Feb 2024 15:57:19 +0100 (CET)", "by mail-lf1-f54.google.com with SMTP id\n 2adb3069b0e04-51124d43943so9116385e87.2\n for <dev@dpdk.org>; Tue, 06 Feb 2024 06:57:19 -0800 (PST)", "from localhost.localdomain ([84.245.120.62])\n by smtp.gmail.com with ESMTPSA id\n lg25-20020a170907181900b00a36c5b01ef3sm1220786ejc.225.2024.02.06.06.57.18\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 06 Feb 2024 06:57:18 -0800 (PST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=pantheon.tech; s=google; t=1707231439; x=1707836239; darn=dpdk.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=joyBwk0zgt5jOkjegucQm0mrXA4WSkWrbHPUr9eGsiU=;\n b=e7NMIGHS97mzy7jb7+esEqgopI8yf8Bs/Vhwrn48M9XaepWCtIrsIX3u3QZ4os20rS\n 0QkA4wcJziftEIvjFDwjQjc8M77Fk+YKT8MEy/Pb3rE90Mf0twvLlOdBOboPQVuPpF01\n o5jgWLiivniTO7MAcWKgQYkrgVIHWM4d03GlS/ej9FWki/u31rD2WxphZWkKTqhodYNW\n 14kyz5ZvXpBtAskjri10vMXvc4HvdjYrBZ7kMoqtqqE+6ZaYPvcAvZhVyrI0mRn1/TYT\n RfzTcnoqGkdupjlq7GRlKcBb6/s5PmoCmiKWd9NLJYnNCpQHW5A4ryEQchrqMZOtTU6i\n KCRQ==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1707231439; x=1707836239;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=joyBwk0zgt5jOkjegucQm0mrXA4WSkWrbHPUr9eGsiU=;\n b=XviPQMFln/aJkD8JiBHvXhofO8ULQGPgJigXTyIeb2MEgJteKxzMW2NcrPbsjmDmpn\n qstgxeRSlXkdDWg2yjzJLM/gP8h6JLUMd5ekSfo1V31VfXGuZVFR1YvhemI1MGjLJkIF\n A7mW6aZC57qZDjH9Nj5i/kBjlYayhm/HwwL4qwl77AZoc27iPqOS2VdzJom4ba5iWzsv\n nFrhRoNZN9OA7gsPKZVFupaUuJh1/SqbjODscn6nj406jKvF5HwHwwmAxUyy+jCQXfxY\n 3xdrFsq63p4b3pbJqVV0mTHAFti2k422KXZmTezFKlmU6PLP4fJorz1ugIUxxFBFFvYg\n y3JA==", "X-Gm-Message-State": "AOJu0YyAyL+y8HLsjYKKwS6rY0E+dNQcPj8Dn/5w2a/r9Pcp2C/7+h7u\n Kj9q7fvWN+1AxYYeaTZSdeTPchxbTTuFyHoP6L6MjMsvh3xsrtTsPye6bsMuSXI=", "X-Google-Smtp-Source": "\n AGHT+IGVcalWnqd/GVjfBoNoUlgD7a+gRpUbWhl9NlzN3wuX6elgu2C5/q9wOt5n2Si3hONji5mp0w==", "X-Received": "by 2002:a19:5f14:0:b0:511:4cbe:b431 with SMTP id\n t20-20020a195f14000000b005114cbeb431mr1789383lfb.66.1707231439090;\n Tue, 06 Feb 2024 06:57:19 -0800 (PST)", "X-Forwarded-Encrypted": "i=0;\n AJvYcCU65Nn/eP1O95SJgnDjteo/pwf78CApQDTxxelR7MzcFEzadMVLQXyYMs5cdk9OEVjjGTrNoqdf8vtaXFXCby4GNKr06+yncrM4VWwBi65i/F+w+XBaROTvC2nvi3bajKXUb42K3QyHmeNCrHBnjp5eWNOSd5FsqacvKbtu+dgHxpXJMkOSB9DTPPPrUfa0KCJlr9snwDGnPrj93hbfINP1GesHODfUKXDyYNqoCKG4/dlUrx1OxuI5rU8OZx1aWXB/", "From": "=?utf-8?q?Juraj_Linke=C5=A1?= <juraj.linkes@pantheon.tech>", "To": "thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, jspewock@iol.unh.edu,\n probb@iol.unh.edu, paul.szczepanek@arm.com, Luca.Vizzarro@arm.com", "Cc": "dev@dpdk.org, =?utf-8?q?Juraj_Linke=C5=A1?= <juraj.linkes@pantheon.tech>", "Subject": "[PATCH v2 1/7] dts: convert dts.py methods to class", "Date": "Tue, 6 Feb 2024 15:57:10 +0100", "Message-Id": "<20240206145716.71435-2-juraj.linkes@pantheon.tech>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20240206145716.71435-1-juraj.linkes@pantheon.tech>", "References": "<20231220103331.60888-1-juraj.linkes@pantheon.tech>\n <20240206145716.71435-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 <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "The dts.py module deviates from the rest of the code without a clear\nreason. Converting it into a class and using better naming will improve\norganization and code readability.\n\nSigned-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>\n---\n dts/framework/dts.py | 338 ----------------------------------------\n dts/framework/runner.py | 333 +++++++++++++++++++++++++++++++++++++++\n dts/main.py | 6 +-\n 3 files changed, 337 insertions(+), 340 deletions(-)\n delete mode 100644 dts/framework/dts.py\n create mode 100644 dts/framework/runner.py", "diff": "diff --git a/dts/framework/dts.py b/dts/framework/dts.py\ndeleted file mode 100644\nindex e16d4578a0..0000000000\n--- a/dts/framework/dts.py\n+++ /dev/null\n@@ -1,338 +0,0 @@\n-# SPDX-License-Identifier: BSD-3-Clause\n-# Copyright(c) 2010-2019 Intel Corporation\n-# Copyright(c) 2022-2023 PANTHEON.tech s.r.o.\n-# Copyright(c) 2022-2023 University of New Hampshire\n-\n-r\"\"\"Test suite runner module.\n-\n-A DTS run is split into stages:\n-\n- #. Execution stage,\n- #. Build target stage,\n- #. Test suite stage,\n- #. Test case stage.\n-\n-The module is responsible for running tests on testbeds defined in the test run configuration.\n-Each setup or teardown of each stage is recorded in a :class:`~.test_result.DTSResult` or\n-one of its subclasses. The test case results are also recorded.\n-\n-If an error occurs, the current stage is aborted, the error is recorded and the run continues in\n-the next iteration of the same stage. The return code is the highest `severity` of all\n-:class:`~.exception.DTSError`\\s.\n-\n-Example:\n- An error occurs in a build target setup. The current build target is aborted and the run\n- continues with the next build target. If the errored build target was the last one in the given\n- execution, the next execution begins.\n-\n-Attributes:\n- dts_logger: The logger instance used in this module.\n- result: The top level result used in the module.\n-\"\"\"\n-\n-import sys\n-\n-from .config import (\n- BuildTargetConfiguration,\n- ExecutionConfiguration,\n- TestSuiteConfig,\n- load_config,\n-)\n-from .exception import BlockingTestSuiteError\n-from .logger import DTSLOG, getLogger\n-from .test_result import BuildTargetResult, DTSResult, ExecutionResult, Result\n-from .test_suite import get_test_suites\n-from .testbed_model import SutNode, TGNode\n-\n-# dummy defaults to satisfy linters\n-dts_logger: DTSLOG = None # type: ignore[assignment]\n-result: DTSResult = DTSResult(dts_logger)\n-\n-\n-def run_all() -> None:\n- \"\"\"Run all build targets in all executions from the test run configuration.\n-\n- Before running test suites, executions and build targets are first set up.\n- The executions and build targets defined in the test run configuration are iterated over.\n- The executions define which tests to run and where to run them and build targets define\n- the DPDK build setup.\n-\n- The tests suites are set up for each execution/build target tuple and each scheduled\n- test case within the test suite is set up, executed and torn down. After all test cases\n- have been executed, the test suite is torn down and the next build target will be tested.\n-\n- All the nested steps look like this:\n-\n- #. Execution setup\n-\n- #. Build target setup\n-\n- #. Test suite setup\n-\n- #. Test case setup\n- #. Test case logic\n- #. Test case teardown\n-\n- #. Test suite teardown\n-\n- #. Build target teardown\n-\n- #. Execution teardown\n-\n- The test cases are filtered according to the specification in the test run configuration and\n- the :option:`--test-cases` command line argument or\n- the :envvar:`DTS_TESTCASES` environment variable.\n- \"\"\"\n- global dts_logger\n- global result\n-\n- # create a regular DTS logger and create a new result with it\n- dts_logger = getLogger(\"DTSRunner\")\n- result = DTSResult(dts_logger)\n-\n- # check the python version of the server that run dts\n- _check_dts_python_version()\n-\n- sut_nodes: dict[str, SutNode] = {}\n- tg_nodes: dict[str, TGNode] = {}\n- try:\n- # for all Execution sections\n- for execution in load_config().executions:\n- sut_node = sut_nodes.get(execution.system_under_test_node.name)\n- tg_node = tg_nodes.get(execution.traffic_generator_node.name)\n-\n- try:\n- if not sut_node:\n- sut_node = SutNode(execution.system_under_test_node)\n- sut_nodes[sut_node.name] = sut_node\n- if not tg_node:\n- tg_node = TGNode(execution.traffic_generator_node)\n- tg_nodes[tg_node.name] = tg_node\n- result.update_setup(Result.PASS)\n- except Exception as e:\n- failed_node = execution.system_under_test_node.name\n- if sut_node:\n- failed_node = execution.traffic_generator_node.name\n- dts_logger.exception(f\"Creation of node {failed_node} failed.\")\n- result.update_setup(Result.FAIL, e)\n-\n- else:\n- _run_execution(sut_node, tg_node, execution, result)\n-\n- except Exception as e:\n- dts_logger.exception(\"An unexpected error has occurred.\")\n- result.add_error(e)\n- raise\n-\n- finally:\n- try:\n- for node in (sut_nodes | tg_nodes).values():\n- node.close()\n- result.update_teardown(Result.PASS)\n- except Exception as e:\n- dts_logger.exception(\"Final cleanup of nodes failed.\")\n- result.update_teardown(Result.ERROR, e)\n-\n- # we need to put the sys.exit call outside the finally clause to make sure\n- # that unexpected exceptions will propagate\n- # in that case, the error that should be reported is the uncaught exception as\n- # that is a severe error originating from the framework\n- # at that point, we'll only have partial results which could be impacted by the\n- # error causing the uncaught exception, making them uninterpretable\n- _exit_dts()\n-\n-\n-def _check_dts_python_version() -> None:\n- \"\"\"Check the required Python version - v3.10.\"\"\"\n-\n- def RED(text: str) -> str:\n- return f\"\\u001B[31;1m{str(text)}\\u001B[0m\"\n-\n- if sys.version_info.major < 3 or (sys.version_info.major == 3 and sys.version_info.minor < 10):\n- print(\n- RED(\n- (\n- \"WARNING: DTS execution node's python version is lower than\"\n- \"python 3.10, is deprecated and will not work in future releases.\"\n- )\n- ),\n- file=sys.stderr,\n- )\n- print(RED(\"Please use Python >= 3.10 instead\"), file=sys.stderr)\n-\n-\n-def _run_execution(\n- sut_node: SutNode,\n- tg_node: TGNode,\n- execution: ExecutionConfiguration,\n- result: DTSResult,\n-) -> None:\n- \"\"\"Run the given execution.\n-\n- This involves running the execution setup as well as running all build targets\n- in the given execution. After that, execution teardown is run.\n-\n- Args:\n- sut_node: The execution's SUT node.\n- tg_node: The execution's TG node.\n- execution: An execution's test run configuration.\n- result: The top level result object.\n- \"\"\"\n- dts_logger.info(f\"Running execution with SUT '{execution.system_under_test_node.name}'.\")\n- execution_result = result.add_execution(sut_node.config)\n- execution_result.add_sut_info(sut_node.node_info)\n-\n- try:\n- sut_node.set_up_execution(execution)\n- execution_result.update_setup(Result.PASS)\n- except Exception as e:\n- dts_logger.exception(\"Execution setup failed.\")\n- execution_result.update_setup(Result.FAIL, e)\n-\n- else:\n- for build_target in execution.build_targets:\n- _run_build_target(sut_node, tg_node, build_target, execution, execution_result)\n-\n- finally:\n- try:\n- sut_node.tear_down_execution()\n- execution_result.update_teardown(Result.PASS)\n- except Exception as e:\n- dts_logger.exception(\"Execution teardown failed.\")\n- execution_result.update_teardown(Result.FAIL, e)\n-\n-\n-def _run_build_target(\n- sut_node: SutNode,\n- tg_node: TGNode,\n- build_target: BuildTargetConfiguration,\n- execution: ExecutionConfiguration,\n- execution_result: ExecutionResult,\n-) -> None:\n- \"\"\"Run the given build target.\n-\n- This involves running the build target setup as well as running all test suites\n- in the given execution the build target is defined in.\n- After that, build target teardown is run.\n-\n- Args:\n- sut_node: The execution's SUT node.\n- tg_node: The execution's TG node.\n- build_target: A build target's test run configuration.\n- execution: The build target's execution's test run configuration.\n- execution_result: The execution level result object associated with the execution.\n- \"\"\"\n- dts_logger.info(f\"Running build target '{build_target.name}'.\")\n- build_target_result = execution_result.add_build_target(build_target)\n-\n- try:\n- sut_node.set_up_build_target(build_target)\n- result.dpdk_version = sut_node.dpdk_version\n- build_target_result.add_build_target_info(sut_node.get_build_target_info())\n- build_target_result.update_setup(Result.PASS)\n- except Exception as e:\n- dts_logger.exception(\"Build target setup failed.\")\n- build_target_result.update_setup(Result.FAIL, e)\n-\n- else:\n- _run_all_suites(sut_node, tg_node, execution, build_target_result)\n-\n- finally:\n- try:\n- sut_node.tear_down_build_target()\n- build_target_result.update_teardown(Result.PASS)\n- except Exception as e:\n- dts_logger.exception(\"Build target teardown failed.\")\n- build_target_result.update_teardown(Result.FAIL, e)\n-\n-\n-def _run_all_suites(\n- sut_node: SutNode,\n- tg_node: TGNode,\n- execution: ExecutionConfiguration,\n- build_target_result: BuildTargetResult,\n-) -> None:\n- \"\"\"Run the execution's (possibly a subset) test suites using the current build target.\n-\n- The function assumes the build target we're testing has already been built on the SUT node.\n- The current build target thus corresponds to the current DPDK build present on the SUT node.\n-\n- If a blocking test suite (such as the smoke test suite) fails, the rest of the test suites\n- in the current build target won't be executed.\n-\n- Args:\n- sut_node: The execution's SUT node.\n- tg_node: The execution's TG node.\n- execution: The execution's test run configuration associated with the current build target.\n- build_target_result: The build target level result object associated\n- with the current build target.\n- \"\"\"\n- end_build_target = False\n- if not execution.skip_smoke_tests:\n- execution.test_suites[:0] = [TestSuiteConfig.from_dict(\"smoke_tests\")]\n- for test_suite_config in execution.test_suites:\n- try:\n- _run_single_suite(sut_node, tg_node, execution, build_target_result, test_suite_config)\n- except BlockingTestSuiteError as e:\n- dts_logger.exception(\n- f\"An error occurred within {test_suite_config.test_suite}. Skipping build target.\"\n- )\n- result.add_error(e)\n- end_build_target = True\n- # if a blocking test failed and we need to bail out of suite executions\n- if end_build_target:\n- break\n-\n-\n-def _run_single_suite(\n- sut_node: SutNode,\n- tg_node: TGNode,\n- execution: ExecutionConfiguration,\n- build_target_result: BuildTargetResult,\n- test_suite_config: TestSuiteConfig,\n-) -> None:\n- \"\"\"Run all test suite in a single test suite module.\n-\n- The function assumes the build target we're testing has already been built on the SUT node.\n- The current build target thus corresponds to the current DPDK build present on the SUT node.\n-\n- Args:\n- sut_node: The execution's SUT node.\n- tg_node: The execution's TG node.\n- execution: The execution's test run configuration associated with the current build target.\n- build_target_result: The build target level result object associated\n- with the current build target.\n- test_suite_config: Test suite test run configuration specifying the test suite module\n- and possibly a subset of test cases of test suites in that module.\n-\n- Raises:\n- BlockingTestSuiteError: If a blocking test suite fails.\n- \"\"\"\n- try:\n- full_suite_path = f\"tests.TestSuite_{test_suite_config.test_suite}\"\n- test_suite_classes = get_test_suites(full_suite_path)\n- suites_str = \", \".join((x.__name__ for x in test_suite_classes))\n- dts_logger.debug(f\"Found test suites '{suites_str}' in '{full_suite_path}'.\")\n- except Exception as e:\n- dts_logger.exception(\"An error occurred when searching for test suites.\")\n- result.update_setup(Result.ERROR, e)\n-\n- else:\n- for test_suite_class in test_suite_classes:\n- test_suite = test_suite_class(\n- sut_node,\n- tg_node,\n- test_suite_config.test_cases,\n- execution.func,\n- build_target_result,\n- )\n- test_suite.run()\n-\n-\n-def _exit_dts() -> None:\n- \"\"\"Process all errors and exit with the proper exit code.\"\"\"\n- result.process()\n-\n- if dts_logger:\n- dts_logger.info(\"DTS execution has ended.\")\n- sys.exit(result.get_return_code())\ndiff --git a/dts/framework/runner.py b/dts/framework/runner.py\nnew file mode 100644\nindex 0000000000..acc1c4d6db\n--- /dev/null\n+++ b/dts/framework/runner.py\n@@ -0,0 +1,333 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2010-2019 Intel Corporation\n+# Copyright(c) 2022-2023 PANTHEON.tech s.r.o.\n+# Copyright(c) 2022-2023 University of New Hampshire\n+\n+\"\"\"Test suite runner module.\n+\n+The module is responsible for running DTS in a series of stages:\n+\n+ #. Execution stage,\n+ #. Build target stage,\n+ #. Test suite stage,\n+ #. Test case stage.\n+\n+The execution and build target stages set up the environment before running test suites.\n+The test suite stage sets up steps common to all test cases\n+and the test case stage runs test cases individually.\n+\"\"\"\n+\n+import logging\n+import sys\n+\n+from .config import (\n+ BuildTargetConfiguration,\n+ ExecutionConfiguration,\n+ TestSuiteConfig,\n+ load_config,\n+)\n+from .exception import BlockingTestSuiteError\n+from .logger import DTSLOG, getLogger\n+from .test_result import BuildTargetResult, DTSResult, ExecutionResult, Result\n+from .test_suite import get_test_suites\n+from .testbed_model import SutNode, TGNode\n+\n+\n+class DTSRunner:\n+ r\"\"\"Test suite runner class.\n+\n+ The class is responsible for running tests on testbeds defined in the test run configuration.\n+ Each setup or teardown of each stage is recorded in a :class:`~framework.test_result.DTSResult`\n+ or one of its subclasses. The test case results are also recorded.\n+\n+ If an error occurs, the current stage is aborted, the error is recorded and the run continues in\n+ the next iteration of the same stage. The return code is the highest `severity` of all\n+ :class:`~.framework.exception.DTSError`\\s.\n+\n+ Example:\n+ An error occurs in a build target setup. The current build target is aborted and the run\n+ continues with the next build target. If the errored build target was the last one in the\n+ given execution, the next execution begins.\n+ \"\"\"\n+\n+ _logger: DTSLOG\n+ _result: DTSResult\n+\n+ def __init__(self):\n+ \"\"\"Initialize the instance with logger and result.\"\"\"\n+ self._logger = getLogger(\"DTSRunner\")\n+ self._result = DTSResult(self._logger)\n+\n+ def run(self):\n+ \"\"\"Run all build targets in all executions from the test run configuration.\n+\n+ Before running test suites, executions and build targets are first set up.\n+ The executions and build targets defined in the test run configuration are iterated over.\n+ The executions define which tests to run and where to run them and build targets define\n+ the DPDK build setup.\n+\n+ The tests suites are set up for each execution/build target tuple and each discovered\n+ test case within the test suite is set up, executed and torn down. After all test cases\n+ have been executed, the test suite is torn down and the next build target will be tested.\n+\n+ All the nested steps look like this:\n+\n+ #. Execution setup\n+\n+ #. Build target setup\n+\n+ #. Test suite setup\n+\n+ #. Test case setup\n+ #. Test case logic\n+ #. Test case teardown\n+\n+ #. Test suite teardown\n+\n+ #. Build target teardown\n+\n+ #. Execution teardown\n+\n+ The test cases are filtered according to the specification in the test run configuration and\n+ the :option:`--test-cases` command line argument or\n+ the :envvar:`DTS_TESTCASES` environment variable.\n+ \"\"\"\n+ sut_nodes: dict[str, SutNode] = {}\n+ tg_nodes: dict[str, TGNode] = {}\n+ try:\n+ # check the python version of the server that runs dts\n+ self._check_dts_python_version()\n+\n+ # for all Execution sections\n+ for execution in load_config().executions:\n+ sut_node = sut_nodes.get(execution.system_under_test_node.name)\n+ tg_node = tg_nodes.get(execution.traffic_generator_node.name)\n+\n+ try:\n+ if not sut_node:\n+ sut_node = SutNode(execution.system_under_test_node)\n+ sut_nodes[sut_node.name] = sut_node\n+ if not tg_node:\n+ tg_node = TGNode(execution.traffic_generator_node)\n+ tg_nodes[tg_node.name] = tg_node\n+ self._result.update_setup(Result.PASS)\n+ except Exception as e:\n+ failed_node = execution.system_under_test_node.name\n+ if sut_node:\n+ failed_node = execution.traffic_generator_node.name\n+ self._logger.exception(f\"The Creation of node {failed_node} failed.\")\n+ self._result.update_setup(Result.FAIL, e)\n+\n+ else:\n+ self._run_execution(sut_node, tg_node, execution)\n+\n+ except Exception as e:\n+ self._logger.exception(\"An unexpected error has occurred.\")\n+ self._result.add_error(e)\n+ raise\n+\n+ finally:\n+ try:\n+ for node in (sut_nodes | tg_nodes).values():\n+ node.close()\n+ self._result.update_teardown(Result.PASS)\n+ except Exception as e:\n+ self._logger.exception(\"The final cleanup of nodes failed.\")\n+ self._result.update_teardown(Result.ERROR, e)\n+\n+ # we need to put the sys.exit call outside the finally clause to make sure\n+ # that unexpected exceptions will propagate\n+ # in that case, the error that should be reported is the uncaught exception as\n+ # that is a severe error originating from the framework\n+ # at that point, we'll only have partial results which could be impacted by the\n+ # error causing the uncaught exception, making them uninterpretable\n+ self._exit_dts()\n+\n+ def _check_dts_python_version(self) -> None:\n+ \"\"\"Check the required Python version - v3.10.\"\"\"\n+ if sys.version_info.major < 3 or (\n+ sys.version_info.major == 3 and sys.version_info.minor < 10\n+ ):\n+ self._logger.warning(\n+ \"DTS execution node's python version is lower than Python 3.10, \"\n+ \"is deprecated and will not work in future releases.\"\n+ )\n+ self._logger.warning(\"Please use Python >= 3.10 instead.\")\n+\n+ def _run_execution(\n+ self,\n+ sut_node: SutNode,\n+ tg_node: TGNode,\n+ execution: ExecutionConfiguration,\n+ ) -> None:\n+ \"\"\"Run the given execution.\n+\n+ This involves running the execution setup as well as running all build targets\n+ in the given execution. After that, execution teardown is run.\n+\n+ Args:\n+ sut_node: The execution's SUT node.\n+ tg_node: The execution's TG node.\n+ execution: An execution's test run configuration.\n+ \"\"\"\n+ self._logger.info(f\"Running execution with SUT '{execution.system_under_test_node.name}'.\")\n+ execution_result = self._result.add_execution(sut_node.config)\n+ execution_result.add_sut_info(sut_node.node_info)\n+\n+ try:\n+ sut_node.set_up_execution(execution)\n+ execution_result.update_setup(Result.PASS)\n+ except Exception as e:\n+ self._logger.exception(\"Execution setup failed.\")\n+ execution_result.update_setup(Result.FAIL, e)\n+\n+ else:\n+ for build_target in execution.build_targets:\n+ self._run_build_target(sut_node, tg_node, build_target, execution, execution_result)\n+\n+ finally:\n+ try:\n+ sut_node.tear_down_execution()\n+ execution_result.update_teardown(Result.PASS)\n+ except Exception as e:\n+ self._logger.exception(\"Execution teardown failed.\")\n+ execution_result.update_teardown(Result.FAIL, e)\n+\n+ def _run_build_target(\n+ self,\n+ sut_node: SutNode,\n+ tg_node: TGNode,\n+ build_target: BuildTargetConfiguration,\n+ execution: ExecutionConfiguration,\n+ execution_result: ExecutionResult,\n+ ) -> None:\n+ \"\"\"Run the given build target.\n+\n+ This involves running the build target setup as well as running all test suites\n+ of the build target's execution.\n+ After that, build target teardown is run.\n+\n+ Args:\n+ sut_node: The execution's sut node.\n+ tg_node: The execution's tg node.\n+ build_target: A build target's test run configuration.\n+ execution: The build target's execution's test run configuration.\n+ execution_result: The execution level result object associated with the execution.\n+ \"\"\"\n+ self._logger.info(f\"Running build target '{build_target.name}'.\")\n+ build_target_result = execution_result.add_build_target(build_target)\n+\n+ try:\n+ sut_node.set_up_build_target(build_target)\n+ self._result.dpdk_version = sut_node.dpdk_version\n+ build_target_result.add_build_target_info(sut_node.get_build_target_info())\n+ build_target_result.update_setup(Result.PASS)\n+ except Exception as e:\n+ self._logger.exception(\"Build target setup failed.\")\n+ build_target_result.update_setup(Result.FAIL, e)\n+\n+ else:\n+ self._run_all_suites(sut_node, tg_node, execution, build_target_result)\n+\n+ finally:\n+ try:\n+ sut_node.tear_down_build_target()\n+ build_target_result.update_teardown(Result.PASS)\n+ except Exception as e:\n+ self._logger.exception(\"Build target teardown failed.\")\n+ build_target_result.update_teardown(Result.FAIL, e)\n+\n+ def _run_all_suites(\n+ self,\n+ sut_node: SutNode,\n+ tg_node: TGNode,\n+ execution: ExecutionConfiguration,\n+ build_target_result: BuildTargetResult,\n+ ) -> None:\n+ \"\"\"Run the execution's (possibly a subset of) test suites using the current build target.\n+\n+ The method assumes the build target we're testing has already been built on the SUT node.\n+ The current build target thus corresponds to the current DPDK build present on the SUT node.\n+\n+ Args:\n+ sut_node: The execution's SUT node.\n+ tg_node: The execution's TG node.\n+ execution: The execution's test run configuration associated\n+ with the current build target.\n+ build_target_result: The build target level result object associated\n+ with the current build target.\n+ \"\"\"\n+ end_build_target = False\n+ if not execution.skip_smoke_tests:\n+ execution.test_suites[:0] = [TestSuiteConfig.from_dict(\"smoke_tests\")]\n+ for test_suite_config in execution.test_suites:\n+ try:\n+ self._run_single_suite(\n+ sut_node, tg_node, execution, build_target_result, test_suite_config\n+ )\n+ except BlockingTestSuiteError as e:\n+ self._logger.exception(\n+ f\"An error occurred within {test_suite_config.test_suite}. \"\n+ \"Skipping build target...\"\n+ )\n+ self._result.add_error(e)\n+ end_build_target = True\n+ # if a blocking test failed and we need to bail out of suite executions\n+ if end_build_target:\n+ break\n+\n+ def _run_single_suite(\n+ self,\n+ sut_node: SutNode,\n+ tg_node: TGNode,\n+ execution: ExecutionConfiguration,\n+ build_target_result: BuildTargetResult,\n+ test_suite_config: TestSuiteConfig,\n+ ) -> None:\n+ \"\"\"Run all test suites in a single test suite module.\n+\n+ The method assumes the build target we're testing has already been built on the SUT node.\n+ The current build target thus corresponds to the current DPDK build present on the SUT node.\n+\n+ Args:\n+ sut_node: The execution's SUT node.\n+ tg_node: The execution's TG node.\n+ execution: The execution's test run configuration associated\n+ with the current build target.\n+ build_target_result: The build target level result object associated\n+ with the current build target.\n+ test_suite_config: Test suite test run configuration specifying the test suite module\n+ and possibly a subset of test cases of test suites in that module.\n+\n+ Raises:\n+ BlockingTestSuiteError: If a blocking test suite fails.\n+ \"\"\"\n+ try:\n+ full_suite_path = f\"tests.TestSuite_{test_suite_config.test_suite}\"\n+ test_suite_classes = get_test_suites(full_suite_path)\n+ suites_str = \", \".join((x.__name__ for x in test_suite_classes))\n+ self._logger.debug(f\"Found test suites '{suites_str}' in '{full_suite_path}'.\")\n+ except Exception as e:\n+ self._logger.exception(\"An error occurred when searching for test suites.\")\n+ self._result.update_setup(Result.ERROR, e)\n+\n+ else:\n+ for test_suite_class in test_suite_classes:\n+ test_suite = test_suite_class(\n+ sut_node,\n+ tg_node,\n+ test_suite_config.test_cases,\n+ execution.func,\n+ build_target_result,\n+ )\n+ test_suite.run()\n+\n+ def _exit_dts(self) -> None:\n+ \"\"\"Process all errors and exit with the proper exit code.\"\"\"\n+ self._result.process()\n+\n+ if self._logger:\n+ self._logger.info(\"DTS execution has ended.\")\n+\n+ logging.shutdown()\n+ sys.exit(self._result.get_return_code())\ndiff --git a/dts/main.py b/dts/main.py\nindex f703615d11..1ffe8ff81f 100755\n--- a/dts/main.py\n+++ b/dts/main.py\n@@ -21,9 +21,11 @@ def main() -> None:\n be modified before the settings module is imported anywhere else in the framework.\n \"\"\"\n settings.SETTINGS = settings.get_settings()\n- from framework import dts\n \n- dts.run_all()\n+ from framework.runner import DTSRunner\n+\n+ dts = DTSRunner()\n+ dts.run()\n \n \n # Main program begins here\n", "prefixes": [ "v2", "1/7" ] }{ "id": 136433, "url": "