Add non-voting jobs.
Change-Id: I5a9ccc857c28d458e3a8fbac03a9d29cc49b1da0 Reviewed-on: https://review.openstack.org/11904 Reviewed-by: Clark Boylan <clark.boylan@gmail.com> Approved: James E. Blair <corvus@inaugust.com> Tested-by: Jenkins
This commit is contained in:
parent
1dbd508c42
commit
4ec821f978
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
14
tests/fixtures/layout.yaml
vendored
14
tests/fixtures/layout.yaml
vendored
@ -39,6 +39,8 @@ jobs:
|
||||
- name: ^.*-merge$
|
||||
failure-message: Unable to merge change
|
||||
hold-following-changes: true
|
||||
- name: nonvoting-project-test2
|
||||
voting: false
|
||||
|
||||
projects:
|
||||
- name: org/project
|
||||
@ -89,3 +91,15 @@ projects:
|
||||
- one-job-project-merge
|
||||
post:
|
||||
- one-job-project-post
|
||||
|
||||
- name: org/nonvoting-project
|
||||
check:
|
||||
- nonvoting-project-merge:
|
||||
- nonvoting-project-test1
|
||||
- nonvoting-project-test2
|
||||
gate:
|
||||
- nonvoting-project-merge:
|
||||
- nonvoting-project-test1
|
||||
- nonvoting-project-test2
|
||||
post:
|
||||
- nonvoting-project-post
|
||||
|
@ -589,6 +589,7 @@ class testScheduler(unittest.TestCase):
|
||||
init_repo("org/project1")
|
||||
init_repo("org/project2")
|
||||
init_repo("org/one-job-project")
|
||||
init_repo("org/nonvoting-project")
|
||||
self.config = CONFIG
|
||||
self.sched = zuul.scheduler.Scheduler()
|
||||
|
||||
@ -1027,8 +1028,6 @@ class testScheduler(unittest.TestCase):
|
||||
self.fake_jenkins.fakeRelease('.*-merge')
|
||||
self.waitUntilSettled()
|
||||
|
||||
pprint.pprint(jobs)
|
||||
|
||||
ref = jobs[-1].parameters['ZUUL_REF']
|
||||
self.fake_jenkins.hold_jobs_in_queue = False
|
||||
self.fake_jenkins.fakeRelease()
|
||||
@ -1304,3 +1303,21 @@ class testScheduler(unittest.TestCase):
|
||||
assert A.reported == 2
|
||||
assert B.reported == 2
|
||||
assert C.reported == 2
|
||||
|
||||
def test_nonvoting_job(self):
|
||||
"Test that non-voting jobs don't vote."
|
||||
A = self.fake_gerrit.addFakeChange('org/nonvoting-project',
|
||||
'master', 'A')
|
||||
A.addApproval('CRVW', 2)
|
||||
self.fake_jenkins.fakeAddFailTest('nonvoting-project-test2', A)
|
||||
self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
|
||||
|
||||
self.waitUntilSettled()
|
||||
jobs = self.fake_jenkins.all_jobs
|
||||
finished_jobs = self.fake_jenkins.job_history
|
||||
|
||||
assert A.data['status'] == 'MERGED'
|
||||
assert A.reported == 2
|
||||
assert finished_jobs[0]['result'] == 'SUCCESS'
|
||||
assert finished_jobs[1]['result'] == 'SUCCESS'
|
||||
assert finished_jobs[2]['result'] == 'FAILURE'
|
||||
|
@ -95,6 +95,8 @@ class Pipeline(object):
|
||||
|
||||
def didAllJobsSucceed(self, changeish):
|
||||
for job in self.getJobs(changeish):
|
||||
if not job.voting:
|
||||
continue
|
||||
build = changeish.current_build_set.getBuild(job.name)
|
||||
if not build:
|
||||
return False
|
||||
@ -104,6 +106,8 @@ class Pipeline(object):
|
||||
|
||||
def didAnyJobFail(self, changeish):
|
||||
for job in self.getJobs(changeish):
|
||||
if not job.voting:
|
||||
continue
|
||||
build = changeish.current_build_set.getBuild(job.name)
|
||||
if build and build.result == 'FAILURE':
|
||||
return True
|
||||
@ -142,6 +146,10 @@ class Pipeline(object):
|
||||
else:
|
||||
result = None
|
||||
job_name = job.name
|
||||
if not job.voting:
|
||||
voting = ' (non-voting)'
|
||||
else:
|
||||
voting = ''
|
||||
if html:
|
||||
if build:
|
||||
url = build.url
|
||||
@ -149,7 +157,7 @@ class Pipeline(object):
|
||||
url = None
|
||||
if url is not None:
|
||||
job_name = '<a href="%s">%s</a>' % (url, job_name)
|
||||
ret += '%s %s: %s' % (indent_str, job_name, result)
|
||||
ret += '%s %s: %s%s' % (indent_str, job_name, result, voting)
|
||||
ret += '\n'
|
||||
if changeish.change_ahead:
|
||||
ret += '%sWaiting on:\n' % (indent_str)
|
||||
@ -181,7 +189,11 @@ class Pipeline(object):
|
||||
url = build.url
|
||||
if not url:
|
||||
url = job.name
|
||||
ret += '- %s : %s\n' % (url, result)
|
||||
if not job.voting:
|
||||
voting = ' (non-voting)'
|
||||
else:
|
||||
voting = ''
|
||||
ret += '- %s : %s%s\n' % (url, result, voting)
|
||||
return ret
|
||||
|
||||
def formatDescription(self, build):
|
||||
@ -374,6 +386,7 @@ class Job(object):
|
||||
self.success_message = None
|
||||
self.parameter_function = None
|
||||
self.hold_following_changes = False
|
||||
self.voting = True
|
||||
self.branches = []
|
||||
self._branches = []
|
||||
|
||||
@ -388,6 +401,7 @@ class Job(object):
|
||||
self.success_message = other.success_message
|
||||
self.parameter_function = other.parameter_function
|
||||
self.hold_following_changes = other.hold_following_changes
|
||||
self.voting = other.voting
|
||||
self.branches = other.branches[:]
|
||||
self._branches = other._branches[:]
|
||||
|
||||
|
@ -115,6 +115,9 @@ class Scheduler(threading.Thread):
|
||||
m = config_job.get('hold-following-changes', False)
|
||||
if m:
|
||||
job.hold_following_changes = True
|
||||
m = config_job.get('voting', None)
|
||||
if m is not None:
|
||||
job.voting = m
|
||||
fname = config_job.get('parameter-function', None)
|
||||
if fname:
|
||||
func = self._config_env.get(fname, None)
|
||||
@ -415,10 +418,11 @@ class BasePipelineManager(object):
|
||||
hold = ''
|
||||
if tree.job.hold_following_changes:
|
||||
hold = ' [hold]'
|
||||
self.log.info("%s%s%s%s" % (istr,
|
||||
repr(tree.job),
|
||||
efilters,
|
||||
hold))
|
||||
voting = ''
|
||||
if not tree.job.voting:
|
||||
voting = ' [nonvoting]'
|
||||
self.log.info("%s%s%s%s%s" % (istr, repr(tree.job),
|
||||
efilters, hold, voting))
|
||||
for x in tree.job_trees:
|
||||
log_jobs(x, indent + 2)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user