Treat any non-success result as a failure.

Aborted, lost, skipped, unstable will all cause a change not to
merge, so treat them the same when deciding if any job for a
change failed.  This should stop new launches and cancel builds
faster when these alternate failures happen.

Also, make the output of the completed jobs in the test suite
more comprehensible by including the change numbers, and use
a new object with its own string formatting for printing.

Change-Id: I2826b0eb5d26a019fed7d20bb1296624588c9fac
Reviewed-on: https://review.openstack.org/23123
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
This commit is contained in:
James E. Blair 2013-02-27 14:11:45 -08:00 committed by Jenkins
parent 263fba97de
commit 0018a6c711
2 changed files with 52 additions and 36 deletions

View File

@ -457,8 +457,12 @@ class FakeJenkinsJob(threading.Thread):
if self.aborted:
result = 'ABORTED'
changes = None
if 'ZUUL_CHANGE_IDS' in self.parameters:
changes = self.parameters['ZUUL_CHANGE_IDS']
self.jenkins.fakeAddHistory(name=self.name, number=self.number,
result=result)
result=result, changes=changes)
self.jenkins.lock.acquire()
self.callback.jenkins_endpoint(FakeJenkinsEvent(self.name,
self.number,
@ -495,8 +499,16 @@ class FakeJenkins(object):
def fakeDequeue(self, job):
self.queue.remove(job)
class FakeJobHistory(object):
def __init__(self, **kw):
self.__dict__.update(kw)
def __repr__(self):
return ("<Completed job, result: %s name: %s #%s changes: %s>" %
(self.result, self.name, self.number, self.changes))
def fakeAddHistory(self, **kw):
self.job_history.append(kw)
self.job_history.append(self.FakeJobHistory(**kw))
def fakeRelease(self, regex=None):
all_jobs = self.all_jobs[:]
@ -713,7 +725,7 @@ class testScheduler(unittest.TestCase):
self.sched.wake_event.wait(0.1)
def countJobResults(self, jobs, result):
jobs = filter(lambda x: x['result'] == result, jobs)
jobs = filter(lambda x: x.result == result, jobs)
return len(jobs)
def assertEmptyQueues(self):
@ -735,13 +747,13 @@ class testScheduler(unittest.TestCase):
self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
self.waitUntilSettled()
jobs = self.fake_jenkins.job_history
job_names = [x['name'] for x in jobs]
job_names = [x.name for x in jobs]
assert 'project-merge' in job_names
assert 'project-test1' in job_names
assert 'project-test2' in job_names
assert jobs[0]['result'] == 'SUCCESS'
assert jobs[1]['result'] == 'SUCCESS'
assert jobs[2]['result'] == 'SUCCESS'
assert jobs[0].result == 'SUCCESS'
assert jobs[1].result == 'SUCCESS'
assert jobs[2].result == 'SUCCESS'
assert A.data['status'] == 'MERGED'
assert A.reported == 2
self.assertEmptyQueues()
@ -945,6 +957,11 @@ class testScheduler(unittest.TestCase):
self.fake_jenkins.fakeRelease()
self.waitUntilSettled()
for x in jobs:
print x
for x in finished_jobs:
print x
assert len(jobs) == 0
assert len(finished_jobs) == 15
assert A.data['status'] == 'NEW'
@ -1172,7 +1189,7 @@ class testScheduler(unittest.TestCase):
self.waitUntilSettled()
jobs = self.fake_jenkins.job_history
job_names = [x['name'] for x in jobs]
job_names = [x.name for x in jobs]
assert len(jobs) == 1
assert 'project-post' in job_names
self.assertEmptyQueues()
@ -1413,9 +1430,9 @@ class testScheduler(unittest.TestCase):
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'
assert finished_jobs[0].result == 'SUCCESS'
assert finished_jobs[1].result == 'SUCCESS'
assert finished_jobs[2].result == 'FAILURE'
self.assertEmptyQueues()
def test_check_queue_success(self):
@ -1429,9 +1446,9 @@ class testScheduler(unittest.TestCase):
assert A.data['status'] == 'NEW'
assert A.reported == 1
assert finished_jobs[0]['result'] == 'SUCCESS'
assert finished_jobs[1]['result'] == 'SUCCESS'
assert finished_jobs[2]['result'] == 'SUCCESS'
assert finished_jobs[0].result == 'SUCCESS'
assert finished_jobs[1].result == 'SUCCESS'
assert finished_jobs[2].result == 'SUCCESS'
self.assertEmptyQueues()
def test_check_queue_failure(self):
@ -1446,9 +1463,9 @@ class testScheduler(unittest.TestCase):
assert A.data['status'] == 'NEW'
assert A.reported == 1
assert finished_jobs[0]['result'] == 'SUCCESS'
assert finished_jobs[1]['result'] == 'SUCCESS'
assert finished_jobs[2]['result'] == 'FAILURE'
assert finished_jobs[0].result == 'SUCCESS'
assert finished_jobs[1].result == 'SUCCESS'
assert finished_jobs[2].result == 'FAILURE'
self.assertEmptyQueues()
def test_dependent_behind_dequeue(self):
@ -1555,13 +1572,13 @@ class testScheduler(unittest.TestCase):
self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
self.waitUntilSettled()
jobs = self.fake_jenkins.job_history
job_names = [x['name'] for x in jobs]
job_names = [x.name for x in jobs]
assert 'project-merge' in job_names
assert 'project-test1' in job_names
assert 'project-test2' in job_names
assert jobs[0]['result'] == 'SUCCESS'
assert jobs[1]['result'] == 'SUCCESS'
assert jobs[2]['result'] == 'SUCCESS'
assert jobs[0].result == 'SUCCESS'
assert jobs[1].result == 'SUCCESS'
assert jobs[2].result == 'SUCCESS'
assert A.data['status'] == 'MERGED'
assert A.reported == 2
self.assertEmptyQueues()
@ -1574,13 +1591,13 @@ class testScheduler(unittest.TestCase):
self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
self.waitUntilSettled()
jobs = self.fake_jenkins.job_history
job_names = [x['name'] for x in jobs]
job_names = [x.name for x in jobs]
assert 'project-merge' in job_names
assert 'project-test1' in job_names
assert 'project-test2' in job_names
assert jobs[0]['result'] == 'SUCCESS'
assert jobs[1]['result'] == 'SUCCESS'
assert jobs[2]['result'] == 'SUCCESS'
assert jobs[0].result == 'SUCCESS'
assert jobs[1].result == 'SUCCESS'
assert jobs[2].result == 'SUCCESS'
assert A.data['status'] == 'MERGED'
assert A.reported == 2
self.assertEmptyQueues()
@ -1599,13 +1616,13 @@ class testScheduler(unittest.TestCase):
self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
self.waitUntilSettled()
jobs = self.fake_jenkins.job_history
job_names = [x['name'] for x in jobs]
job_names = [x.name for x in jobs]
assert 'project1-merge' in job_names
assert 'project1-test1' in job_names
assert 'project1-test2' in job_names
assert jobs[0]['result'] == 'SUCCESS'
assert jobs[1]['result'] == 'SUCCESS'
assert jobs[2]['result'] == 'SUCCESS'
assert jobs[0].result == 'SUCCESS'
assert jobs[1].result == 'SUCCESS'
assert jobs[2].result == 'SUCCESS'
assert A.data['status'] == 'MERGED'
assert A.reported == 2
self.assertEmptyQueues()
@ -1622,7 +1639,7 @@ class testScheduler(unittest.TestCase):
while A.reported < 2:
self.waitUntilSettled()
jobs = self.fake_jenkins.job_history
job_names = [x['name'] for x in jobs]
job_names = [x.name for x in jobs]
assert not job_names
assert A.data['status'] == 'NEW'
assert A.reported == 2
@ -1635,13 +1652,13 @@ class testScheduler(unittest.TestCase):
self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
self.waitUntilSettled()
jobs = self.fake_jenkins.job_history
job_names = [x['name'] for x in jobs]
job_names = [x.name for x in jobs]
assert 'project-merge' in job_names
assert 'project-test1' in job_names
assert 'project-test2' in job_names
assert jobs[0]['result'] == 'SUCCESS'
assert jobs[1]['result'] == 'SUCCESS'
assert jobs[2]['result'] == 'SUCCESS'
assert jobs[0].result == 'SUCCESS'
assert jobs[1].result == 'SUCCESS'
assert jobs[2].result == 'SUCCESS'
assert A.data['status'] == 'MERGED'
assert A.reported == 2
self.assertEmptyQueues()

View File

@ -123,8 +123,7 @@ class Pipeline(object):
if not job.voting:
continue
build = changeish.current_build_set.getBuild(job.name)
# Treat LOST jobs as failures
if build and (build.result == 'FAILURE' or build.result == 'LOST'):
if build and build.result and (build.result != 'SUCCESS'):
return True
return False