Add device event constants to fakelibvirt

The patch I92eb27b710f16d69cf003712431fe225a014c3a8 added the usage of
two new libvirt event constants but missed to add them also to the
fakelibvirt. This caused an extra warning to appear in a lot of unit
tests.

URI qemu:///system does not support events: module
'nova.tests.unit.virt.libvirt.fakelibvirt' has no attribute
'VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED'

The missing constants now added.

This change showed that the above patch also missed to adapt some of the
unit test to the registration of the two new events but this was masked
by the missing fakelibvirt change. So now the unit tests also adapted.

Change-Id: I926553e057ff4838d84244e6f4ef4f39e418788e
This commit is contained in:
Balazs Gibizer 2021-03-05 12:48:12 +01:00
parent c8a6f8d2e5
commit aeb8de892b
3 changed files with 14 additions and 4 deletions

View File

@ -88,6 +88,9 @@ VIR_DOMAIN_EVENT_STOPPED = 5
VIR_DOMAIN_EVENT_SHUTDOWN = 6
VIR_DOMAIN_EVENT_PMSUSPENDED = 7
VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED = 15
VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED = 22
VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED = 1
VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY = 7

View File

@ -26008,13 +26008,20 @@ class LibvirtNonblockingTestCase(test.NoDBTestCase):
conn = fakelibvirt.virConnect()
conn.is_expected = True
side_effect = [conn, None]
side_effect = [conn, None, None, None]
expected_calls = [
mock.call(fakelibvirt.openAuth, 'test:///default',
mock.ANY, mock.ANY),
mock.call(conn.domainEventRegisterAny, None,
fakelibvirt.VIR_DOMAIN_EVENT_ID_LIFECYCLE,
mock.ANY, mock.ANY)]
mock.ANY, mock.ANY),
mock.call(conn.domainEventRegisterAny, None,
fakelibvirt.VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED,
mock.ANY, mock.ANY),
mock.call(conn.domainEventRegisterAny, None,
fakelibvirt.VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED,
mock.ANY, mock.ANY),
]
if hasattr(fakelibvirt.virConnect, 'registerCloseCallback'):
side_effect.append(None)
expected_calls.append(mock.call(

View File

@ -365,7 +365,7 @@ class HostTestCase(test.NoDBTestCase):
get_conn_currency(self.host)
get_conn_currency(self.host)
self.assertEqual(self.connect_calls, 1)
self.assertEqual(self.register_calls, 1)
self.assertEqual(self.register_calls, 3)
@mock.patch.object(fakelibvirt.virConnect, "domainEventRegisterAny")
@mock.patch.object(host.Host, "_connect")
@ -399,7 +399,7 @@ class HostTestCase(test.NoDBTestCase):
thr1.wait()
thr2.wait()
self.assertEqual(self.connect_calls, 1)
self.assertEqual(self.register_calls, 1)
self.assertEqual(self.register_calls, 3)
@mock.patch.object(host.Host, "_connect")
def test_conn_event(self, mock_conn):