diff --git a/ceilometer/publisher/rpc.py b/ceilometer/publisher/rpc.py index 99f22a859..892eca46a 100644 --- a/ceilometer/publisher/rpc.py +++ b/ceilometer/publisher/rpc.py @@ -118,7 +118,7 @@ class RPCPublisher(publisher.PublisherBase): self.target = options.get('target', ['record_metering_data'])[0] - self.policy = options.get('policy', ['wait'])[-1] + self.policy = options.get('policy', ['default'])[-1] self.max_queue_length = int(options.get( 'max_queue_length', [1024])[-1]) diff --git a/tests/publisher/test_rpc_publisher.py b/tests/publisher/test_rpc_publisher.py index 853eb525c..0e622d691 100644 --- a/tests/publisher/test_rpc_publisher.py +++ b/tests/publisher/test_rpc_publisher.py @@ -19,9 +19,11 @@ """Tests for ceilometer/publish.py """ -import eventlet import datetime +import eventlet +import mock + from ceilometer import sample from ceilometer.openstack.common import jsonutils from ceilometer.openstack.common import network_utils @@ -296,10 +298,13 @@ class TestPublish(test.BaseTestCase): self.assertEqual(len(self.published), 2) self.assertEqual(len(publisher.local_queue), 0) - def test_published_with_no_policy(self): + @mock.patch('ceilometer.publisher.rpc.LOG') + def test_published_with_no_policy(self, mylog): self.rpc_unreachable = True publisher = rpc.RPCPublisher( network_utils.urlsplit('rpc://')) + self.assertTrue(mylog.info.called) + self.assertRaises( SystemExit, publisher.publish_samples, @@ -308,10 +313,12 @@ class TestPublish(test.BaseTestCase): self.assertEqual(len(self.published), 0) self.assertEqual(len(publisher.local_queue), 0) - def test_published_with_policy_block(self): + @mock.patch('ceilometer.publisher.rpc.LOG') + def test_published_with_policy_block(self, mylog): self.rpc_unreachable = True publisher = rpc.RPCPublisher( network_utils.urlsplit('rpc://?policy=default')) + self.assertTrue(mylog.info.called) self.assertRaises( SystemExit, publisher.publish_samples, @@ -319,7 +326,8 @@ class TestPublish(test.BaseTestCase): self.assertEqual(len(self.published), 0) self.assertEqual(len(publisher.local_queue), 0) - def test_published_with_policy_incorrect(self): + @mock.patch('ceilometer.publisher.rpc.LOG') + def test_published_with_policy_incorrect(self, mylog): self.rpc_unreachable = True publisher = rpc.RPCPublisher( network_utils.urlsplit('rpc://?policy=notexist')) @@ -327,6 +335,7 @@ class TestPublish(test.BaseTestCase): SystemExit, publisher.publish_samples, None, self.test_data) + self.assertTrue(mylog.warn.called) self.assertEqual(publisher.policy, 'default') self.assertEqual(len(self.published), 0) self.assertEqual(len(publisher.local_queue), 0)