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

Skip storage testcases if nvme cmd doesn't have 'NameSpace' in output. #3685

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Mariner 2 issue fix
  • Loading branch information
SRIKKANTH committed Feb 28, 2025
commit 33dc322421ebc820813500cd105f41a7af89c741
2 changes: 1 addition & 1 deletion lisa/sut_orchestrator/azure/features.py
Original file line number Diff line number Diff line change
@@ -1814,7 +1814,7 @@ def get_luns(self) -> Dict[str, int]:
if node_disk.get_os_disk_controller_type() == schema.DiskControllerType.NVME:
data_disks = self.get_raw_data_disks()
nvme_device_ids = self._node.tools[Nvmecli].get_namespace_ids(
force_run=True
force_run=True, log=self._log
)

for nvme_device_id in nvme_device_ids:
26 changes: 22 additions & 4 deletions lisa/tools/nvmecli.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@
from lisa.executable import Tool
from lisa.operating_system import Posix
from lisa.tools import Git, Make
from lisa.util import SkippedException, find_patterns_in_lines
from lisa.util import LisaException, SkippedException, find_patterns_in_lines
from lisa.util.logger import Logger
from lisa.util.process import ExecutableResult


@@ -107,7 +108,18 @@ def get_namespaces(self, force_run: bool = False) -> List[str]:
return namespaces_cli

def get_devices(self, force_run: bool = False) -> Any:
nvme_list = self.run("list -o json", shell=True, sudo=True, force_run=force_run)
nvme_list = self.run(
"list -o json 2>/dev/null",
shell=True,
sudo=True,
force_run=force_run,
no_error_log=True,
)
if not nvme_list.stdout:
raise LisaException(
"No NVMe devices found. "
"The 'nvme list' command returned an empty string."
)
nvme_devices = json.loads(nvme_list.stdout)
return nvme_devices["Devices"]

@@ -159,13 +171,19 @@ def get_disks(self, force_run: bool = False) -> List[str]:
# /dev/nvme1n1 68e8d42a7ed4e5f90002 Microsoft NVMe Direct Disk v2 1 472.45 GB / 472.45 GB 512 B + 0 B NVMDV00 # noqa: E501
# /dev/nvme2n1 68e8d42a7ed4e5f90001 Microsoft NVMe Direct Disk v2 1 472.45 GB / 472.45 GB 512 B + 0 B NVMDV00 # noqa: E501

def get_namespace_ids(self, force_run: bool = False) -> List[Dict[str, int]]:
def get_namespace_ids(
self, log: Logger, force_run: bool = False
) -> List[Dict[str, int]]:
nvme_devices = self.get_devices(force_run=force_run)
# Older versions of nvme-cli do not have the NameSpace key in the output
# skip the test if NameSpace key is not available
if not nvme_devices or "NameSpace" not in nvme_devices[0]:
log.debug(
"'NameSpace' key is not available in 'nvme -list -o json' output, skip"
)
raise SkippedException(
"'NameSpace' key is not available in 'nvme -list -o json' output"
"The version of nvme-cli is too old,"
" it doesn't support to get namespace id."
)

return [
Loading
Oops, something went wrong.