Merge "Raise an error if pipeline is defined twice"
This commit is contained in:
commit
9b6c7e60b5
47
tests/fixtures/layouts/broken-double-gate.yaml
vendored
Normal file
47
tests/fixtures/layouts/broken-double-gate.yaml
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
- pipeline:
|
||||||
|
name: gate
|
||||||
|
manager: dependent
|
||||||
|
trigger:
|
||||||
|
gerrit:
|
||||||
|
- event: comment-added
|
||||||
|
approval:
|
||||||
|
- Approved: 1
|
||||||
|
success:
|
||||||
|
gerrit:
|
||||||
|
Verified: 2
|
||||||
|
submit: true
|
||||||
|
failure:
|
||||||
|
gerrit:
|
||||||
|
Verified: -2
|
||||||
|
start:
|
||||||
|
gerrit:
|
||||||
|
Verified: 0
|
||||||
|
|
||||||
|
- pipeline:
|
||||||
|
name: gate
|
||||||
|
manager: dependent
|
||||||
|
trigger:
|
||||||
|
gerrit:
|
||||||
|
- event: comment-added
|
||||||
|
approval:
|
||||||
|
- Approved: 1
|
||||||
|
success:
|
||||||
|
gerrit:
|
||||||
|
Verified: 2
|
||||||
|
submit: true
|
||||||
|
failure:
|
||||||
|
gerrit:
|
||||||
|
Verified: -2
|
||||||
|
start:
|
||||||
|
gerrit:
|
||||||
|
Verified: 0
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: base
|
||||||
|
parent: null
|
||||||
|
|
||||||
|
- project:
|
||||||
|
name: org/project
|
||||||
|
gate:
|
||||||
|
jobs:
|
||||||
|
- base
|
@ -154,10 +154,7 @@ class TestJob(BaseTestCase):
|
|||||||
job.applyVariant(bad_final, self.layout)
|
job.applyVariant(bad_final, self.layout)
|
||||||
|
|
||||||
def test_job_inheritance_job_tree(self):
|
def test_job_inheritance_job_tree(self):
|
||||||
pipeline = model.Pipeline('gate', self.tenant)
|
queue = model.ChangeQueue(self.pipeline)
|
||||||
pipeline.source_context = self.context
|
|
||||||
self.layout.addPipeline(pipeline)
|
|
||||||
queue = model.ChangeQueue(pipeline)
|
|
||||||
|
|
||||||
base = self.pcontext.job_parser.fromYaml({
|
base = self.pcontext.job_parser.fromYaml({
|
||||||
'_source_context': self.context,
|
'_source_context': self.context,
|
||||||
@ -229,10 +226,7 @@ class TestJob(BaseTestCase):
|
|||||||
self.assertEqual(job.timeout, 70)
|
self.assertEqual(job.timeout, 70)
|
||||||
|
|
||||||
def test_inheritance_keeps_matchers(self):
|
def test_inheritance_keeps_matchers(self):
|
||||||
pipeline = model.Pipeline('gate', self.tenant)
|
queue = model.ChangeQueue(self.pipeline)
|
||||||
pipeline.source_context = self.context
|
|
||||||
self.layout.addPipeline(pipeline)
|
|
||||||
queue = model.ChangeQueue(pipeline)
|
|
||||||
|
|
||||||
base = self.pcontext.job_parser.fromYaml({
|
base = self.pcontext.job_parser.fromYaml({
|
||||||
'_source_context': self.context,
|
'_source_context': self.context,
|
||||||
|
@ -2586,6 +2586,17 @@ class TestBrokenConfig(ZuulTestCase):
|
|||||||
"Zuul encountered a syntax error",
|
"Zuul encountered a syntax error",
|
||||||
str(tenant.layout.loading_errors[0].error))
|
str(tenant.layout.loading_errors[0].error))
|
||||||
|
|
||||||
|
@simple_layout('layouts/broken-double-gate.yaml')
|
||||||
|
def test_broken_config_on_startup_double_gate(self):
|
||||||
|
# Verify that duplicated pipeline definitions raise config errors
|
||||||
|
tenant = self.sched.abide.tenants.get('tenant-one')
|
||||||
|
self.assertEquals(
|
||||||
|
len(tenant.layout.loading_errors), 1,
|
||||||
|
"An error should have been stored")
|
||||||
|
self.assertIn(
|
||||||
|
"Zuul encountered a syntax error",
|
||||||
|
str(tenant.layout.loading_errors[0].error))
|
||||||
|
|
||||||
def test_dynamic_ignore(self):
|
def test_dynamic_ignore(self):
|
||||||
# Verify dynamic config behaviors inside a tenant broken config
|
# Verify dynamic config behaviors inside a tenant broken config
|
||||||
tenant = self.sched.abide.tenants.get('tenant-one')
|
tenant = self.sched.abide.tenants.get('tenant-one')
|
||||||
|
@ -1129,6 +1129,7 @@ class PipelineParser(object):
|
|||||||
self.schema(conf)
|
self.schema(conf)
|
||||||
pipeline = model.Pipeline(conf['name'], self.pcontext.tenant)
|
pipeline = model.Pipeline(conf['name'], self.pcontext.tenant)
|
||||||
pipeline.source_context = conf['_source_context']
|
pipeline.source_context = conf['_source_context']
|
||||||
|
pipeline.start_mark = conf['_start_mark']
|
||||||
pipeline.description = conf.get('description')
|
pipeline.description = conf.get('description')
|
||||||
|
|
||||||
precedence = model.PRECEDENCE_MAP[conf.get('precedence')]
|
precedence = model.PRECEDENCE_MAP[conf.get('precedence')]
|
||||||
|
@ -247,6 +247,7 @@ class Pipeline(object):
|
|||||||
# reach the currently active layout for that tenant.
|
# reach the currently active layout for that tenant.
|
||||||
self.tenant = tenant
|
self.tenant = tenant
|
||||||
self.source_context = None
|
self.source_context = None
|
||||||
|
self.start_mark = None
|
||||||
self.description = None
|
self.description = None
|
||||||
self.failure_message = None
|
self.failure_message = None
|
||||||
self.merge_failure_message = None
|
self.merge_failure_message = None
|
||||||
@ -3561,6 +3562,11 @@ class Layout(object):
|
|||||||
"may not be added to %s" % (
|
"may not be added to %s" % (
|
||||||
pipeline.tenant,
|
pipeline.tenant,
|
||||||
self.tenant))
|
self.tenant))
|
||||||
|
|
||||||
|
if pipeline.name in self.pipelines:
|
||||||
|
raise Exception(
|
||||||
|
"Pipeline %s is already defined" % pipeline.name)
|
||||||
|
|
||||||
self.pipelines[pipeline.name] = pipeline
|
self.pipelines[pipeline.name] = pipeline
|
||||||
|
|
||||||
def addProjectTemplate(self, project_template):
|
def addProjectTemplate(self, project_template):
|
||||||
|
Loading…
Reference in New Issue
Block a user