aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject aurora git commit: Run all python tests in a single chroot
Date Mon, 08 Feb 2016 07:40:13 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 784deaf40 -> b3de59cde


Run all python tests in a single chroot

For whatever reason, it is no longer necessary to run tests with `fast=False`. The rename
is necessary to prevent identical named test suites form clashing.

Reviewed at https://reviews.apache.org/r/43317/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/b3de59cd
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/b3de59cd
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/b3de59cd

Branch: refs/heads/master
Commit: b3de59cde6e6ac86b294bfadfd0c4352971099b2
Parents: 784deaf
Author: Stephan Erb <serb@apache.org>
Authored: Mon Feb 8 08:39:08 2016 +0100
Committer: Stephan Erb <stephan@dev.static-void.de>
Committed: Mon Feb 8 08:39:08 2016 +0100

----------------------------------------------------------------------
 pants.ini                                       |   7 -
 .../apache/thermos/observer/test_detector.py    | 161 -------------------
 .../observer/test_observer_task_detector.py     | 161 +++++++++++++++++++
 3 files changed, 161 insertions(+), 168 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/b3de59cd/pants.ini
----------------------------------------------------------------------
diff --git a/pants.ini b/pants.ini
index 984ac1f..4324a3f 100644
--- a/pants.ini
+++ b/pants.ini
@@ -28,13 +28,6 @@ version: 0.9.1
 interpreter_requirement: CPython>=2.7,<3
 
 
-[test.pytest]
-# As of Nov. 2015, the Aurora python tests cannot all be run in the same chroot successfully;
this
-# isolates one pytest session in one chroot per test target. More info here:
-#   http://pantsbuild.github.io/options_reference.html#group_testpytest
-fast: False
-
-
 # We have some modules that have side-effects upon import, including starting a repl, so
we can't
 # use python-eval to validate our BUILD deps currently.
 [compile.python-eval]

http://git-wip-us.apache.org/repos/asf/aurora/blob/b3de59cd/src/test/python/apache/thermos/observer/test_detector.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/thermos/observer/test_detector.py b/src/test/python/apache/thermos/observer/test_detector.py
deleted file mode 100644
index cacb49d..0000000
--- a/src/test/python/apache/thermos/observer/test_detector.py
+++ /dev/null
@@ -1,161 +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 random
-from contextlib import contextmanager
-
-import mock
-import pytest
-
-from apache.thermos.monitoring.detector import PathDetector
-from apache.thermos.observer.detector import ObserverTaskDetector
-
-
-class EmptyPathDetector(PathDetector):
-  def get_paths(self):
-    return []
-
-
-class PatchingObserverTaskDetector(ObserverTaskDetector):
-  def __init__(self, *args, **kw):
-    self.__tasks = []
-    super(PatchingObserverTaskDetector, self).__init__(EmptyPathDetector(), *args, **kw)
-
-  def iter_tasks(self):
-    return iter(self.__tasks)
-
-  @contextmanager
-  def patched_tasks(self, active_tasks=(), finished_tasks=(), shuffle=True):
-    old_tasks = self.__tasks
-
-    tasks = [(root, t_id, 'active') for (root, t_id) in active_tasks] + [
-             (root, t_id, 'finished') for (root, t_id) in finished_tasks]
-
-    if shuffle:
-      random.shuffle(tasks)
-
-    self.__tasks = tasks
-    yield
-    self.__tasks = old_tasks
-
-
-def test_observer_task_detector_construction():
-  pod = PatchingObserverTaskDetector()
-  pod.refresh()
-  assert pod.active_tasks == set()
-  assert pod.finished_tasks == set()
-
-
-# eight transitions:
-#    #1 (n/e) -> active
-#    #2 (n/e) -> finished
-#    #3 active -> active
-#    #4 active -> finished
-#    #5 active -> (n/e)
-#    #6 finished -> active (Fail)
-#    #7 finished -> finished
-#    #8 finished -> (n/e)
-def make_mocks():
-  on_active, on_finished, on_removed = mock.Mock(), mock.Mock(), mock.Mock()
-  pod = PatchingObserverTaskDetector(
-      on_active=on_active,
-      on_finished=on_finished,
-      on_removed=on_removed,
-  )
-  return pod, on_active, on_finished, on_removed
-
-
-TASK1 = ('root1', 'task1')
-TASK2 = ('root2', 'task2')
-
-
-def test_observer_task_detector_standard_transitions():
-  pod, on_active, on_finished, on_removed = make_mocks()
-
-  with pod.patched_tasks(active_tasks=(TASK1,)):  # 1
-    pod.refresh()
-    assert pod.active_tasks == set([TASK1])
-    assert pod.finished_tasks == set()
-    on_active.assert_called_once_with(*TASK1)
-    assert on_finished.call_count == 0
-    assert on_removed.call_count == 0
-    on_active.reset_mock()
-
-  with pod.patched_tasks(active_tasks=(TASK1,)):  # 3
-    pod.refresh()
-    assert pod.active_tasks == set([TASK1])
-    assert pod.finished_tasks == set()
-    assert on_active.call_count == 0
-    assert on_finished.call_count == 0
-    assert on_removed.call_count == 0
-
-  with pod.patched_tasks(finished_tasks=(TASK1,)):  # 4
-    pod.refresh()
-    assert pod.active_tasks == set()
-    assert pod.finished_tasks == set([TASK1])
-    on_finished.assert_called_once_with(*TASK1)
-    assert on_active.call_count == 0
-    assert on_removed.call_count == 0
-    on_finished.reset_mock()
-
-  with pod.patched_tasks(finished_tasks=(TASK1,)):  # 7
-    pod.refresh()
-    assert pod.active_tasks == set()
-    assert pod.finished_tasks == set([TASK1])
-    assert on_finished.call_count == 0
-    assert on_active.call_count == 0
-    assert on_removed.call_count == 0
-
-  with pod.patched_tasks():  # 8
-    pod.refresh()
-    assert pod.active_tasks == set()
-    assert pod.finished_tasks == set()
-    on_removed.assert_called_once_with(*TASK1)
-    assert on_active.call_count == 0
-    assert on_finished.call_count == 0
-    on_removed.reset_mock()
-
-
-def test_observer_task_detector_nonstandard_transitions():
-  pod, on_active, on_finished, on_removed = make_mocks()
-
-  with pod.patched_tasks(active_tasks=(TASK1,)):
-    pod.refresh()
-    assert pod.active_tasks == set([TASK1])
-    on_active.reset_mock()
-
-  with pod.patched_tasks():  # 5
-    pod.refresh()
-    assert pod.active_tasks == set()
-    assert pod.finished_tasks == set()
-    on_finished.assert_called_once_with(*TASK1)
-    on_removed.assert_called_once_with(*TASK1)
-    assert on_active.call_count == 0
-    on_removed.reset_mock()
-    on_finished.reset_mock()
-
-  with pod.patched_tasks(finished_tasks=(TASK2,)):  # 2
-    pod.refresh()
-    assert pod.active_tasks == set()
-    assert pod.finished_tasks == set([TASK2])
-    on_active.assert_called_once_with(*TASK2)
-    on_finished.assert_called_once_with(*TASK2)
-    assert on_removed.call_count == 0
-    on_active.reset_mock()
-    on_finished.reset_mock()
-
-  with pod.patched_tasks(active_tasks=(TASK2,)):  # 6
-    with pytest.raises(AssertionError):
-      pod.refresh()

http://git-wip-us.apache.org/repos/asf/aurora/blob/b3de59cd/src/test/python/apache/thermos/observer/test_observer_task_detector.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/thermos/observer/test_observer_task_detector.py b/src/test/python/apache/thermos/observer/test_observer_task_detector.py
new file mode 100644
index 0000000..cacb49d
--- /dev/null
+++ b/src/test/python/apache/thermos/observer/test_observer_task_detector.py
@@ -0,0 +1,161 @@
+#
+# 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 random
+from contextlib import contextmanager
+
+import mock
+import pytest
+
+from apache.thermos.monitoring.detector import PathDetector
+from apache.thermos.observer.detector import ObserverTaskDetector
+
+
+class EmptyPathDetector(PathDetector):
+  def get_paths(self):
+    return []
+
+
+class PatchingObserverTaskDetector(ObserverTaskDetector):
+  def __init__(self, *args, **kw):
+    self.__tasks = []
+    super(PatchingObserverTaskDetector, self).__init__(EmptyPathDetector(), *args, **kw)
+
+  def iter_tasks(self):
+    return iter(self.__tasks)
+
+  @contextmanager
+  def patched_tasks(self, active_tasks=(), finished_tasks=(), shuffle=True):
+    old_tasks = self.__tasks
+
+    tasks = [(root, t_id, 'active') for (root, t_id) in active_tasks] + [
+             (root, t_id, 'finished') for (root, t_id) in finished_tasks]
+
+    if shuffle:
+      random.shuffle(tasks)
+
+    self.__tasks = tasks
+    yield
+    self.__tasks = old_tasks
+
+
+def test_observer_task_detector_construction():
+  pod = PatchingObserverTaskDetector()
+  pod.refresh()
+  assert pod.active_tasks == set()
+  assert pod.finished_tasks == set()
+
+
+# eight transitions:
+#    #1 (n/e) -> active
+#    #2 (n/e) -> finished
+#    #3 active -> active
+#    #4 active -> finished
+#    #5 active -> (n/e)
+#    #6 finished -> active (Fail)
+#    #7 finished -> finished
+#    #8 finished -> (n/e)
+def make_mocks():
+  on_active, on_finished, on_removed = mock.Mock(), mock.Mock(), mock.Mock()
+  pod = PatchingObserverTaskDetector(
+      on_active=on_active,
+      on_finished=on_finished,
+      on_removed=on_removed,
+  )
+  return pod, on_active, on_finished, on_removed
+
+
+TASK1 = ('root1', 'task1')
+TASK2 = ('root2', 'task2')
+
+
+def test_observer_task_detector_standard_transitions():
+  pod, on_active, on_finished, on_removed = make_mocks()
+
+  with pod.patched_tasks(active_tasks=(TASK1,)):  # 1
+    pod.refresh()
+    assert pod.active_tasks == set([TASK1])
+    assert pod.finished_tasks == set()
+    on_active.assert_called_once_with(*TASK1)
+    assert on_finished.call_count == 0
+    assert on_removed.call_count == 0
+    on_active.reset_mock()
+
+  with pod.patched_tasks(active_tasks=(TASK1,)):  # 3
+    pod.refresh()
+    assert pod.active_tasks == set([TASK1])
+    assert pod.finished_tasks == set()
+    assert on_active.call_count == 0
+    assert on_finished.call_count == 0
+    assert on_removed.call_count == 0
+
+  with pod.patched_tasks(finished_tasks=(TASK1,)):  # 4
+    pod.refresh()
+    assert pod.active_tasks == set()
+    assert pod.finished_tasks == set([TASK1])
+    on_finished.assert_called_once_with(*TASK1)
+    assert on_active.call_count == 0
+    assert on_removed.call_count == 0
+    on_finished.reset_mock()
+
+  with pod.patched_tasks(finished_tasks=(TASK1,)):  # 7
+    pod.refresh()
+    assert pod.active_tasks == set()
+    assert pod.finished_tasks == set([TASK1])
+    assert on_finished.call_count == 0
+    assert on_active.call_count == 0
+    assert on_removed.call_count == 0
+
+  with pod.patched_tasks():  # 8
+    pod.refresh()
+    assert pod.active_tasks == set()
+    assert pod.finished_tasks == set()
+    on_removed.assert_called_once_with(*TASK1)
+    assert on_active.call_count == 0
+    assert on_finished.call_count == 0
+    on_removed.reset_mock()
+
+
+def test_observer_task_detector_nonstandard_transitions():
+  pod, on_active, on_finished, on_removed = make_mocks()
+
+  with pod.patched_tasks(active_tasks=(TASK1,)):
+    pod.refresh()
+    assert pod.active_tasks == set([TASK1])
+    on_active.reset_mock()
+
+  with pod.patched_tasks():  # 5
+    pod.refresh()
+    assert pod.active_tasks == set()
+    assert pod.finished_tasks == set()
+    on_finished.assert_called_once_with(*TASK1)
+    on_removed.assert_called_once_with(*TASK1)
+    assert on_active.call_count == 0
+    on_removed.reset_mock()
+    on_finished.reset_mock()
+
+  with pod.patched_tasks(finished_tasks=(TASK2,)):  # 2
+    pod.refresh()
+    assert pod.active_tasks == set()
+    assert pod.finished_tasks == set([TASK2])
+    on_active.assert_called_once_with(*TASK2)
+    on_finished.assert_called_once_with(*TASK2)
+    assert on_removed.call_count == 0
+    on_active.reset_mock()
+    on_finished.reset_mock()
+
+  with pod.patched_tasks(active_tasks=(TASK2,)):  # 6
+    with pytest.raises(AssertionError):
+      pod.refresh()


Mime
View raw message