diff --git a/ceilometer/collector.py b/ceilometer/collector.py index f8463e446..5246f72dd 100644 --- a/ceilometer/collector.py +++ b/ceilometer/collector.py @@ -40,6 +40,8 @@ OPTS = [ cfg.CONF.register_opts(OPTS, group="collector") cfg.CONF.import_opt('rpc_backend', 'ceilometer.openstack.common.rpc') +cfg.CONF.import_opt('metering_topic', 'ceilometer.publisher.rpc', + group="publisher_rpc") LOG = log.getLogger(__name__) diff --git a/ceilometer/tests/test_collector.py b/ceilometer/tests/test_collector.py index 74ee4880c..17fde4bf0 100644 --- a/ceilometer/tests/test_collector.py +++ b/ceilometer/tests/test_collector.py @@ -29,6 +29,11 @@ from ceilometer import sample from ceilometer.tests import base as tests_base +class FakeConnection(): + def create_worker(self, topic, proxy, pool_name): + pass + + class TestCollector(tests_base.BaseTestCase): def setUp(self): super(TestCollector, self).setUp() @@ -161,3 +166,14 @@ class TestCollector(tests_base.BaseTestCase): self.CONF.set_override('udp_address', '', group='collector') with patch('ceilometer.openstack.common.rpc.create_connection'): self.srv.start() + + @patch.object(FakeConnection, 'create_worker') + @patch('ceilometer.openstack.common.rpc.dispatcher.RpcDispatcher') + def test_initialize_service_hook_conf_opt(self, mock_dispatcher, + mock_worker): + self.CONF.set_override('metering_topic', 'mytopic', + group='publisher_rpc') + self.srv.conn = FakeConnection() + self.srv.initialize_service_hook(mock.MagicMock()) + mock_worker.assert_called_once_with('mytopic', mock_dispatcher(), + 'ceilometer.collector.mytopic')