Sets storage_conn in CollectorService.

Fixes bug 1204133

Storage_conn was not being set when the CollectorService
was instantiated, thus enabling event storage would cause
exceptions when trying to store the event.

Change-Id: Ie7f84e1c266239cf7052fd5aba55577a257d2b1b
This commit is contained in:
Andrew Melton 2013-07-23 11:10:37 -04:00
parent 0b50ac2f59
commit d73b1c5e6b
2 changed files with 10 additions and 0 deletions

View File

@ -114,6 +114,7 @@ class CollectorService(rpc_service.Service):
def __init__(self, host, topic, manager=None):
super(CollectorService, self).__init__(host, topic, manager)
self.storage_conn = storage.get_connection(cfg.CONF)
def start(self):
super(CollectorService, self).start()

View File

@ -127,6 +127,10 @@ class TestUDPCollectorService(TestCollector):
resource_metadata={},
)._asdict())
def test_service_has_storage_conn(self):
srv = service.UDPCollectorService()
self.assertIsNotNone(srv.storage_conn)
def test_udp_receive(self):
self.srv.storage_conn = self.mox.CreateMock(base.Connection)
self.counter['source'] = 'mysource'
@ -175,6 +179,11 @@ class TestCollectorService(TestCollector):
self.srv = service.CollectorService('the-host', 'the-topic')
self.ctx = None
def test_service_has_storage_conn(self):
# Test an unmocked default CollectorService
srv = service.CollectorService('the-host', 'the-topic')
self.assertIsNotNone(srv.storage_conn)
@patch('ceilometer.pipeline.setup_pipeline', MagicMock())
def test_init_host(self):
# If we try to create a real RPC connection, init_host() never