summaryrefslogtreecommitdiff
path: root/oslo_messaging/tests/rpc/test_dispatcher.py
diff options
context:
space:
mode:
Diffstat (limited to 'oslo_messaging/tests/rpc/test_dispatcher.py')
-rwxr-xr-xoslo_messaging/tests/rpc/test_dispatcher.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/oslo_messaging/tests/rpc/test_dispatcher.py b/oslo_messaging/tests/rpc/test_dispatcher.py
index 89b36cd..337593b 100755
--- a/oslo_messaging/tests/rpc/test_dispatcher.py
+++ b/oslo_messaging/tests/rpc/test_dispatcher.py
@@ -217,6 +217,34 @@ class TestDispatcher(test_utils.BaseTestCase):
'method: {}'.format(method))
+class TestDispatcherWithPingEndpoint(test_utils.BaseTestCase):
+ def test_dispatcher_with_ping(self):
+ self.config(rpc_ping_enabled=True)
+ dispatcher = oslo_messaging.RPCDispatcher([], None, None)
+ incoming = mock.Mock(ctxt={},
+ message=dict(method='oslo_rpc_server_ping'),
+ client_timeout=0)
+
+ res = dispatcher.dispatch(incoming)
+ self.assertEqual('pong', res)
+
+ def test_dispatcher_with_ping_already_used(self):
+ class MockEndpoint(object):
+ def oslo_rpc_server_ping(self, ctxt, **kwargs):
+ return 'not_pong'
+
+ mockEndpoint = MockEndpoint()
+
+ self.config(rpc_ping_enabled=True)
+ dispatcher = oslo_messaging.RPCDispatcher([mockEndpoint], None, None)
+ incoming = mock.Mock(ctxt={},
+ message=dict(method='oslo_rpc_server_ping'),
+ client_timeout=0)
+
+ res = dispatcher.dispatch(incoming)
+ self.assertEqual('not_pong', res)
+
+
class TestSerializer(test_utils.BaseTestCase):
scenarios = [
('no_args_or_retval',