Fix race in test_reconfigure_window_fixed

By not waiting until settled after the second reconfiguration,
we might get to the release() call (which releases all jobs) before
the executor server had processed the stop jobs from the
reconfiguration event.  This caused the jobs to have the 'success'
result instead of 'aborted'.  In fact, that was the usual case,
which is why we were checking for 'success' on the restarted jobs.
Only when the system was slow enough do we see what it was really
doing -- aborting the jobs.

Also, remove the release('job1') call so that both of change B's
jobs are aborted, instead of just one.

Finally, I've added an extra wait until settled after the first
reconfiguration event.  This should not be necessary, but it
seems like good practice.

Change-Id: I87e926e009e031f8866aeab87411e3487e06f978
This commit is contained in:
James E. Blair 2018-05-17 07:31:34 -07:00
parent 1b747ca65f
commit 12a4b7f1d2
1 changed files with 4 additions and 3 deletions

View File

@ -4160,11 +4160,11 @@ class TestScheduler(ZuulTestCase):
self.assertEqual(queue.window, 2)
self.assertTrue(len(self.builds), 4)
self.executor_server.release('job1')
self.waitUntilSettled()
self.commitConfigUpdate('org/common-config',
'layouts/reconfigure-window-fixed2.yaml')
self.sched.reconfigure(self.config)
self.waitUntilSettled()
tenant = self.sched.abide.tenants.get('tenant-one')
queue = tenant.layout.pipelines['gate'].queues[0]
# Because we have configured a static window, it should
@ -4179,6 +4179,7 @@ class TestScheduler(ZuulTestCase):
tenant = self.sched.abide.tenants.get('tenant-one')
queue = tenant.layout.pipelines['gate'].queues[0]
self.assertEqual(queue.window, 1)
self.waitUntilSettled()
# B's builds have been canceled now
self.assertTrue(len(self.builds), 2)
@ -4190,9 +4191,9 @@ class TestScheduler(ZuulTestCase):
self.waitUntilSettled()
self.assertHistory([
dict(name='job1', result='SUCCESS', changes='1,1'),
dict(name='job1', result='SUCCESS', changes='1,1 2,1'),
dict(name='job1', result='ABORTED', changes='1,1 2,1'),
dict(name='job2', result='SUCCESS', changes='1,1'),
dict(name='job2', result='SUCCESS', changes='1,1 2,1'),
dict(name='job2', result='ABORTED', changes='1,1 2,1'),
dict(name='job1', result='SUCCESS', changes='1,1 2,1'),
dict(name='job2', result='SUCCESS', changes='1,1 2,1'),
], ordered=False)