Beispiel #1
0
    def test_consumer_graceful_terminate(self, mock_rpc_server):
        mock_rpc_server_rv = mock.Mock()
        mock_rpc_server.return_value = mock_rpc_server_rv

        cons = consumer.ConsumerService(1, self.conf)
        cons.run()
        cons.terminate(graceful=True)
        mock_rpc_server_rv.stop.assert_called_once_with()
        mock_rpc_server_rv.wait.assert_called_once_with()
Beispiel #2
0
    def test_consumer_terminate(self, mock_rpc_server, mock_endpoint,
                                mock_target, mock_get_transport):
        mock_rpc_server_rv = mock.Mock()
        mock_rpc_server.return_value = mock_rpc_server_rv

        cons = consumer.ConsumerService(1, self.conf)
        cons.run()
        cons.terminate()
        mock_rpc_server_rv.stop.assert_called_once_with()
        self.assertFalse(mock_rpc_server_rv.wait.called)
Beispiel #3
0
    def test_consumer_run(self, mock_rpc_server, mock_endpoint, mock_target):
        mock_rpc_server_rv = mock.Mock()
        mock_rpc_server.return_value = mock_rpc_server_rv
        mock_endpoint_rv = mock.Mock()
        mock_endpoint.return_value = mock_endpoint_rv
        mock_target_rv = mock.Mock()
        mock_target.return_value = mock_target_rv

        consumer.ConsumerService(1, self.conf).run()

        mock_target.assert_called_once_with(topic='foo_topic',
                                            server='test-hostname',
                                            fanout=False)
        mock_endpoint.assert_called_once_with()
Beispiel #4
0
    def test_consumer_run(self, mock_rpc_server, mock_endpoint, mock_target,
                          mock_get_transport):
        mock_get_transport_rv = mock.Mock()
        mock_get_transport.return_value = mock_get_transport_rv
        mock_rpc_server_rv = mock.Mock()
        mock_rpc_server.return_value = mock_rpc_server_rv
        mock_endpoint_rv = mock.Mock()
        mock_endpoint.return_value = mock_endpoint_rv
        mock_target_rv = mock.Mock()
        mock_target.return_value = mock_target_rv

        consumer.ConsumerService(1, self.conf).run()

        mock_get_transport.assert_called_once_with(cfg.CONF)
        mock_target.assert_called_once_with(topic='foo_topic',
                                            server='test-hostname',
                                            fanout=False)
        mock_endpoint.assert_called_once_with()
        access_policy = dispatcher.DefaultRPCAccessPolicy
        mock_rpc_server.assert_called_once_with(mock_get_transport_rv,
                                                mock_target_rv,
                                                [mock_endpoint_rv],
                                                executor='threading',
                                                access_policy=access_policy)