Repository: aurora Updated Branches: refs/heads/master 620a12c0a -> b9d9ee3cc
Kill flaky TaskObserverTest. Previously, a mock threading.Event was waited on in one thread and the count of waits was read in another thread. Most thread memory models do not guaranty reads are fresh in this scenario unless there is a memory barrier of some sort forcing per-cpu caches to be flushed. Since the test really only verified correct conversion of a poll interval to fractional seconds - kill the test as not pulling its weight. Bugs closed: AURORA-1570 Reviewed at https://reviews.apache.org/r/41915/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/b9d9ee3c Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/b9d9ee3c Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/b9d9ee3c Branch: refs/heads/master Commit: b9d9ee3cca1860cedafc46e5bea4824e5da07f33 Parents: 620a12c Author: John Sirois <[email protected]> Authored: Tue Jan 5 09:54:16 2016 -0800 Committer: Bill Farner <[email protected]> Committed: Tue Jan 5 09:54:16 2016 -0800 ---------------------------------------------------------------------- src/test/python/apache/thermos/observer/BUILD | 1 + .../thermos/observer/test_task_observer.py | 45 -------------------- 2 files changed, 1 insertion(+), 45 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/b9d9ee3c/src/test/python/apache/thermos/observer/BUILD ---------------------------------------------------------------------- diff --git a/src/test/python/apache/thermos/observer/BUILD b/src/test/python/apache/thermos/observer/BUILD index f3f697c..ec391f2 100644 --- a/src/test/python/apache/thermos/observer/BUILD +++ b/src/test/python/apache/thermos/observer/BUILD @@ -17,6 +17,7 @@ python_tests( sources = globs('*.py'), dependencies = [ '3rdparty/python:mock', + 'src/main/python/apache/thermos/monitoring', 'src/main/python/apache/thermos/observer', ] ) http://git-wip-us.apache.org/repos/asf/aurora/blob/b9d9ee3c/src/test/python/apache/thermos/observer/test_task_observer.py ---------------------------------------------------------------------- diff --git a/src/test/python/apache/thermos/observer/test_task_observer.py b/src/test/python/apache/thermos/observer/test_task_observer.py deleted file mode 100644 index ace15c5..0000000 --- a/src/test/python/apache/thermos/observer/test_task_observer.py +++ /dev/null @@ -1,45 +0,0 @@ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import unittest - -from mock import create_autospec, patch -from twitter.common.quantity import Amount, Time - -from apache.thermos.observer.detector import ObserverTaskDetector -from apache.thermos.observer.task_observer import TaskObserver - - -class TaskObserverTest(unittest.TestCase): - def test_run_loop(self): - """Test observer run loop.""" - mock_task_detector = create_autospec(spec=ObserverTaskDetector) - with patch( - "apache.thermos.observer.task_observer.ObserverTaskDetector", - return_value=mock_task_detector) as mock_detector: - with patch('threading._Event.wait') as mock_wait: - - run_count = 3 - interval = 15 - observer = TaskObserver(mock_detector, interval=Amount(interval, Time.SECONDS)) - observer.start() - while len(mock_wait.mock_calls) < run_count: - pass - - observer.stop() - - assert len(mock_task_detector.mock_calls) >= run_count - assert len(mock_wait.mock_calls) >= run_count - args = mock_wait.mock_calls[1][1] - assert interval == args[0]
