diff options
author | Szymon Wroblewski <szymon.wroblewski@ovhcloud.com> | 2021-09-29 12:32:11 +0200 |
---|---|---|
committer | Szymon Wroblewski <szymon.wroblewski@ovhcloud.com> | 2021-10-11 09:48:57 +0200 |
commit | 0940d4f2318e7216486ad2d6ad11837c8f54797a (patch) | |
tree | 5d2a4672b0905ead561b4049d2a4599cabf3ea68 | |
parent | b73ae4e6de22c79eac3c5af6ac47c432f6d0816e (diff) | |
download | ceilometer-0940d4f2318e7216486ad2d6ad11837c8f54797a.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
-rw-r--r-- | ceilometer/tests/unit/compute/test_discovery.py | 12 |
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)) |