summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Wroblewski <szymon.wroblewski@ovhcloud.com>2021-09-29 12:32:11 +0200
committerEmma Foley <efoley@redhat.com>2022-12-15 13:06:29 +0000
commitb80d48afea9ab934e380f277ab92aaf4d45e1297 (patch)
tree1cbda0e6121e8142cd68d1db0bafdedab631f728
parent819b48fd54893b27749f2ff45cdd12f01e93e27f (diff)
downloadceilometer-b80d48afea9ab934e380f277ab92aaf4d45e1297.tar.gz
Fix broken test_discovery_with_libvirt_error
Mock only small parts of libvirt not the whole library, when testing libvirt discovery. Closes-Bug: #1774292 Change-Id: Ifbcf3fa0602d805b1e493f1ee6c3385edb87a277 (cherry picked from commit 0940d4f2318e7216486ad2d6ad11837c8f54797a) (cherry picked from commit 274e51555f0b939efc228efe1ec34e0253742a8e)
-rw-r--r--ceilometer/tests/unit/compute/test_discovery.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/ceilometer/tests/unit/compute/test_discovery.py b/ceilometer/tests/unit/compute/test_discovery.py
index 0e1eccad..abe538cd 100644
--- a/ceilometer/tests/unit/compute/test_discovery.py
+++ b/ceilometer/tests/unit/compute/test_discovery.py
@@ -130,6 +130,9 @@ class FakeManualInstanceConn(object):
def listAllDomains(self):
return [FakeManualInstanceDomain()]
+ def isAlive(self):
+ return False
+
class TestDiscovery(base.BaseTestCase):
@@ -288,14 +291,13 @@ class TestDiscovery(base.BaseTestCase):
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))