From c36e493a9011db67ab8451e7e32f146ebfc28cef Mon Sep 17 00:00:00 2001 From: "Matthew G. McGovern" Date: Mon, 14 Feb 2022 13:23:39 -0800 Subject: [PATCH] OVS test: add support for RHEL --- lisa/node.py | 7 ++++++- microsoft/testsuites/dpdk/dpdkovs.py | 25 ++++++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lisa/node.py b/lisa/node.py index aae6f8ab7b..cf4ea21e02 100644 --- a/lisa/node.py +++ b/lisa/node.py @@ -262,7 +262,12 @@ def capture_system_information(self, name: str = "") -> None: def find_partition_with_freespace(self, size_in_gb: int) -> str: if self.os.is_windows: - raise NotImplementedError() + raise NotImplementedError( + ( + "find_partition_with_freespace was called on a Windows node, " + "this function is not implemented for Windows" + ) + ) df = self.tools[Df] home_partition = df.get_partition_by_mountpoint("/home") diff --git a/microsoft/testsuites/dpdk/dpdkovs.py b/microsoft/testsuites/dpdk/dpdkovs.py index 289009277c..871a220bc6 100644 --- a/microsoft/testsuites/dpdk/dpdkovs.py +++ b/microsoft/testsuites/dpdk/dpdkovs.py @@ -7,8 +7,8 @@ from semver import VersionInfo from lisa.executable import Tool -from lisa.operating_system import Debian -from lisa.tools import Gcc, Git, Ip, Make, Modprobe, Uname +from lisa.operating_system import Debian, Fedora +from lisa.tools import Chown, Gcc, Git, Ip, Make, Modprobe, Uname, Whoami from lisa.util import UnsupportedDistroException from microsoft.testsuites.dpdk.dpdktestpmd import DpdkTestpmd @@ -46,12 +46,18 @@ def dependencies(self) -> List[Type[Tool]]: @property def can_install(self) -> bool: kernel_version = self.node.tools[Uname].get_linux_information().kernel_version - return kernel_version > "4.4.0" and isinstance(self.node.os, Debian) + return kernel_version > "4.4.0" and ( + isinstance(self.node.os, Debian) or isinstance(self.node.os, Fedora) + ) def _install_os_packages(self) -> None: os = self.node.os if isinstance(os, Debian): os.install_packages(list(self.ubuntu_packages)) + elif isinstance(self.node.os, Fedora): + # NOTE: RHEL 8 works without additional packages, + # an edit may be needed later after further testing. + pass else: raise UnsupportedDistroException( os, @@ -62,14 +68,23 @@ def _install(self) -> bool: # NOTE: defer building until we can provide the DPDK source dir as a parameter. # _install just checks out our resources and sets up the version info # TODO: Add option to select which OVS version to use other than latest - + node = self.node self._install_os_packages() + # NOTE: dpdk build is big, use this function to find a safe spot to build. + build_path = node.find_partition_with_freespace(size_in_gb=30) + self.ovs_build_path = node.get_pure_path(build_path).joinpath("ovs_build") + + # create the dir and chown it since partition ownership is not guaranteed + node.shell.mkdir(self.ovs_build_path) + username = node.tools[Whoami].get_username() + node.tools[Chown].change_owner(self.ovs_build_path, username, recurse=True) + # checkout git and get latest version tag git = self.node.tools[Git] self.repo_dir = git.clone( "https://github.com/openvswitch/ovs.git", - cwd=self.node.working_path, + cwd=self.ovs_build_path, ) latest_version_tag = git.get_tag(cwd=self.repo_dir) git.checkout(latest_version_tag, cwd=self.repo_dir)