Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DPDK: install path fixes for meson and Ubuntu 24.04 #3598

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions lisa/operating_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,24 @@ def uninstall_packages(
package_names = self._get_package_list(packages)
self._uninstall_packages(package_names, signed, timeout, extra_args)

def package_exists(self, package: Union[str, Tool, Type[Tool]]) -> bool:
def package_exists(
self,
package: Union[str, Tool, Type[Tool]],
minimum_version: Optional[VersionInfo] = None,
) -> bool:
"""
Query if a package/tool is installed on the node.
Return Value - bool
"""
package_name = self.__resolve_package_name(package)
return self._package_exists(package_name)
exists = self._package_exists(package_name)
if exists and minimum_version:
return (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to print debug message, if min version is not met. It saves time to troubleshooting the reason.

self.get_package_information(package_name=package_name)
>= minimum_version
)
else:
return exists

def is_package_in_repo(self, package: Union[str, Tool, Type[Tool]]) -> bool:
"""
Expand Down
32 changes: 24 additions & 8 deletions lisa/tools/meson.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@


class Meson(Tool):
_minimum_version = VersionInfo(major=0, minor=52, patch=0)

@property
def command(self) -> str:
return "meson"

def _check_exists(self) -> bool:
result = self.node.execute("meson --version", shell=True)
return result.exit_code == 0 and VersionInfo.parse(result.stdout) >= "0.52.0"
return (
result.exit_code == 0
and VersionInfo.parse(result.stdout) >= self._minimum_version
)

@property
def can_install(self) -> bool:
Expand All @@ -33,25 +38,36 @@ def _install(self) -> bool:

package_installed = ""
package_available = ""
for pkg in ["meson", "python3-meson"]:
if (
posix_os.package_exists(pkg)
and posix_os.get_package_information(pkg, use_cached=False) >= "0.52.0"
):
# packaged as 'meson' on older systems and 'python3-meson' on newer ones,
# since it's actually just a python package.
# So check for both
for pkg in [
"python3-meson",
"meson",
]:
if posix_os.package_exists(pkg, minimum_version=self._minimum_version):
package_installed = pkg
squirrelsc marked this conversation as resolved.
Show resolved Hide resolved
break
elif posix_os.is_package_in_repo(pkg):
package_available = pkg
break

# prefer the packaged version as long as it's the right version
if package_installed:
return self._check_exists()
if package_available:
posix_os.install_packages(package_available)
else:
# verify version is correct if it's installed from pkg manager
if not posix_os.package_exists(pkg, minimum_version=self._minimum_version):
posix_os.uninstall_packages(pkg)
package_available = ""

# otherwise, install with pip
# this can get weird on some systems since they have started
# returning an error code if you try to use pip without a venv
if not (package_available or package_installed):
username = self.node.tools[Whoami].get_username()
self.node.tools[Pip].install_packages("meson", install_to_user=True)
# environment variables won't expand even when using shell=True :\
self.node.tools[Ln].create_link(
f"/home/{username}/.local/bin/meson", "/usr/bin/meson", force=True
)
Expand Down
5 changes: 2 additions & 3 deletions microsoft/testsuites/dpdk/dpdktestpmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@
"dpkg-dev",
"pkg-config",
"python3-pip",
"python3-pyelftools",
"python-pyelftools",
# 18.04 doesn't need linux-modules-extra-azure
# since it will never have MANA support
],
Expand All @@ -128,7 +126,6 @@
"build-essential",
"libnuma-dev",
"libmnl-dev",
"python3-pyelftools",
"libelf-dev",
"pkg-config",
],
Expand Down Expand Up @@ -228,6 +225,8 @@ def _setup_node(self) -> None:
# like cmake, meson, make, autoconf, etc.
self._node.tools[Ninja].install()
if not isinstance(self._os, Debian):
self._os.install_packages("python3-pyelftools")
else:
self._node.tools[Pip].install_packages("pyelftools")
squirrelsc marked this conversation as resolved.
Show resolved Hide resolved

def _uninstall(self) -> None:
Expand Down
3 changes: 2 additions & 1 deletion microsoft/testsuites/dpdk/rdmacore.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ def _check_if_installed(self) -> bool:

def _setup_node(self) -> None:
if isinstance(self._os, (Debian, Fedora, Suse)):
self._os.uninstall_packages("rdma-core")
if self._os.package_exists("rdma-core"):
self._os.uninstall_packages("rdma-core")
if isinstance(self._os, Fedora):
self._os.group_install_packages("Development Tools")
super()._setup_node()
Expand Down
Loading