2014-01-10 17:43:02 +00:00
|
|
|
|
|
|
|
# Copyright 2014 Red Hat, Inc.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
2020-05-11 10:17:47 +02:00
|
|
|
|
|
|
|
from unittest import mock
|
|
|
|
|
2015-05-22 16:08:59 +03:00
|
|
|
import stevedore
|
2014-08-25 15:05:50 +02:00
|
|
|
import testtools
|
2014-01-10 17:43:02 +00:00
|
|
|
|
2016-02-20 11:31:15 -05:00
|
|
|
from oslo_messaging import server
|
2014-07-18 15:32:56 +02:00
|
|
|
try:
|
2015-01-02 14:24:57 -05:00
|
|
|
from oslo_messaging import opts
|
2014-07-18 15:32:56 +02:00
|
|
|
except ImportError:
|
2014-08-25 15:05:50 +02:00
|
|
|
opts = None
|
2015-01-02 14:24:57 -05:00
|
|
|
from oslo_messaging.tests import utils as test_utils
|
2014-01-10 17:43:02 +00:00
|
|
|
|
|
|
|
|
2017-08-17 11:09:29 +08:00
|
|
|
@testtools.skipIf(opts is None, "Options not importable")
|
2014-01-10 17:43:02 +00:00
|
|
|
class OptsTestCase(test_utils.BaseTestCase):
|
|
|
|
|
|
|
|
def _test_list_opts(self, result):
|
2018-08-27 15:57:54 -04:00
|
|
|
self.assertEqual(5, len(result))
|
2014-01-10 17:43:02 +00:00
|
|
|
|
|
|
|
groups = [g for (g, l) in result]
|
|
|
|
self.assertIn(None, groups)
|
2014-09-05 15:24:50 +02:00
|
|
|
self.assertIn('oslo_messaging_amqp', groups)
|
2016-01-05 18:34:15 +01:00
|
|
|
self.assertIn('oslo_messaging_notifications', groups)
|
2015-01-28 08:57:21 +01:00
|
|
|
self.assertIn('oslo_messaging_rabbit', groups)
|
2016-06-21 14:57:17 +03:00
|
|
|
self.assertIn('oslo_messaging_kafka', groups)
|
2014-01-10 17:43:02 +00:00
|
|
|
|
|
|
|
def test_list_opts(self):
|
|
|
|
self._test_list_opts(opts.list_opts())
|
|
|
|
|
|
|
|
def test_entry_point(self):
|
|
|
|
result = None
|
2015-05-22 16:08:59 +03:00
|
|
|
for ext in stevedore.ExtensionManager('oslo.config.opts',
|
|
|
|
invoke_on_load=True):
|
|
|
|
if ext.name == "oslo.messaging":
|
|
|
|
result = ext.obj
|
2014-01-10 17:43:02 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
self.assertIsNotNone(result)
|
|
|
|
self._test_list_opts(result)
|
2015-07-18 14:32:34 +02:00
|
|
|
|
|
|
|
def test_defaults(self):
|
2016-02-20 11:31:15 -05:00
|
|
|
transport = mock.Mock()
|
|
|
|
transport.conf = self.conf
|
2016-03-25 13:39:53 +02:00
|
|
|
|
|
|
|
class MessageHandlingServerImpl(server.MessageHandlingServer):
|
|
|
|
def _create_listener(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def _process_incoming(self, incoming):
|
|
|
|
pass
|
|
|
|
|
|
|
|
MessageHandlingServerImpl(transport, mock.Mock())
|
2015-07-18 14:32:34 +02:00
|
|
|
opts.set_defaults(self.conf, executor_thread_pool_size=100)
|
|
|
|
self.assertEqual(100, self.conf.executor_thread_pool_size)
|