Skip to content

Commit

Permalink
Merge "Fix broken test_discovery_with_libvirt_error"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Nov 15, 2021
2 parents 4d2ad5b + 0940d4f commit 872ce50
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ceilometer/tests/unit/compute/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ class FakeManualInstanceConn(object):
def listAllDomains(self):
return [FakeManualInstanceDomain()]

def isAlive(self):
return False


class TestDiscovery(base.BaseTestCase):

Expand Down Expand Up @@ -288,14 +291,13 @@ def test_discovery_with_legacy_resource_cache_cleanup(self):
self.client.instance_get_all_by_host.call_args_list)

@testtools.skipUnless(libvirt, "libvirt not available")
@mock.patch.object(utils, "libvirt")
@mock.patch.object(discovery, "libvirt")
def test_discovery_with_libvirt_error(self, libvirt, libvirt2):
@mock.patch.object(libvirt, "VIR_DOMAIN_METADATA_ELEMENT", 2)
@mock.patch.object(libvirt, "openReadOnly")
def test_discovery_with_libvirt_error(self, openReadOnly):
self.CONF.set_override("instance_discovery_method",
"libvirt_metadata",
group="compute")
libvirt.VIR_DOMAIN_METADATA_ELEMENT = 2
libvirt2.openReadOnly.return_value = FakeManualInstanceConn()
openReadOnly.return_value = FakeManualInstanceConn()
dsc = discovery.InstanceDiscovery(self.CONF)
resources = dsc.discover(mock.MagicMock())
self.assertEqual(0, len(resources))
Expand Down

0 comments on commit 872ce50

Please sign in to comment.