From 12a4b7f1d208e4777a7a437118c03d9a391a7cc4 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 17 May 2018 07:31:34 -0700 Subject: [PATCH] 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 --- tests/unit/test_scheduler.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py index 89fd3f6e7d..8286313dc2 100755 --- a/tests/unit/test_scheduler.py +++ b/tests/unit/test_scheduler.py @@ -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)