[test]Speed up qemu announce test by mocking sleep

Before

Test id                                           Runtime (s)
------------------------------------------------  -----------
LibvirtConnTestCase.test_qemu_announce_self       2.214
TestProfiler.test_all_public_methods_are_traced   0.079

After

Test id                                           Runtime (s)
------------------------------------------------  -----------
LibvirtConnTestCase.test_qemu_announce_self       0.242
TestProfiler.test_all_public_methods_are_traced   0.097

Change-Id: Ib3c6e8c53f3eab5328eb30f5fd2e49a4b2e43097
Signed-off-by: Balazs Gibizer <gibi@redhat.com>
This commit is contained in:
Balazs Gibizer
2025-07-25 15:46:07 +02:00
parent 218ce9448b
commit 56e038900c
@@ -2102,6 +2102,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
mock_guest.set_user_password.assert_called_once_with("root", "123")
@mock.patch("time.sleep", new=mock.Mock())
@mock.patch('nova.virt.libvirt.host.Host.get_guest')
def test_qemu_announce_self(self, mock_get_guest):
# Enable the workaround, configure to call announce_self 3 times