diff --git a/lisa/util/__init__.py b/lisa/util/__init__.py index 950e1feb1..24d050196 100644 --- a/lisa/util/__init__.py +++ b/lisa/util/__init__.py @@ -391,6 +391,10 @@ class InitializableMixin: self._is_initialized = False raise identifier + def reinitialize(self, *args: Any, **kwargs: Any) -> None: + self._is_initialized = False + self.initialize() + class BaseClassMixin: @classmethod diff --git a/microsoft/testsuites/dpdk/common.py b/microsoft/testsuites/dpdk/common.py index b67c0e17a..c187df4a0 100644 --- a/microsoft/testsuites/dpdk/common.py +++ b/microsoft/testsuites/dpdk/common.py @@ -192,7 +192,7 @@ class Installer: self._download_assets() # remove an installation - def _uninstall(self) -> None: + def uninstall(self) -> None: raise NotImplementedError(f"_clean_previous_installation {self._err_msg}") # install the dependencies @@ -216,7 +216,7 @@ class Installer: def do_installation(self, required_version: Optional[VersionInfo] = None) -> None: self._setup_node() if self._should_install(): - self._uninstall() + self.uninstall() self._install_dependencies() self._install() @@ -243,7 +243,7 @@ class PackageManagerInstall(Installer): super().__init__(node, os_dependencies) # uninstall from the package manager - def _uninstall(self) -> None: + def uninstall(self) -> None: if not (isinstance(self._os, Posix) and self._check_if_installed()): return if self._os_dependencies is not None: diff --git a/microsoft/testsuites/dpdk/dpdksuite.py b/microsoft/testsuites/dpdk/dpdksuite.py index 47ef1c8b7..e23a1390b 100644 --- a/microsoft/testsuites/dpdk/dpdksuite.py +++ b/microsoft/testsuites/dpdk/dpdksuite.py @@ -28,6 +28,7 @@ from lisa.tools.hugepages import HugePageSize from lisa.util.constants import SIGINT from microsoft.testsuites.dpdk.common import ( DPDK_STABLE_GIT_REPO, + PackageManagerInstall, force_dpdk_default_source, ) from microsoft.testsuites.dpdk.dpdknffgo import DpdkNffGo @@ -527,7 +528,10 @@ class Dpdk(TestSuite): except (NotEnoughMemoryException, UnsupportedOperationException) as err: raise SkippedException(err) testpmd = test_kit.testpmd - + if isinstance(testpmd.installer, PackageManagerInstall): + testpmd.installer.uninstall() + testpmd.reinitialize() + testpmd.install() # grab a nic and run testpmd git = node.tools[Git] make = node.tools[Make] diff --git a/microsoft/testsuites/dpdk/dpdktestpmd.py b/microsoft/testsuites/dpdk/dpdktestpmd.py index f6a361867..f1e90b4bd 100644 --- a/microsoft/testsuites/dpdk/dpdktestpmd.py +++ b/microsoft/testsuites/dpdk/dpdktestpmd.py @@ -208,7 +208,7 @@ class DpdkSourceInstall(Installer): self._node.tools[Ninja].install() self._node.tools[Pip].install_packages("pyelftools") - def _uninstall(self) -> None: + def uninstall(self) -> None: # undo source installation (thanks ninja) if not self._check_if_installed(): return