def test_create_destroy_rpc_namespace_proxy_receive(self):
        self.agent.init_host()
        self.agent.after_start()
        ctxt = context.Context('user', 'tenant')
        with mock.patch('oslo.messaging.proxy.get_proxy_server'
                        ) as mock_get_proxy_server:
            mock_proxy_server = mock_get_proxy_server.return_value
            src_unix_target = 'topic=src_topic,server=src_server'
            dst_transport_url = 'fake:///'
            dst_target = 'topic=dst_topic,server=dst_server'
            ns_proxy_id = self.agent.create_rpc_namespace_proxy(
                ctxt, src_unix_target, dst_transport_url, dst_target,
                'receive')
            src_unix_target = target.target_parse(src_unix_target)
            dst_target = target.target_parse(dst_target)
            mock_get_proxy_server.assert_called_once_with(
                self.mock_transport, dst_target, None,
                self.mock_transport, src_unix_target, None, executor=mock.ANY)
            # mock_proxy_server.start.assert_called_once_with()

            self.agent.destroy_rpc_namespace_proxy(ctxt, ns_proxy_id)
            mock_proxy_server.stop.assert_called_once_with()
            mock_proxy_server.wait.assert_called_once_with()
            self.mock_transport.cleanup.assert_called_once_with()
        self.agent.stop()
        self.agent.wait()
 def _create_rpc_namespace_proxy(self, src_transport, src_target,
                                 dst_transport, dst_target):
     src_target = target.target_parse(src_target)
     assert src_target.server
     dst_target = target.target_parse(dst_target)
     assert dst_target.server
     return proxy.get_proxy_server(
         src_transport, src_target, None,
         dst_transport, dst_target, None, executor='eventlet')
Beispiel #3
0
 def _create_rpc_proxy(self, ns_agent, src_transport, src_target, dst_transport, dst_target):
     rpc_proxy_id = str(uuid.uuid4())
     src_target = target.target_parse(src_target)
     assert src_target.server
     dst_target = target.target_parse(dst_target)
     assert dst_target.server
     proxy_server = proxy.get_proxy_server(
         src_transport, src_target, None, dst_transport, dst_target, None, executor="eventlet"
     )
     ns_agent.local_proxies[rpc_proxy_id] = proxy_server
     proxy_server.start()
     return rpc_proxy_id
Beispiel #4
0
 def _create_rpc_namespace_proxy(self, src_transport, src_target,
                                 dst_transport, dst_target):
     src_target = target.target_parse(src_target)
     assert src_target.server
     dst_target = target.target_parse(dst_target)
     assert dst_target.server
     return proxy.get_proxy_server(src_transport,
                                   src_target,
                                   None,
                                   dst_transport,
                                   dst_target,
                                   None,
                                   executor='eventlet')
Beispiel #5
0
 def _create_rpc_proxy(self, ns_agent, src_transport, src_target,
                       dst_transport, dst_target):
     rpc_proxy_id = str(uuid.uuid4())
     src_target = target.target_parse(src_target)
     assert src_target.server
     dst_target = target.target_parse(dst_target)
     assert dst_target.server
     proxy_server = proxy.get_proxy_server(src_transport,
                                           src_target,
                                           None,
                                           dst_transport,
                                           dst_target,
                                           None,
                                           executor='eventlet')
     ns_agent.local_proxies[rpc_proxy_id] = proxy_server
     proxy_server.start()
     return rpc_proxy_id
Beispiel #6
0
 def test_parse(self):
     t = agent_target.target_parse(self.target_str)
     self.assertEqual(t, self.target_instance)
    def test_create_destroy_rpc_namespace_proxy(self):
        self.agent.init_host()
        self.agent.after_start()
        ctxt = context.Context('user', 'tenant')
        with mock.patch('oslo.messaging.proxy.get_proxy_server'
                        ) as mock_get_proxy_server:
            mock_proxy_server = mock_get_proxy_server.return_value
            src_unix_target_send = ('topic=src_topic_send,'
                                    'server=src_server_send')
            dst_transport_url_send = 'fake:///'
            dst_target_send = 'topic=dst_topic_send,server=dst_server_send'
            ns_proxy_id_send = self.agent.create_rpc_namespace_proxy(
                ctxt, src_unix_target_send, dst_transport_url_send,
                dst_target_send, 'send')
            src_unix_target_send = target.target_parse(src_unix_target_send)
            dst_target_send = target.target_parse(dst_target_send)
            mock_get_proxy_server.assert_called_once_with(
                self.mock_transport, src_unix_target_send, None,
                self.mock_transport, dst_target_send, None, executor=mock.ANY)
            # mock_proxy_server.start.assert_called_once_with()

            src_unix_target_recv = ('topic=src_topic_recv,'
                                    'server=src_server_recv')
            dst_transport_url_recv = 'fake:///'
            dst_target_recv = 'topic=dst_topic_recv,server=dst_server_recv'
            self.agent.create_rpc_namespace_proxy(
                ctxt, src_unix_target_recv, dst_transport_url_recv,
                dst_target_recv, 'receive')
            src_unix_target_recv = target.target_parse(src_unix_target_recv)
            dst_target_recv = target.target_parse(dst_target_recv)

            # mock.call().__hash__()/mock.call.__hash__() doesn't work
            # due to __getattr__. So create it manually
            call_hash = mock._Call(name='().__hash__')
            mock_get_proxy_server.assert_has_calls([
                mock.call(self.mock_transport, src_unix_target_send, None,
                          self.mock_transport, dst_target_send, None,
                          executor=mock.ANY),
                # mock.call().start(),
                call_hash(),
                mock.call(self.mock_transport, dst_target_recv, None,
                          self.mock_transport, src_unix_target_recv, None,
                          executor=mock.ANY),
                # mock.call().start(),
                call_hash()])

            self.agent.destroy_rpc_namespace_proxy(ctxt, ns_proxy_id_send)
            mock_proxy_server.stop.assert_called_once_with()
            mock_proxy_server.wait.assert_called_once_with()

            self.agent.destroy_namespace_agent(ctxt)
            self.agent.wait()
            call_hash = mock._Call(name='__hash__')
            mock_proxy_server.assert_has_calls([
                # mock.call.start(),
                call_hash(),
                # mock.call.start(),
                call_hash(),
                call_hash(),
                mock.call.stop(),
                mock.call.wait(),
                mock.call.stop(),
                mock.call.wait()])
            self.mock_transport.cleanup.assert_called_once_with()