diff options
author | Szymon Wroblewski <szymon.wroblewski@ovhcloud.com> | 2021-09-29 12:32:11 +0200 |
---|---|---|
committer | Emma Foley <efoley@redhat.com> | 2022-12-21 11:20:54 +0000 |
commit | bcada72c3aaeeb2a86de3368b1787a9253c9d55b (patch) | |
tree | 754aec16dd5ad97799afae1ffc328f9a706c1cfd | |
parent | 0a798c58dff3245b12d920b3c3cc95a2628cae36 (diff) | |
download | ceilometer-stable/ussuri.tar.gz |
Fix broken test_discovery_with_libvirt_errorstable/ussuri
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)
(cherry picked from commit b80d48afea9ab934e380f277ab92aaf4d45e1297)
-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 e5c1c964..e726d631 100644 --- a/ceilometer/tests/unit/compute/test_discovery.py +++ b/ceilometer/tests/unit/compute/test_discovery.py @@ -128,6 +128,9 @@ class FakeManualInstanceConn(object): def listAllDomains(self): return [FakeManualInstanceDomain()] + def isAlive(self): + return False + class TestDiscovery(base.BaseTestCase): @@ -286,14 +289,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)) |