Browse Source

libvirt: stub logging of host capabilities

By default we capture the logging output stream at INFO level
for unit/functional tests and anything that hits the libvirt
Host.get_capabilities method logs the giant xml host capabilities
string that is defined in the fakelibvirt module. This can cause
subunit parsing to fail because there is too much output in the
buffer.

This change simply stubs out that particular logging call in the
FakeLibvirtFixture class which is used extensively in the more
detailed libvirt tests like LibvirtConnTestCase. If this turns out
to not be good enough we can try stubbing at a more global level
like in the base nova TestCase.

Conflicts:
      nova/virt/libvirt/host.py

NOTE(mriedem): The conflict is due to not having change
I06e1f7429c056c4ce8506b10359762e457dbb2a0 in Stein.

Change-Id: I38b350bce908005161ed7c3eb737f32076828a37
Related-Bug: #1813147
(cherry picked from commit 2973faa070)
tags/19.0.3
Matt Riedemann 2 months ago
parent
commit
d6b5e81df5
2 changed files with 13 additions and 1 deletions
  1. +5
    -0
      nova/tests/unit/virt/libvirt/fakelibvirt.py
  2. +8
    -1
      nova/virt/libvirt/host.py

+ 5
- 0
nova/tests/unit/virt/libvirt/fakelibvirt.py View File

@@ -1786,6 +1786,11 @@ class FakeLibvirtFixture(fixtures.Fixture):
'nova.virt.libvirt.driver.LibvirtDriver'
'._get_host_sysinfo_serial_os', return_value=uuids.machine_id))

# Stub out _log_host_capabilities since it logs a giant string at INFO
# and we don't want that to blow up the subunit parser in test runs.
self.useFixture(fixtures.MockPatch(
'nova.virt.libvirt.host.Host._log_host_capabilities'))

disable_event_thread(self)

if self.stub_os_vif:

+ 8
- 1
nova/virt/libvirt/host.py View File

@@ -635,6 +635,13 @@ class Host(object):

return online_cpus

@staticmethod
def _log_host_capabilities(xmlstr):
# NOTE(mriedem): This looks a bit weird but we do this so we can stub
# out this method in unit/functional test runs since the xml string is
# big and it can cause subunit parsing to fail (see bug 1813147).
LOG.info("Libvirt host capabilities %s", xmlstr)

def get_capabilities(self):
"""Returns the host capabilities information

@@ -647,7 +654,7 @@ class Host(object):
"""
if not self._caps:
xmlstr = self.get_connection().getCapabilities()
LOG.info("Libvirt host capabilities %s", xmlstr)
self._log_host_capabilities(xmlstr)
self._caps = vconfig.LibvirtConfigCaps()
self._caps.parse_str(xmlstr)
# NOTE(mriedem): Don't attempt to get baseline CPU features

Loading…
Cancel
Save