Simplify the validation of required fields of pipeline source
- The required field "meters" (or "counters") validation is invalid - The validation of these required fields of SampleSource and EventSource are unnecessary Change-Id: Ifda35d7ff0e5baa1a97017d9deb6db7613fb8e31
This commit is contained in:
parent
6fe1319f66
commit
a04da91e03
@ -293,11 +293,7 @@ class EventSource(Source):
|
||||
|
||||
def __init__(self, cfg):
|
||||
super(EventSource, self).__init__(cfg)
|
||||
try:
|
||||
self.events = cfg['events']
|
||||
except KeyError as err:
|
||||
raise PipelineException(
|
||||
"Required field %s not specified" % err.args[0], cfg)
|
||||
self.events = cfg.get('events')
|
||||
self.check_source_filtering(self.events, 'events')
|
||||
|
||||
def support_event(self, event_name):
|
||||
@ -315,13 +311,8 @@ class SampleSource(Source):
|
||||
|
||||
def __init__(self, cfg):
|
||||
super(SampleSource, self).__init__(cfg)
|
||||
try:
|
||||
# Support 'counters' for backward compatibility
|
||||
self.meters = cfg.get('meters', cfg.get('counters'))
|
||||
except KeyError as err:
|
||||
raise PipelineException(
|
||||
"Required field %s not specified" % err.args[0], cfg)
|
||||
|
||||
# Support 'counters' for backward compatibility
|
||||
self.meters = cfg.get('meters', cfg.get('counters'))
|
||||
try:
|
||||
self.interval = int(cfg.get('interval', 600))
|
||||
except ValueError:
|
||||
|
@ -103,6 +103,10 @@ class TestDecoupledPipeline(pipeline_base.BasePipelineTestCase):
|
||||
del self.pipeline_cfg['sinks']
|
||||
self._exception_create_pipelinemanager()
|
||||
|
||||
def test_source_no_meters_or_counters(self):
|
||||
del self.pipeline_cfg['sources'][0]['counters']
|
||||
self._exception_create_pipelinemanager()
|
||||
|
||||
def test_source_dangling_sink(self):
|
||||
self.pipeline_cfg['sources'].append({
|
||||
'name': 'second_source',
|
||||
|
Loading…
Reference in New Issue
Block a user