From 9391044765be5cdcd141b25fc2db459ceca9c8b1 Mon Sep 17 00:00:00 2001 From: Arnaud M Date: Sat, 21 Dec 2024 22:58:57 +0100 Subject: [PATCH] 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 --- mistral/tests/unit/rpc/kombu/test_kombu_server.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mistral/tests/unit/rpc/kombu/test_kombu_server.py b/mistral/tests/unit/rpc/kombu/test_kombu_server.py index 7f997ceaa..9fd7395fe 100644 --- a/mistral/tests/unit/rpc/kombu/test_kombu_server.py +++ b/mistral/tests/unit/rpc/kombu/test_kombu_server.py @@ -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(