Fix keyboardinterrupt test on kombuserver

The keyboardinterrupt test was not waiting enough for the thread to
reach the code that actually mock the keyboard interrupt.
Adding a sleep(1) in that test is fixing the issue.

This issue is visibile using the last eventlet release (0.38.2).

Change-Id: I4420da5225a2b7f41b0fb53eae158fdac7bf8ad8
Signed-off-by: Arnaud M <arnaud.morin@gmail.com>
This commit is contained in:
Arnaud M 2024-12-21 22:58:57 +01:00
parent f90a0af4af
commit 9391044765

View File

@ -21,6 +21,8 @@ from mistral.tests.unit.rpc.kombu import fake_kombu
from unittest import mock
import socket
import time
from stevedore import driver
with mock.patch.dict('sys.modules', kombu=fake_kombu):
@ -37,6 +39,7 @@ class KombuServerTest(base.KombuTestCase):
super(KombuServerTest, self).setUp()
self.conf = mock.MagicMock()
self.conf.host = 'fakehost'
self.server = kombu_server.KombuRPCServer(self.conf)
self.ctx = type('context', (object,), {'to_dict': lambda self: {}})()
@ -134,6 +137,9 @@ class KombuServerTest(base.KombuTestCase):
fake_kombu.connection.acquire.return_value = acquire_mock
self.assertIsNone(self.server.run())
# Wait 1 sec so the thread start listening on RPC and receive the
# side_effect
time.sleep(1)
self.assertFalse(self.server.is_running)
@mock.patch.object(