Merge "fix perf when libvirt is >=2.0.0 and <2.3.0" into stable/newton
This commit is contained in:
commit
ae1e1519e2
@ -291,7 +291,10 @@ class LibvirtInspector(virt_inspector.Inspector):
|
||||
instructions=perf["perf.instructions"],
|
||||
cache_references=perf["perf.cache_references"],
|
||||
cache_misses=perf["perf.cache_misses"])
|
||||
except AttributeError as e:
|
||||
# NOTE(sileht): KeyError if for libvirt >=2.0.0,<2.3.0, the perf
|
||||
# subsystem ws existing but not these attributes
|
||||
# https://github.com/libvirt/libvirt/commit/bae660869de0612bee2a740083fb494c27e3f80c
|
||||
except (AttributeError, KeyError) as e:
|
||||
msg = _LE('Perf is not supported by current version of libvirt, '
|
||||
'and failed to inspect perf events of '
|
||||
'%(instance_uuid)s, can not get info from libvirt: '
|
||||
|
@ -404,6 +404,20 @@ class TestLibvirtInspection(base.BaseTestCase):
|
||||
self.assertEqual(74184, pe.cache_references)
|
||||
self.assertEqual(16737, pe.cache_misses)
|
||||
|
||||
def test_inspect_perf_events_libvirt_less_than_2_3_0(self):
|
||||
fake_stats = [({}, {})]
|
||||
connection = self.inspector.connection
|
||||
with mock.patch.object(connection, 'lookupByUUIDString',
|
||||
return_value=self.domain):
|
||||
with mock.patch.object(self.domain, 'info',
|
||||
return_value=(0, 0, 51200,
|
||||
2, 999999)):
|
||||
with mock.patch.object(connection, 'domainListGetStats',
|
||||
return_value=fake_stats):
|
||||
self.assertRaises(virt_inspector.NoDataException,
|
||||
self.inspector.inspect_perf_events,
|
||||
self.instance)
|
||||
|
||||
|
||||
class TestLibvirtInspectionWithError(base.BaseTestCase):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user