From 6bae0d97c42b06382b69a40dacc0544df3b3c116 Mon Sep 17 00:00:00 2001 From: Arushi Gaur Date: Mon, 9 Dec 2024 15:52:22 -0800 Subject: [PATCH] Handle different format of nvme cli 2.11 PiperOrigin-RevId: 704445519 --- perfkitbenchmarker/linux_virtual_machine.py | 8 +++++++- tests/providers/gcp/gce_disk_test.py | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/perfkitbenchmarker/linux_virtual_machine.py b/perfkitbenchmarker/linux_virtual_machine.py index 94cd21f43..8410b1b31 100644 --- a/perfkitbenchmarker/linux_virtual_machine.py +++ b/perfkitbenchmarker/linux_virtual_machine.py @@ -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 [] diff --git a/tests/providers/gcp/gce_disk_test.py b/tests/providers/gcp/gce_disk_test.py index b691e5a28..ca31dac30 100644 --- a/tests/providers/gcp/gce_disk_test.py +++ b/tests/providers/gcp/gce_disk_test.py @@ -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), @@ -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),