Merge "Fix early processing of merge-pending items on reconfig" into feature/zuulv3

This commit is contained in:
Zuul 2017-10-07 06:14:15 +00:00 committed by Gerrit Code Review
commit d88620a3b2
3 changed files with 34 additions and 15 deletions

View File

@ -1570,7 +1570,7 @@ class FakeGearmanServer(gear.Server):
parameters = json.loads(job.arguments.decode('utf8'))
if not regex or re.match(regex, parameters.get('job')):
match = True
if job.name == b'merger:merge':
if job.name.startswith(b'merger:'):
if not regex:
match = True
if match:

View File

@ -4715,6 +4715,28 @@ For CI problems and help debugging, contact ci@example.org"""
build = self.getJobFromHistory('py27')
self.assertEqual(build.parameters['zuul']['jobtags'], [])
def test_pending_merge_in_reconfig(self):
# Test that if we are waiting for an outstanding merge on
# reconfiguration that we continue to do so.
self.gearman_server.hold_merge_jobs_in_queue = True
A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
A.setMerged()
self.fake_gerrit.addEvent(A.getRefUpdatedEvent())
self.waitUntilSettled()
# Reconfigure while we still have an outstanding merge job
self.sched.reconfigureTenant(self.sched.abide.tenants['tenant-one'],
None)
self.waitUntilSettled()
# Verify the merge job is still running and that the item is
# in the pipeline
self.assertEqual(len(self.sched.merger.jobs), 1)
tenant = self.sched.abide.tenants.get('tenant-one')
pipeline = tenant.layout.pipelines['post']
self.assertEqual(len(pipeline.getAllItems()), 1)
self.gearman_server.hold_merge_jobs_in_queue = False
self.gearman_server.release()
self.waitUntilSettled()
class TestExecutor(ZuulTestCase):
tenant_config_file = 'config/single-tenant/main.yaml'

View File

@ -229,20 +229,17 @@ class PipelineManager(object):
(item.change, change_queue))
change_queue.enqueueItem(item)
# Get an updated copy of the layout if necessary.
# This will return one of the following:
# 1) An existing layout from the item ahead or pipeline.
# 2) A newly created layout from the cached pipeline
# layout config plus the previously returned
# in-repo files stored in the buildset.
# 3) None in the case that a fetch of the files from
# the merger is still pending.
item.layout = self.getLayout(item)
# Rebuild the frozen job tree from the new layout, if
# we have one. If not, it will be built later.
if item.layout:
item.freezeJobGraph()
# Get an updated copy of the layout and update the job
# graph if necessary. This resumes the buildset merge
# state machine. If we have an up-to-date layout, it
# will go ahead and refresh the job graph if needed;
# or it will send a new merge job if necessary, or it
# will do nothing if we're waiting on a merge job.
item.job_graph = None
item.layout = None
if item.active:
if self.prepareItem(item):
self.prepareJobs(item)
# Re-set build results in case any new jobs have been
# added to the tree.