[v2,7/7] dts: remove git ref option

Message ID 20241021134935.1210500-8-luca.vizzarro@arm.com (mailing list archive)
State Superseded, archived
Delegated to: Paul Szczepanek
Headers
Series DTS external DPDK build |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Luca Vizzarro Oct. 21, 2024, 1:49 p.m. UTC
From: Tomáš Ďurovec <tomas.durovec@pantheon.tech>

Given the whole DPDK tree directory can now be copied to the nodes,
there is no more need to use the git ref option, as the tree can be
controlled directly by the user.

Signed-off-by: Tomáš Ďurovec <tomas.durovec@pantheon.tech>
Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
---
 doc/guides/tools/dts.rst  |   9 ---
 dts/framework/settings.py |  48 ++-------------
 dts/framework/utils.py    | 119 +-------------------------------------
 3 files changed, 7 insertions(+), 169 deletions(-)
  

Comments

Dean Marx Oct. 25, 2024, 6:31 p.m. UTC | #1
On Mon, Oct 21, 2024 at 9:50 AM Luca Vizzarro <luca.vizzarro@arm.com> wrote:

> From: Tomáš Ďurovec <tomas.durovec@pantheon.tech>
>
> Given the whole DPDK tree directory can now be copied to the nodes,
> there is no more need to use the git ref option, as the tree can be
> controlled directly by the user.
>
> Signed-off-by: Tomáš Ďurovec <tomas.durovec@pantheon.tech>
> Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
>

Reviewed-by: Dean Marx <dmarx@iol.unh.edu>
  
Patrick Robb Oct. 29, 2024, 1:28 a.m. UTC | #2
On Mon, Oct 21, 2024 at 9:50 AM Luca Vizzarro <luca.vizzarro@arm.com> wrote:

> From: Tomáš Ďurovec <tomas.durovec@pantheon.tech>
>
> Given the whole DPDK tree directory can now be copied to the nodes,
> there is no more need to use the git ref option, as the tree can be
> controlled directly by the user.
>
> Signed-off-by: Tomáš Ďurovec <tomas.durovec@pantheon.tech>
> Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
> ---
>  doc/guides/tools/dts.rst  |   9 ---
>  dts/framework/settings.py |  48 ++-------------
>  dts/framework/utils.py    | 119 +-------------------------------------
>  3 files changed, 7 insertions(+), 169 deletions(-)
>
> diff --git a/doc/guides/tools/dts.rst b/doc/guides/tools/dts.rst
> index 7b90c4856e..a00d987ece 100644
> --- a/doc/guides/tools/dts.rst
> +++ b/doc/guides/tools/dts.rst
> @@ -237,9 +237,6 @@ DTS is run with ``main.py`` located in the ``dts``
> directory after entering Poet
>     -t SECONDS, --timeout SECONDS
>                             [DTS_TIMEOUT] The default timeout for all DTS
> operations except for compiling DPDK. (default: 15)
>     -v, --verbose           [DTS_VERBOSE] Specify to enable verbose
> output, logging all messages to the console. (default: False)
> -   --revision ID, --rev ID, --git-ref ID
> -                           [DTS_DPDK_REVISION_ID] Git revision ID to
> test. Could be commit, tag, tree ID etc. To test local changes, first
> -                           commit them, then use their commit ID.
> (default: None)
>     --compile-timeout SECONDS
>                             [DTS_COMPILE_TIMEOUT] The timeout for
> compiling DPDK. (default: 1200)
>     --test-suite TEST_SUITE [TEST_CASES ...]
> @@ -275,12 +272,6 @@ The minimum DTS needs is a config file and a
> pre-built DPDK or DPDK
>  sources location which can be specified in said config file or on the
>  command line or environment variables.
>
> -Example command for running DTS with the template configuration and DPDK
> tag v23.11:
> -
> -.. code-block:: console
> -
> -   (dts-py3.10) $ ./main.py --git-ref v23.11
> -
>

I see this needs to go because of the --git-ref usage. Can this be replaced
with a new example command? Perhaps even 2, one for each of --tarball and
--dpdk-tree?


Reviewed-by: Patrick Robb <probb@iol.unh.edu>
  
Luca Vizzarro Oct. 29, 2024, 11:51 a.m. UTC | #3
Hi Patrick,

On 29/10/2024 01:28, Patrick Robb wrote:
>     -Example command for running DTS with the template configuration and
>     DPDK tag v23.11:
>     -
>     -.. code-block:: console
>     -
>     -   (dts-py3.10) $ ./main.py --git-ref v23.11
>     -
> 
> 
> I see this needs to go because of the --git-ref usage. Can this be 
> replaced with a new example command? Perhaps even 2, one for each of -- 
> tarball and --dpdk-tree?

These patches make these command line arguments optional, and instead of 
being the primary source of DPDK, they become overrides of the 
configuration fields. The original doc snippet was there as it was 
mandatory to make it work, but it's no longer the case given the 
configuration must be completed or DTS won't run. And naturall with a 
completed configuration there is no further need to use CLI arguments.

Hope this clarifies!

Best,
Luca
  

Patch

diff --git a/doc/guides/tools/dts.rst b/doc/guides/tools/dts.rst
index 7b90c4856e..a00d987ece 100644
--- a/doc/guides/tools/dts.rst
+++ b/doc/guides/tools/dts.rst
@@ -237,9 +237,6 @@  DTS is run with ``main.py`` located in the ``dts`` directory after entering Poet
    -t SECONDS, --timeout SECONDS
                            [DTS_TIMEOUT] The default timeout for all DTS operations except for compiling DPDK. (default: 15)
    -v, --verbose           [DTS_VERBOSE] Specify to enable verbose output, logging all messages to the console. (default: False)
-   --revision ID, --rev ID, --git-ref ID
-                           [DTS_DPDK_REVISION_ID] Git revision ID to test. Could be commit, tag, tree ID etc. To test local changes, first
-                           commit them, then use their commit ID. (default: None)
    --compile-timeout SECONDS
                            [DTS_COMPILE_TIMEOUT] The timeout for compiling DPDK. (default: 1200)
    --test-suite TEST_SUITE [TEST_CASES ...]
@@ -275,12 +272,6 @@  The minimum DTS needs is a config file and a pre-built DPDK or DPDK
 sources location which can be specified in said config file or on the
 command line or environment variables.
 
-Example command for running DTS with the template configuration and DPDK tag v23.11:
-
-.. code-block:: console
-
-   (dts-py3.10) $ ./main.py --git-ref v23.11
-
 
 DTS Results
 ~~~~~~~~~~~
diff --git a/dts/framework/settings.py b/dts/framework/settings.py
index 08529805da..a452319b90 100644
--- a/dts/framework/settings.py
+++ b/dts/framework/settings.py
@@ -42,21 +42,14 @@ 
 .. option:: --dpdk-tree
 .. envvar:: DTS_DPDK_TREE
 
-    The path to the DPDK source tree directory to test. Cannot be used in conjunction with --tarball
-    and --revision.
+    The path to the DPDK source tree directory to test. Cannot be used in conjunction with
+    --tarball.
 
 .. option:: --tarball, --snapshot
 .. envvar:: DTS_DPDK_TARBALL
 
     The path to the DPDK source tarball to test. DPDK must be contained in a folder with the same
-    name as the tarball file. Cannot be used in conjunction with --dpdk-tree and
-    --revision.
-
-.. option:: --revision, --rev, --git-ref
-.. envvar:: DTS_DPDK_REVISION_ID
-
-    Git revision ID to test. Could be commit, tag, tree ID etc. To test local changes, first commit
-    them, then use their commit ID. Cannot be used in conjunction with --dpdk-tree and --tarball.
+    name as the tarball file. Cannot be used in conjunction with --dpdk-tree.
 
 .. option:: --remote-source
 .. envvar:: DTS_REMOTE_SOURCE
@@ -109,8 +102,6 @@ 
 from typing import Callable
 
 from .config import DPDKLocation, TestSuiteConfig
-from .exception import ConfigurationError
-from .utils import DPDKGitTarball, get_commit_id
 
 
 @dataclass(slots=True)
@@ -257,14 +248,6 @@  def _get_help_string(self, action):
         return help
 
 
-def _parse_revision_id(rev_id: str) -> str:
-    """Validate revision ID and retrieve corresponding commit ID."""
-    try:
-        return get_commit_id(rev_id)
-    except ConfigurationError:
-        raise argparse.ArgumentTypeError("The Git revision ID supplied is invalid or ambiguous")
-
-
 def _required_with_one_of(parser: _DTSArgumentParser, action: Action, *required_dests: str) -> None:
     """Verify that `action` is listed together with at least one of `required_dests`.
 
@@ -372,7 +355,7 @@  def _get_parser() -> _DTSArgumentParser:
     action = dpdk_source.add_argument(
         "--dpdk-tree",
         help="The path to the DPDK source tree directory to test. Cannot be used in conjunction "
-        "with --tarball and --revision.",
+        "with --tarball.",
         metavar="DIR_PATH",
         dest="dpdk_tree_path",
     )
@@ -382,26 +365,12 @@  def _get_parser() -> _DTSArgumentParser:
         "--tarball",
         "--snapshot",
         help="The path to the DPDK source tarball to test. DPDK must be contained in a folder with "
-        "the same name as the tarball file. Cannot be used in conjunction with --dpdk-tree and "
-        "--revision.",
+        "the same name as the tarball file. Cannot be used in conjunction with --dpdk-tree.",
         metavar="FILE_PATH",
         dest="dpdk_tarball_path",
     )
     _add_env_var_to_action(action, "DPDK_TARBALL")
 
-    action = dpdk_source.add_argument(
-        "--revision",
-        "--rev",
-        "--git-ref",
-        type=_parse_revision_id,
-        help="Git revision ID to test. Could be commit, tag, tree ID etc. To test local changes, "
-        "first commit them, then use their commit ID. Cannot be used in conjunction with "
-        "--dpdk-tree and --tarball.",
-        metavar="ID",
-        dest="dpdk_revision_id",
-    )
-    _add_env_var_to_action(action)
-
     action = dpdk_build.add_argument(
         "--remote-source",
         action="store_true",
@@ -410,9 +379,7 @@  def _get_parser() -> _DTSArgumentParser:
         "the SUT node. Can only be used with --dpdk-tree or --tarball.",
     )
     _add_env_var_to_action(action)
-    _required_with_one_of(
-        parser, action, "dpdk_tarball_path", "dpdk_tree_path"
-    )  # ignored if passed with git-ref
+    _required_with_one_of(parser, action, "dpdk_tarball_path", "dpdk_tree_path")
 
     action = dpdk_build.add_argument(
         "--precompiled-build-dir",
@@ -568,9 +535,6 @@  def get_settings() -> Settings:
 
     args = parser.parse_args()
 
-    if args.dpdk_revision_id:
-        args.dpdk_tarball_path = Path(DPDKGitTarball(args.dpdk_revision_id, args.output_dir))
-
     args.dpdk_location = _process_dpdk_location(
         args.dpdk_tree_path, args.dpdk_tarball_path, args.remote_source, args.precompiled_build_dir
     )
diff --git a/dts/framework/utils.py b/dts/framework/utils.py
index 04b5813613..78a39e32c7 100644
--- a/dts/framework/utils.py
+++ b/dts/framework/utils.py
@@ -14,22 +14,19 @@ 
     REGEX_FOR_PCI_ADDRESS: The regex representing a PCI address, e.g. ``0000:00:08.0``.
 """
 
-import atexit
 import fnmatch
 import json
 import os
 import random
-import subprocess
 import tarfile
 from enum import Enum, Flag
 from pathlib import Path
-from subprocess import SubprocessError
 from typing import Any, Callable
 
 from scapy.layers.inet import IP, TCP, UDP, Ether  # type: ignore[import-untyped]
 from scapy.packet import Packet  # type: ignore[import-untyped]
 
-from .exception import ConfigurationError, InternalError
+from .exception import InternalError
 
 REGEX_FOR_PCI_ADDRESS: str = "/[0-9a-fA-F]{4}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}.[0-9]{1}/"
 _REGEX_FOR_COLON_OR_HYPHEN_SEP_MAC: str = r"(?:[\da-fA-F]{2}[:-]){5}[\da-fA-F]{2}"
@@ -80,31 +77,6 @@  def get_packet_summaries(packets: list[Packet]) -> str:
     return f"Packet contents: \n{packet_summaries}"
 
 
-def get_commit_id(rev_id: str) -> str:
-    """Given a Git revision ID, return the corresponding commit ID.
-
-    Args:
-        rev_id: The Git revision ID.
-
-    Raises:
-        ConfigurationError: The ``git rev-parse`` command failed, suggesting
-            an invalid or ambiguous revision ID was supplied.
-    """
-    result = subprocess.run(
-        ["git", "rev-parse", "--verify", rev_id],
-        text=True,
-        capture_output=True,
-    )
-    if result.returncode != 0:
-        raise ConfigurationError(
-            f"{rev_id} is not a valid git reference.\n"
-            f"Command: {result.args}\n"
-            f"Stdout: {result.stdout}\n"
-            f"Stderr: {result.stderr}"
-        )
-    return result.stdout.strip()
-
-
 class StrEnum(Enum):
     """Enum with members stored as strings."""
 
@@ -180,95 +152,6 @@  def extension(self):
         return f"{self.value}" if self == self.none else f"{self.none.value}.{self.value}"
 
 
-class DPDKGitTarball:
-    """Compressed tarball of DPDK from the repository.
-
-    The class supports the :class:`os.PathLike` protocol,
-    which is used to get the Path of the tarball::
-
-        from pathlib import Path
-        tarball = DPDKGitTarball("HEAD", "output")
-        tarball_path = Path(tarball)
-    """
-
-    _git_ref: str
-    _tar_compression_format: TarCompressionFormat
-    _tarball_dir: Path
-    _tarball_name: str
-    _tarball_path: Path | None
-
-    def __init__(
-        self,
-        git_ref: str,
-        output_dir: str,
-        tar_compression_format: TarCompressionFormat = TarCompressionFormat.xz,
-    ):
-        """Create the tarball during initialization.
-
-        The DPDK version is specified with `git_ref`. The tarball will be compressed with
-        `tar_compression_format`, which must be supported by the DTS execution environment.
-        The resulting tarball will be put into `output_dir`.
-
-        Args:
-            git_ref: A git commit ID, tag ID or tree ID.
-            output_dir: The directory where to put the resulting tarball.
-            tar_compression_format: The compression format to use.
-        """
-        self._git_ref = git_ref
-        self._tar_compression_format = tar_compression_format
-
-        self._tarball_dir = Path(output_dir, "tarball")
-
-        self._create_tarball_dir()
-
-        self._tarball_name = (
-            f"dpdk-tarball-{self._git_ref}.{self._tar_compression_format.extension}"
-        )
-        self._tarball_path = self._check_tarball_path()
-        if not self._tarball_path:
-            self._create_tarball()
-
-    def _create_tarball_dir(self) -> None:
-        os.makedirs(self._tarball_dir, exist_ok=True)
-
-    def _check_tarball_path(self) -> Path | None:
-        if self._tarball_name in os.listdir(self._tarball_dir):
-            return Path(self._tarball_dir, self._tarball_name)
-        return None
-
-    def _create_tarball(self) -> None:
-        self._tarball_path = Path(self._tarball_dir, self._tarball_name)
-
-        atexit.register(self._delete_tarball)
-
-        result = subprocess.run(
-            'git -C "$(git rev-parse --show-toplevel)" archive '
-            f'{self._git_ref} --prefix="dpdk-tarball-{self._git_ref + os.sep}" | '
-            f"{self._tar_compression_format} > {Path(self._tarball_path.absolute())}",
-            shell=True,
-            text=True,
-            capture_output=True,
-        )
-
-        if result.returncode != 0:
-            raise SubprocessError(
-                f"Git archive creation failed with exit code {result.returncode}.\n"
-                f"Command: {result.args}\n"
-                f"Stdout: {result.stdout}\n"
-                f"Stderr: {result.stderr}"
-            )
-
-        atexit.unregister(self._delete_tarball)
-
-    def _delete_tarball(self) -> None:
-        if self._tarball_path and os.path.exists(self._tarball_path):
-            os.remove(self._tarball_path)
-
-    def __fspath__(self) -> str:
-        """The os.PathLike protocol implementation."""
-        return str(self._tarball_path)
-
-
 def convert_to_list_of_string(value: Any | list[Any]) -> list[str]:
     """Convert the input to the list of strings."""
     return list(map(str, value) if isinstance(value, list) else str(value))