diff options
author | Szymon Wroblewski <szymon.wroblewski@ovhcloud.com> | 2021-09-29 12:32:11 +0200 |
---|---|---|
committer | Emma Foley <efoley@redhat.com> | 2023-01-03 20:03:13 +0000 |
commit | c0538c94cf02d4bd2c8f1194d29eabcffcbea895 (patch) | |
tree | 7ce0ac3a935296ca5fe2db8548b7049785dd6987 | |
parent | 1b6fb52d3aeeada83ac12a071e38587f3a129965 (diff) | |
download | ceilometer-stable/train.tar.gz |
Fix broken test_discovery_with_libvirt_errorstable/train
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)
(cherry picked from commit bcada72c3aaeeb2a86de3368b1787a9253c9d55b)
-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 33fe9aaf..5a4d4029 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)) |