Fix problems during unstable network

In this patch start and stop method is not raised exceptions
if connectivity problem is detected. Rasing exceptions there
exceptions are not expected by MessageHandlerServer.
It hangs server on start

Closes-Bug: #1553168

Change-Id: I891abab2a1184fa65b496ea2f7fc54894bc0b421
This commit is contained in:
dukhlov
2016-03-03 11:00:50 -05:00
parent 41851e9c8a
commit 0aca222d96
7 changed files with 120 additions and 80 deletions

View File

@@ -22,7 +22,7 @@ from oslo_serialization import jsonutils
import pika
import oslo_messaging
from oslo_messaging._drivers.pika_driver import pika_engine
from oslo_messaging._drivers.pika_driver import pika_commons as pika_drv_cmns
from oslo_messaging._drivers.pika_driver import pika_message as pika_drv_msg
@@ -252,7 +252,7 @@ class RpcReplyPikaIncomingMessageTestCase(unittest.TestCase):
def setUp(self):
self._pika_engine = mock.Mock()
self._pika_engine.allowed_remote_exmods = [
pika_engine._EXCEPTIONS_MODULE, "oslo_messaging.exceptions"
pika_drv_cmns.EXCEPTIONS_MODULE, "oslo_messaging.exceptions"
]
self._channel = mock.Mock()

View File

@@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import socket
import time
import unittest
@@ -33,6 +34,18 @@ class PikaPollerTestCase(unittest.TestCase):
)
self._prefetch_count = 123
def test_start_when_connection_unavailable(self):
incoming_message_class_mock = mock.Mock()
poller = pika_poller.PikaPoller(
self._pika_engine, self._prefetch_count,
incoming_message_class=incoming_message_class_mock
)
self._pika_engine.create_connection.side_effect = socket.timeout()
# start() should not raise socket.timeout exception
poller.start()
@mock.patch("oslo_messaging._drivers.pika_driver.pika_poller.PikaPoller."
"_declare_queue_binding")
def test_poll(self, declare_queue_binding_mock):