Avoid duplication of discovery for multi-sink sources
Perviously, where a single source has a pluggable discovery extension loaded and is associated with multiple sinks, the discovered resources were duplicated for each sink. Now, we ensure that duplicate discovery extensions are excluded. Change-Id: Icffcc65f2be2baef7730b31773b39ffdda0454a7 Closes-Bug: #1354536
This commit is contained in:
parent
9936b3469c
commit
2bc48ff261
@ -37,11 +37,11 @@ class Resources(object):
|
||||
def __init__(self, agent_manager):
|
||||
self.agent_manager = agent_manager
|
||||
self._resources = []
|
||||
self._discovery = []
|
||||
self._discovery = set([])
|
||||
|
||||
def extend(self, pipeline):
|
||||
self._resources.extend(pipeline.resources)
|
||||
self._discovery.extend(pipeline.discovery)
|
||||
self._discovery.update(set(pipeline.discovery))
|
||||
|
||||
@property
|
||||
def resources(self):
|
||||
|
@ -520,3 +520,27 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
|
||||
self.assertEqual(1, len(self.PollsterAnother.samples))
|
||||
self.assertEqual(['discovered_3', 'discovered_4'],
|
||||
self.PollsterAnother.resources)
|
||||
|
||||
def test_multiple_sinks_same_discoverer(self):
|
||||
self.Discovery.resources = ['discovered_1', 'discovered_2']
|
||||
sources = [{'name': 'test_source_1',
|
||||
'interval': 60,
|
||||
'counters': ['test'],
|
||||
'discovery': ['testdiscovery'],
|
||||
'sinks': ['test_sink_1', 'test_sink_2']}]
|
||||
sinks = [{'name': 'test_sink_1',
|
||||
'transformers': [],
|
||||
'publishers': ['test://']},
|
||||
{'name': 'test_sink_2',
|
||||
'transformers': [],
|
||||
'publishers': ['test://']}]
|
||||
self.pipeline_cfg = {'sources': sources, 'sinks': sinks}
|
||||
self.mgr.discovery_manager = self.create_discovery_manager()
|
||||
self.setup_pipeline()
|
||||
polling_tasks = self.mgr.setup_polling_tasks()
|
||||
self.assertEqual(1, len(polling_tasks))
|
||||
self.assertTrue(60 in polling_tasks.keys())
|
||||
self.mgr.interval_task(polling_tasks.get(60))
|
||||
self.assertEqual(1, len(self.Pollster.samples))
|
||||
self.assertEqual(['discovered_1', 'discovered_2'],
|
||||
self.Pollster.resources)
|
||||
|
Loading…
x
Reference in New Issue
Block a user