Skip to content

Commit

Permalink
Merge "Sets storage_conn in CollectorService."
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jul 24, 2013
2 parents 3589de7 + d73b1c5 commit a4b1b54
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions ceilometer/collector/service.py
Expand Up @@ -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()
Expand Down
9 changes: 9 additions & 0 deletions tests/collector/test_service.py
Expand Up @@ -127,6 +127,10 @@ def setUp(self):
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'
Expand Down Expand Up @@ -175,6 +179,11 @@ def setUp(self):
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
Expand Down

0 comments on commit a4b1b54

Please sign in to comment.