Skip to content
Open
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
15 changes: 15 additions & 0 deletions lisa/operating_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Optional,
Pattern,
Sequence,
Set,
Type,
Union,
)
Expand Down Expand Up @@ -354,6 +355,7 @@ class Posix(OperatingSystem, BaseClassMixin):
def __init__(self, node: Any) -> None:
super().__init__(node, is_posix=True)
self._first_time_installation: bool = True
self._package_metadata_refresh_retried: Set[str] = set()

@classmethod
def type_name(cls) -> str:
Expand Down Expand Up @@ -1237,6 +1239,19 @@ def _is_package_in_repo(self, package: str) -> bool:
result = self._node.execute(command, sudo=True, shell=True)
matched = get_matched_str(result.stdout, self._package_candidate_pattern)
if matched:
if package not in self._package_metadata_refresh_retried:
self._log.debug(
f"Package '{package}' was not found in apt metadata. "
"Refreshing metadata before retrying package lookup."
)
self._initialize_package_installation()
self._package_metadata_refresh_retried.add(package)
result = self._node.execute(command, sudo=True, shell=True)
Comment thread
Copilot marked this conversation as resolved.
matched = get_matched_str(
result.stdout, self._package_candidate_pattern
)
if not matched:
return True
return False
return True

Expand Down
18 changes: 14 additions & 4 deletions lisa/tools/stress_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from lisa.executable import Tool
from lisa.operating_system import CBLMariner, Debian, Posix
from lisa.util import LisaException, RepoNotExistException
from lisa.util.process import Process

from .git import Git
Expand All @@ -27,10 +28,19 @@ def can_install(self) -> bool:
def install(self) -> bool:
posix_os: Posix = cast(Posix, self.node.os)
if posix_os.is_package_in_repo(self.command):
posix_os.install_packages(self.command)
else:
self._install_from_src()
return self._check_exists()
try:
posix_os.install_packages(self.command)
except RepoNotExistException:
raise
except LisaException as package_error:
self._log.debug(
f"failed to install {self.command} from package manager: "
f"{package_error}"
)

if not self._check_exists():
return self._install_from_src()
return True

def launch_vm_stressor(
self, num_workers: int = 0, vm_bytes: str = "", timeout_in_seconds: int = 0
Expand Down
Loading