Merge "Add test for variant override" into feature/zuulv3

This commit is contained in:
Jenkins 2016-12-05 14:15:48 +00:00 committed by Gerrit Code Review
commit 4c5ac4e95a
3 changed files with 109 additions and 0 deletions

View File

@ -0,0 +1,46 @@
- pipeline:
name: check
manager: independent
source:
gerrit
trigger:
gerrit:
- event: patchset-created
success:
gerrit:
verified: 1
failure:
gerrit:
verified: -1
- job:
name: project-test-irrelevant-starts-empty
- job:
name: project-test-irrelevant-starts-full
irrelevant-files:
- ^README$
- ^ignoreme$
- job:
name: project-test-nomatch-starts-empty
- job:
name: project-test-nomatch-starts-full
irrelevant-files:
- ^README$
- project:
name: org/project
check:
jobs:
- project-test-irrelevant-starts-empty:
irrelevant-files:
- ^README$
- ^ignoreme$
- project-test-irrelevant-starts-full
- project-test-nomatch-starts-empty:
irrelevant-files:
- ^README$
- project-test-nomatch-starts-full

View File

@ -265,6 +265,51 @@ class TestJob(BaseTestCase):
self.assertEqual(job.name, 'python27')
self.assertEqual(job.timeout, 70)
def test_inheritance_keeps_matchers(self):
layout = model.Layout()
pipeline = model.Pipeline('gate', layout)
layout.addPipeline(pipeline)
queue = model.ChangeQueue(pipeline)
project = model.Project('project')
base = configloader.JobParser.fromYaml(layout, {
'_source_project': project,
'name': 'base',
'timeout': 30,
})
layout.addJob(base)
python27 = configloader.JobParser.fromYaml(layout, {
'_source_project': project,
'name': 'python27',
'parent': 'base',
'timeout': 40,
'irrelevant-files': ['^ignored-file$'],
})
layout.addJob(python27)
project_config = configloader.ProjectParser.fromYaml(layout, {
'name': 'project',
'gate': {
'jobs': [
'python27',
]
}
})
layout.addProjectConfig(project_config, update_pipeline=False)
change = model.Change(project)
change.branch = 'master'
change.files = ['/COMMIT_MSG', 'ignored-file']
item = queue.enqueueChange(change)
item.current_build_set.layout = layout
self.assertTrue(base.changeMatches(change))
self.assertFalse(python27.changeMatches(change))
item.freezeJobTree()
self.assertEqual([], item.getJobs())
def test_job_source_project(self):
layout = model.Layout()
base_project = model.Project('base_project')

View File

@ -2237,6 +2237,24 @@ class TestScheduler(ZuulTestCase):
def test_irrelevant_files_no_match_runs_job(self):
self._test_irrelevant_files_jobs(should_skip=False)
def test_inherited_jobs_keep_matchers(self):
self.updateConfigLayout('layout-inheritance')
self.sched.reconfigure(self.config)
files = {'ignoreme': 'ignored\n'}
change = self.fake_gerrit.addFakeChange('org/project',
'master',
'test irrelevant-files',
files=files)
self.fake_gerrit.addEvent(change.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
run_jobs = set([build.name for build in self.history])
self.assertEqual(set(['project-test-nomatch-starts-empty',
'project-test-nomatch-starts-full']), run_jobs)
@skip("Disabled for early v3 development")
def test_test_config(self):
"Test that we can test the config"