Merge "Add internal noop job"
This commit is contained in:
commit
64a53835f3
|
@ -694,6 +694,11 @@ succeeds. In the above example, project-unittest, project-pep8, and
|
||||||
project-pyflakes are only executed if project-merge succeeds. This
|
project-pyflakes are only executed if project-merge succeeds. This
|
||||||
can help avoid running unnecessary jobs.
|
can help avoid running unnecessary jobs.
|
||||||
|
|
||||||
|
The special job named ``noop`` is internal to Zuul and will always
|
||||||
|
return ``SUCCESS`` immediately. This can be useful if you require
|
||||||
|
that all changes be processed by a pipeline but a project has no jobs
|
||||||
|
that can be run on it.
|
||||||
|
|
||||||
.. seealso:: The OpenStack Zuul configuration for a comprehensive example: https://github.com/openstack-infra/config/blob/master/modules/openstack_project/files/zuul/layout.yaml
|
.. seealso:: The OpenStack Zuul configuration for a comprehensive example: https://github.com/openstack-infra/config/blob/master/modules/openstack_project/files/zuul/layout.yaml
|
||||||
|
|
||||||
Project Templates
|
Project Templates
|
||||||
|
|
|
@ -38,6 +38,6 @@ projects:
|
||||||
- name: org/project
|
- name: org/project
|
||||||
merge-mode: cherry-pick
|
merge-mode: cherry-pick
|
||||||
check:
|
check:
|
||||||
- noop
|
- gate-noop
|
||||||
gate:
|
gate:
|
||||||
- noop
|
- gate-noop
|
||||||
|
|
|
@ -795,6 +795,7 @@ class TestScheduler(testtools.TestCase):
|
||||||
self.init_repo("org/layered-project")
|
self.init_repo("org/layered-project")
|
||||||
self.init_repo("org/node-project")
|
self.init_repo("org/node-project")
|
||||||
self.init_repo("org/conflict-project")
|
self.init_repo("org/conflict-project")
|
||||||
|
self.init_repo("org/noop-project")
|
||||||
|
|
||||||
self.statsd = FakeStatsd()
|
self.statsd = FakeStatsd()
|
||||||
os.environ['STATSD_HOST'] = 'localhost'
|
os.environ['STATSD_HOST'] = 'localhost'
|
||||||
|
@ -2654,6 +2655,19 @@ class TestScheduler(testtools.TestCase):
|
||||||
self.assertEqual(len(self.history), 10)
|
self.assertEqual(len(self.history), 10)
|
||||||
self.assertEqual(self.countJobResults(self.history, 'ABORTED'), 1)
|
self.assertEqual(self.countJobResults(self.history, 'ABORTED'), 1)
|
||||||
|
|
||||||
|
def test_noop_job(self):
|
||||||
|
"Test that the internal noop job works"
|
||||||
|
A = self.fake_gerrit.addFakeChange('org/noop-project', 'master', 'A')
|
||||||
|
A.addApproval('CRVW', 2)
|
||||||
|
self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
|
||||||
|
self.waitUntilSettled()
|
||||||
|
|
||||||
|
self.assertEqual(len(self.gearman_server.getQueue()), 0)
|
||||||
|
self.assertTrue(self.sched._areAllBuildsComplete())
|
||||||
|
self.assertEqual(len(self.history), 0)
|
||||||
|
self.assertEqual(A.data['status'], 'MERGED')
|
||||||
|
self.assertEqual(A.reported, 2)
|
||||||
|
|
||||||
def test_zuul_refs(self):
|
def test_zuul_refs(self):
|
||||||
"Test that zuul refs exist and have the right changes"
|
"Test that zuul refs exist and have the right changes"
|
||||||
self.worker.hold_jobs_in_build = True
|
self.worker.hold_jobs_in_build = True
|
||||||
|
@ -2858,6 +2872,11 @@ class TestScheduler(testtools.TestCase):
|
||||||
|
|
||||||
def test_stuck_job_cleanup(self):
|
def test_stuck_job_cleanup(self):
|
||||||
"Test that pending jobs are cleaned up if removed from layout"
|
"Test that pending jobs are cleaned up if removed from layout"
|
||||||
|
# This job won't be registered at startup because it is not in
|
||||||
|
# the standard layout, but we need it to already be registerd
|
||||||
|
# for when we reconfigure, as that is when Zuul will attempt
|
||||||
|
# to run the new job.
|
||||||
|
self.worker.registerFunction('build:gate-noop')
|
||||||
self.gearman_server.hold_jobs_in_queue = True
|
self.gearman_server.hold_jobs_in_queue = True
|
||||||
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
|
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
|
||||||
A.addApproval('CRVW', 2)
|
A.addApproval('CRVW', 2)
|
||||||
|
@ -2870,13 +2889,13 @@ class TestScheduler(testtools.TestCase):
|
||||||
self.sched.reconfigure(self.config)
|
self.sched.reconfigure(self.config)
|
||||||
self.waitUntilSettled()
|
self.waitUntilSettled()
|
||||||
|
|
||||||
self.gearman_server.release('noop')
|
self.gearman_server.release('gate-noop')
|
||||||
self.waitUntilSettled()
|
self.waitUntilSettled()
|
||||||
self.assertEqual(len(self.gearman_server.getQueue()), 0)
|
self.assertEqual(len(self.gearman_server.getQueue()), 0)
|
||||||
self.assertTrue(self.sched._areAllBuildsComplete())
|
self.assertTrue(self.sched._areAllBuildsComplete())
|
||||||
|
|
||||||
self.assertEqual(len(self.history), 1)
|
self.assertEqual(len(self.history), 1)
|
||||||
self.assertEqual(self.history[0].name, 'noop')
|
self.assertEqual(self.history[0].name, 'gate-noop')
|
||||||
self.assertEqual(self.history[0].result, 'SUCCESS')
|
self.assertEqual(self.history[0].result, 'SUCCESS')
|
||||||
|
|
||||||
def test_file_jobs(self):
|
def test_file_jobs(self):
|
||||||
|
|
|
@ -290,6 +290,11 @@ class Gearman(object):
|
||||||
build = Build(job, uuid)
|
build = Build(job, uuid)
|
||||||
build.parameters = params
|
build.parameters = params
|
||||||
|
|
||||||
|
if job.name == 'noop':
|
||||||
|
build.result = 'SUCCESS'
|
||||||
|
self.sched.onBuildCompleted(build)
|
||||||
|
return build
|
||||||
|
|
||||||
gearman_job = gear.Job(name, json.dumps(params),
|
gearman_job = gear.Job(name, json.dumps(params),
|
||||||
unique=uuid)
|
unique=uuid)
|
||||||
build.__gearman_job = gearman_job
|
build.__gearman_job = gearman_job
|
||||||
|
|
Loading…
Reference in New Issue