Skip to content

Commit

Permalink
Handle different format of nvme cli 2.11
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 704445519
  • Loading branch information
Arushi-07 authored and copybara-github committed Dec 9, 2024
1 parent 5cd0147 commit 6bae0d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 7 additions & 1 deletion perfkitbenchmarker/linux_virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2167,7 +2167,13 @@ def GetNVMEDeviceInfo(self):
self.InstallPackages('nvme-cli')
version_str, _ = self.RemoteCommand('sudo nvme --version')
version_num = version_str.split()[2]
if packaging_version.parse(version_num) >= packaging_version.parse('1.5'):
# TODO(arushigaur): Version check can be removed and we can just parse
# the raw output.
if packaging_version.parse(version_num) >= packaging_version.parse(
'1.5'
) and packaging_version.parse(version_num) < packaging_version.parse(
'2.11'
):
stdout, _ = self.RemoteCommand('sudo nvme list --output-format json')
if not stdout:
return []
Expand Down
12 changes: 10 additions & 2 deletions tests/providers/gcp/gce_disk_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ def testPdStandardOnLinux(self):
fake_rets = [
('stdout', 'stderr', 0),
('stdout', 'stderr', 0),
('20 20 201', 'stderr', 0),
(
'nvme version 2.8 (git 2.8)\nlibnvme version 1.8 (git 1.8)',
'stderr',
0,
),
('', 'stderr', 0),
('/dev/nvme0n1', 'stderr', 0),
('0', 'stderr', 0),
Expand Down Expand Up @@ -295,7 +299,11 @@ def testPdExtremeOnCreateWithVMLinux(self):
('', '', 0),
('stdout', 'stderr', 0),
('stdout', 'stderr', 0),
('20 20 201', 'stderr', 0),
(
'nvme version 2.8 (git 2.8)\nlibnvme version 1.8 (git 1.8)',
'stderr',
0,
),
('', 'stderr', 0),
('/dev/nvme0n1', 'stderr', 0),
('0', 'stderr', 0),
Expand Down

0 comments on commit 6bae0d9

Please sign in to comment.