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 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
29 changes: 29 additions & 0 deletions lisa/operating_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2094,6 +2094,35 @@ def _initialize_package_installation(self) -> None:
"There are no enabled repositories defined in this image.",
)

def _uninstall_packages(
self,
packages: List[str],
signed: bool = True,
timeout: int = 600,
extra_args: Optional[List[str]] = None,
) -> None:
add_args = self._process_extra_package_args(extra_args)
command = f"zypper --non-interactive {add_args}"
if not signed:
command += " --no-gpg-checks "
command += f" rm {' '.join(packages)}"
self.wait_running_process("zypper")
install_result = self._node.execute(
command, shell=True, sudo=True, timeout=timeout
)
if install_result.exit_code in (1, 100):
raise LisaException(
f"Failed to install {packages}. exit_code: {install_result.exit_code}, "
f"stderr: {install_result.stderr}"
)
elif install_result.exit_code == 0:
self._log.debug(f"{packages} is/are installed successfully.")
else:
self._log.debug(
Copy link
Member

Choose a reason for hiding this comment

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

Should the reboot be a specified exit code? Why are only 1/100 failed codes?

Copy link
Collaborator Author

@mcgov mcgov Jan 14, 2025

Choose a reason for hiding this comment

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

I am following the convention of the install_packages code for SUSE. I'm assuming it was based on https://manpages.opensuse.org/Tumbleweed/zypper/zypper.8.en.html

The others seem to be info error codes

Copy link
Member

Choose a reason for hiding this comment

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

I read the doc, I feel only 0 means success. For example, 2 means command parameter errors, 3 means invalid args ...

f"{packages} is/are installed."
" A system reboot or package manager restart might be required."
)

def _install_packages(
self,
packages: List[str],
Expand Down
23 changes: 20 additions & 3 deletions lisa/tools/meson.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,25 @@ def can_install(self) -> bool:
def _install(self) -> bool:
posix_os: Posix = cast(Posix, self.node.os)
# use pip to make sure we install a recent version
if (not posix_os.package_exists("meson")) or posix_os.get_package_information(
"meson", use_cached=False
) < "0.52.0":

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"
):
package_installed = pkg
break
elif posix_os.is_package_in_repo(pkg):
package_available = pkg
break

if package_installed:
return self._check_exists()
if package_available:
posix_os.install_packages(package_available)
else:
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 :\
Expand All @@ -48,6 +64,7 @@ def _install(self) -> bool:
no_info_log=True,
no_error_log=True,
)

return self._check_exists()

def setup(self, args: str, cwd: PurePath, build_dir: str = "build") -> PurePath:
Expand Down
6 changes: 6 additions & 0 deletions microsoft/testsuites/dpdk/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ def __init__(
matcher: Callable[[Posix], bool],
packages: Optional[Sequence[Union[str, Tool, Type[Tool]]]] = None,
stop_on_match: bool = False,
requires_reboot: bool = False,
) -> None:
self.matcher = matcher
self.packages = packages
self.stop_on_match = stop_on_match
self.requires_reboot = requires_reboot


class DependencyInstaller:
Expand All @@ -65,6 +67,10 @@ def install_required_packages(
for requirement in self.requirements:
if requirement.matcher(os) and requirement.packages:
packages += requirement.packages
if requirement.requires_reboot:
os.install_packages(packages=packages, extra_args=extra_args)
packages = []
node.reboot()
if requirement.stop_on_match:
break
os.install_packages(packages=packages, extra_args=extra_args)
Expand Down
4 changes: 3 additions & 1 deletion microsoft/testsuites/dpdk/dpdktestpmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
and bool(x.get_kernel_information().version >= "5.15.0")
and x.is_package_in_repo("linux-modules-extra-azure"),
packages=["linux-modules-extra-azure"],
requires_reboot=True,
),
OsPackageDependencies(
matcher=lambda x: isinstance(x, Debian),
Expand Down Expand Up @@ -226,7 +227,8 @@ def _setup_node(self) -> None:
# which breaks when another tool checks for it's existence before building...
# like cmake, meson, make, autoconf, etc.
self._node.tools[Ninja].install()
self._node.tools[Pip].install_packages("pyelftools")
if not isinstance(self._os, Debian):
self._node.tools[Pip].install_packages("pyelftools")

def _uninstall(self) -> None:
# undo source installation (thanks ninja)
Expand Down
Loading