Add missing exception
Change Idd49b0c70caedfcd42420ffa2ac926a6087d406e added support for discovery of PMEM devices by the libvirt driver. Some error handling code in this was expected to raise a 'GetPMEMNamespacesFailed' exception, however, a typo meant the exception was actually called 'GetPMEMNamespaceFailed' (singular). This exception was later removed in change I6fd027fb51823b8a8a24ed7b864a2191c4e8e8c0 because it had no references. Re-introduce the exception, this time with the correct name, and add some unit tests to prevent us regressing. Change-Id: I3b597a46314a1b29a952fc0f7a9c4537341e37b8 Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Closes-Bug: #1904446
This commit is contained in:
parent
43b8df3ae8
commit
160ed6ff65
|
@ -2274,6 +2274,10 @@ class PMEMNamespaceConfigInvalid(NovaException):
|
|||
"please check your conf file. ")
|
||||
|
||||
|
||||
class GetPMEMNamespacesFailed(NovaException):
|
||||
msg_fmt = _("Get PMEM namespaces on host failed: %(reason)s.")
|
||||
|
||||
|
||||
class VPMEMCleanupFailed(NovaException):
|
||||
msg_fmt = _("Failed to clean up the vpmem backend device %(dev)s: "
|
||||
"%(error)s")
|
||||
|
|
|
@ -27501,6 +27501,15 @@ class LibvirtPMEMNamespaceTests(test.NoDBTestCase):
|
|||
self.assertRaises(exception.PMEMNamespaceConfigInvalid,
|
||||
drvr._discover_vpmems, vpmem_conf)
|
||||
|
||||
@mock.patch('nova.privsep.libvirt.get_pmem_namespaces')
|
||||
def test_get_vpmems_on_host__exception(self, mock_get_ns):
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||
mock_get_ns.side_effect = Exception('foo')
|
||||
|
||||
self.assertRaises(
|
||||
exception.GetPMEMNamespacesFailed,
|
||||
drvr._get_vpmems_on_host)
|
||||
|
||||
@mock.patch('nova.virt.hardware.get_vpmems')
|
||||
def test_get_ordered_vpmems(self, mock_labels):
|
||||
# get orgered vpmems based on flavor extra_specs
|
||||
|
|
Loading…
Reference in New Issue