From: "Juraj Linkeš" <juraj.linkes@pantheon.tech>
To: Luca Vizzarro <luca.vizzarro@arm.com>, dev@dpdk.org
Cc: Jeremy Spewock <jspewock@iol.unh.edu>,
Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>,
Paul Szczepanek <paul.szczepanek@arm.com>,
Alex Chapman <alex.chapman@arm.com>
Subject: Re: [PATCH v2 2/5] dts: add random generation seed setting
Date: Fri, 23 Aug 2024 12:30:19 +0200 [thread overview]
Message-ID: <1c74fadc-aa35-4c6d-afcb-7cea14bba771@pantheon.tech> (raw)
In-Reply-To: <20240806124642.2580828-3-luca.vizzarro@arm.com>
This is a great idea. I originally didn't think the config file option
would be very useful, but thinking a bit more about it, when debugging
and trying to find a solution the devs need to run with the same seed
over and over, so it's going to have a place.
Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
On 6. 8. 2024 14:46, Luca Vizzarro wrote:
> When introducing pseudo-random generation in the test runs we need to
> ensure that these can be reproduced by setting a pre-defined seed.
> This commits adds the ability to set one or allow for one to be
> generated and reported back to the user.
>
> Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
> Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
> Reviewed-by: Alex Chapman <alex.chapman@arm.com>
> ---
> doc/guides/tools/dts.rst | 5 +++++
> dts/framework/config/__init__.py | 4 ++++
> dts/framework/config/conf_yaml_schema.json | 4 ++++
> dts/framework/config/types.py | 2 ++
> dts/framework/runner.py | 8 ++++++++
> dts/framework/settings.py | 17 +++++++++++++++++
> 6 files changed, 40 insertions(+)
>
> diff --git a/doc/guides/tools/dts.rst b/doc/guides/tools/dts.rst
> index 515b15e4d8..9b5ea9779c 100644
> --- a/doc/guides/tools/dts.rst
> +++ b/doc/guides/tools/dts.rst
> @@ -251,6 +251,8 @@ DTS is run with ``main.py`` located in the ``dts`` directory after entering Poet
> ... | DTS_TEST_SUITES='suite, suite case, ...' (default: [])
> --re-run N_TIMES, --re_run N_TIMES
> [DTS_RERUN] Re-run each test case the specified number of times if a test failure occurs. (default: 0)
> + --random-seed NUMBER [DTS_RANDOM_SEED] The seed to use with the pseudo-random generator. If not specified, the configuration value is
> + used instead. If that's also not specified, a random seed is generated. (default: None)
>
>
> The brackets contain the names of environment variables that set the same thing.
> @@ -548,6 +550,9 @@ involved in the testing. These can be defined with the following mappings:
> +----------------------------+---------------+---------------------------------------------------+
> | ``traffic_generator_node`` | Node name for the traffic generator node. |
> +----------------------------+-------------------------------------------------------------------+
> + | ``random_seed`` | (*optional*) *int* – Allows you to set a seed for pseudo-random |
> + | | generation. |
> + +----------------------------+-------------------------------------------------------------------+
>
> ``nodes``
> `sequence <https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range>`_ listing
> diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
> index df60a5030e..269d9ec318 100644
> --- a/dts/framework/config/__init__.py
> +++ b/dts/framework/config/__init__.py
> @@ -445,6 +445,7 @@ class TestRunConfiguration:
> system_under_test_node: The SUT node to use in this test run.
> traffic_generator_node: The TG node to use in this test run.
> vdevs: The names of virtual devices to test.
> + random_seed: The seed to use for pseudo-random generation.
> """
>
> build_targets: list[BuildTargetConfiguration]
> @@ -455,6 +456,7 @@ class TestRunConfiguration:
> system_under_test_node: SutNodeConfiguration
> traffic_generator_node: TGNodeConfiguration
> vdevs: list[str]
> + random_seed: int | None
>
> @classmethod
> def from_dict(
> @@ -497,6 +499,7 @@ def from_dict(
> vdevs = (
> d["system_under_test_node"]["vdevs"] if "vdevs" in d["system_under_test_node"] else []
> )
> + random_seed = d.get("random_seed", None)
> return cls(
> build_targets=build_targets,
> perf=d["perf"],
> @@ -506,6 +509,7 @@ def from_dict(
> system_under_test_node=system_under_test_node,
> traffic_generator_node=traffic_generator_node,
> vdevs=vdevs,
> + random_seed=random_seed,
> )
>
> def copy_and_modify(self, **kwargs) -> Self:
> diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json
> index f02a310bb5..df390e8ae2 100644
> --- a/dts/framework/config/conf_yaml_schema.json
> +++ b/dts/framework/config/conf_yaml_schema.json
> @@ -379,6 +379,10 @@
> },
> "traffic_generator_node": {
> "$ref": "#/definitions/node_name"
> + },
> + "random_seed": {
> + "type": "integer",
> + "description": "Optional field. Allows you to set a seed for pseudo-random generation."
> }
> },
> "additionalProperties": false,
> diff --git a/dts/framework/config/types.py b/dts/framework/config/types.py
> index cf16556403..ce7b784ac8 100644
> --- a/dts/framework/config/types.py
> +++ b/dts/framework/config/types.py
> @@ -121,6 +121,8 @@ class TestRunConfigDict(TypedDict):
> system_under_test_node: TestRunSUTConfigDict
> #:
> traffic_generator_node: str
> + #:
> + random_seed: int
>
>
> class ConfigurationDict(TypedDict):
> diff --git a/dts/framework/runner.py b/dts/framework/runner.py
> index 6b6f6a05f5..34b1dad5c4 100644
> --- a/dts/framework/runner.py
> +++ b/dts/framework/runner.py
> @@ -20,6 +20,7 @@
> import importlib
> import inspect
> import os
> +import random
> import re
> import sys
> from pathlib import Path
> @@ -147,6 +148,7 @@ def run(self) -> None:
> self._logger.info(
> f"Running test run with SUT '{test_run_config.system_under_test_node.name}'."
> )
> + self._init_random_seed(test_run_config)
> test_run_result = self._result.add_test_run(test_run_config)
> # we don't want to modify the original config, so create a copy
> test_run_test_suites = list(
> @@ -723,3 +725,9 @@ def _exit_dts(self) -> None:
> self._logger.info("DTS execution has ended.")
>
> sys.exit(self._result.get_return_code())
> +
> + def _init_random_seed(self, conf: TestRunConfiguration) -> None:
> + """Initialize the random seed to use for the test run."""
> + seed = SETTINGS.random_seed or conf.random_seed or random.randrange(0xFFFF_FFFF)
> + self._logger.info(f"Initializing test run with random seed {seed}")
> + random.seed(seed)
> diff --git a/dts/framework/settings.py b/dts/framework/settings.py
> index f6303066d4..7744e37f54 100644
> --- a/dts/framework/settings.py
> +++ b/dts/framework/settings.py
> @@ -66,6 +66,12 @@
>
> Re-run each test case this many times in case of a failure.
>
> +.. option:: --random-seed
> +.. envvar:: DTS_RANDOM_SEED
> +
> + The seed to use with the pseudo-random generator. If not specified, the configuration value is
> + used instead. If that's also not specified, a random seed is generated.
> +
> The module provides one key module-level variable:
>
> Attributes:
> @@ -115,6 +121,8 @@ class Settings:
> test_suites: list[TestSuiteConfig] = field(default_factory=list)
> #:
> re_run: int = 0
> + #:
> + random_seed: int | None = None
>
>
> SETTINGS: Settings = Settings()
> @@ -375,6 +383,15 @@ def _get_parser() -> _DTSArgumentParser:
> )
> _add_env_var_to_action(action, "RERUN")
>
> + action = parser.add_argument(
> + "--random-seed",
> + type=int,
> + help="The seed to use with the pseudo-random generator. If not specified, the configuration"
> + " value is used instead. If that's also not specified, a random seed is generated.",
> + metavar="NUMBER",
> + )
> + _add_env_var_to_action(action)
> +
> return parser
>
>
next prev parent reply other threads:[~2024-08-23 10:30 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-06 12:14 [PATCH 0/4] dts: add pktgen and testpmd changes Luca Vizzarro
2024-08-06 12:14 ` [PATCH 1/5] dts: add ability to send/receive multiple packets Luca Vizzarro
2024-08-06 12:14 ` [PATCH 2/5] dts: add random generation seed setting Luca Vizzarro
2024-08-06 12:14 ` [PATCH 3/5] dts: add random packet generator Luca Vizzarro
2024-08-06 12:14 ` [PATCH 4/5] dts: add ability to start/stop ports Luca Vizzarro
2024-08-06 12:14 ` [PATCH 4/5] dts: add ability to start/stop testpmd ports Luca Vizzarro
2024-08-06 12:14 ` [PATCH 5/5] dts: add testpmd set ports queues Luca Vizzarro
2024-08-06 12:46 ` [PATCH v2 0/5] dts: add pktgen and testpmd changes Luca Vizzarro
2024-08-06 12:46 ` [PATCH v2 1/5] dts: add ability to send/receive multiple packets Luca Vizzarro
2024-08-09 15:10 ` Jeremy Spewock
2024-09-06 16:23 ` Luca Vizzarro
2024-09-09 14:12 ` Jeremy Spewock
2024-08-23 10:17 ` Juraj Linkeš
2024-09-06 16:30 ` Luca Vizzarro
2024-08-06 12:46 ` [PATCH v2 2/5] dts: add random generation seed setting Luca Vizzarro
2024-08-09 15:10 ` Jeremy Spewock
2024-08-23 10:30 ` Juraj Linkeš [this message]
2024-08-06 12:46 ` [PATCH v2 3/5] dts: add random packet generator Luca Vizzarro
2024-08-09 15:11 ` Jeremy Spewock
2024-08-23 11:58 ` Juraj Linkeš
2024-09-06 16:31 ` Luca Vizzarro
2024-08-06 12:46 ` [PATCH v2 4/5] dts: add ability to start/stop testpmd ports Luca Vizzarro
2024-08-09 15:13 ` Jeremy Spewock
2024-09-06 16:41 ` Luca Vizzarro
2024-08-23 12:16 ` Juraj Linkeš
2024-09-06 16:46 ` Luca Vizzarro
2024-09-09 7:32 ` Juraj Linkeš
2024-09-09 14:20 ` Jeremy Spewock
2024-09-09 15:16 ` Juraj Linkeš
2024-08-06 12:46 ` [PATCH v2 5/5] dts: add testpmd set ports queues Luca Vizzarro
2024-08-09 15:14 ` Jeremy Spewock
2024-08-20 16:04 ` Jeremy Spewock
2024-09-06 16:51 ` Luca Vizzarro
2024-08-23 12:22 ` Juraj Linkeš
2024-09-06 16:53 ` Luca Vizzarro
2024-09-09 11:01 ` [PATCH v3 0/5] dts: add pktgen and testpmd changes Luca Vizzarro
2024-09-09 11:01 ` [PATCH v3 1/5] dts: add ability to send/receive multiple packets Luca Vizzarro
2024-09-09 17:12 ` Patrick Robb
2024-09-09 11:01 ` [PATCH v3 2/5] dts: add random generation seed setting Luca Vizzarro
2024-09-09 11:01 ` [PATCH v3 3/5] dts: add random packet generator Luca Vizzarro
2024-09-09 11:01 ` [PATCH v3 4/5] dts: add ability to start/stop testpmd ports Luca Vizzarro
2024-09-09 11:54 ` Juraj Linkeš
2024-09-09 14:20 ` Jeremy Spewock
2024-09-09 11:01 ` [PATCH v3 5/5] dts: add testpmd set ports queues Luca Vizzarro
2024-09-09 12:01 ` Juraj Linkeš
2024-09-09 14:20 ` Jeremy Spewock
2024-09-09 15:50 ` [PATCH 0/4] dts: add pktgen and testpmd changes Juraj Linkeš
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1c74fadc-aa35-4c6d-afcb-7cea14bba771@pantheon.tech \
--to=juraj.linkes@pantheon.tech \
--cc=alex.chapman@arm.com \
--cc=dev@dpdk.org \
--cc=honnappa.nagarahalli@arm.com \
--cc=jspewock@iol.unh.edu \
--cc=luca.vizzarro@arm.com \
--cc=paul.szczepanek@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).