Fix race in test_periodic_override

The main body of the test used a config with a job with a branch selector
so that even though the timer trigger fired 2 events, only one of them would
result in a job being run.  However, the second config which the test switched
to in order to disable the timer dropped the branch selector, meaning that
in some cases an event in progress could end up causing a second job to start
running.  Add a new second configuration which retains the branch selector
to correct this.

Also, add some waitUntilSettled methods after the second reconfiguration, even
though they still shouldn't be strictly necessary.  If there are any more
race conditions, this should serve to stabilize them.

Change-Id: I309983148739943cb810e84322551e830d80cac5
diff --git a/tests/fixtures/layouts/repo-checkout-no-timer-override.yaml b/tests/fixtures/layouts/repo-checkout-no-timer-override.yaml
new file mode 100644
index 0000000..de3bfe0
--- /dev/null
+++ b/tests/fixtures/layouts/repo-checkout-no-timer-override.yaml
@@ -0,0 +1,21 @@
+- pipeline:
+    name: periodic
+    manager: independent
+    # Trigger is required, set it to one that is a noop
+    # during tests that check the timer trigger.
+    trigger:
+      gerrit:
+        - event: ref-updated
+
+- job:
+    name: integration
+    branches: master
+    override-branch: stable/havana
+    required-projects:
+      - org/project1
+
+- project:
+    name: org/project1
+    periodic:
+      jobs:
+        - integration
diff --git a/tests/unit/test_executor.py b/tests/unit/test_executor.py
index 4700bd1..95cccee 100755
--- a/tests/unit/test_executor.py
+++ b/tests/unit/test_executor.py
@@ -274,8 +274,9 @@
         # Stop queuing timer triggered jobs so that the assertions
         # below don't race against more jobs being queued.
         self.commitConfigUpdate('common-config',
-                                'layouts/repo-checkout-no-timer.yaml')
+                                'layouts/repo-checkout-no-timer-override.yaml')
         self.sched.reconfigure(self.config)
+        self.waitUntilSettled()
 
         self.assertEquals(1, len(self.builds), "One build is running")
 
@@ -313,6 +314,7 @@
         self.commitConfigUpdate('common-config',
                                 'layouts/repo-checkout-no-timer.yaml')
         self.sched.reconfigure(self.config)
+        self.waitUntilSettled()
 
         self.assertEquals(2, len(self.builds), "Two builds are running")
 
diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py
index 1e0affc..e36cdfe 100755
--- a/tests/unit/test_scheduler.py
+++ b/tests/unit/test_scheduler.py
@@ -1833,6 +1833,7 @@
         # Must be in same repo, so overwrite config with another one
         self.commitConfigUpdate('common-config', 'layouts/no-timer.yaml')
         self.sched.reconfigure(self.config)
+        self.waitUntilSettled()
 
         self.assertEqual(len(self.builds), 1, "One timer job")