You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wi...@apache.org on 2015/02/17 23:59:11 UTC
incubator-aurora git commit: Update aurora to commons 0.3.3,
unflake tests using ThreadedClock
Repository: incubator-aurora
Updated Branches:
refs/heads/master 219c3adcd -> 131060f32
Update aurora to commons 0.3.3, unflake tests using ThreadedClock
Testing Done:
./pants test.pytest --no-fast src/test/python::
Reviewed at https://reviews.apache.org/r/31137/
Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/131060f3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/131060f3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/131060f3
Branch: refs/heads/master
Commit: 131060f324dc0a608be15c0a877680ae7d8df9ff
Parents: 219c3ad
Author: Brian Wickman <wi...@apache.org>
Authored: Tue Feb 17 14:59:06 2015 -0800
Committer: Brian Wickman <wi...@apache.org>
Committed: Tue Feb 17 14:59:06 2015 -0800
----------------------------------------------------------------------
3rdparty/python/requirements.txt | 38 ++++++++++----------
.../apache/aurora/executor/gc_executor.py | 3 ++
.../executor/common/test_health_checker.py | 34 +++++++++++-------
.../apache/aurora/executor/test_gc_executor.py | 26 +++-----------
4 files changed, 48 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/131060f3/3rdparty/python/requirements.txt
----------------------------------------------------------------------
diff --git a/3rdparty/python/requirements.txt b/3rdparty/python/requirements.txt
index 9f7bea9..ee30136 100644
--- a/3rdparty/python/requirements.txt
+++ b/3rdparty/python/requirements.txt
@@ -12,23 +12,23 @@ pystachio==0.7.4
pyyaml==3.10
requests==2.3.0
thrift==0.9.1
-twitter.common.app==0.3.2
-twitter.common.collections==0.3.2
-twitter.common.concurrent==0.3.2
-twitter.common.contextutil==0.3.2
-twitter.common.decorators==0.3.2
-twitter.common.dirutil==0.3.2
-twitter.common.exceptions==0.3.2
-twitter.common.http==0.3.2
-twitter.common.lang==0.3.2
-twitter.common.log==0.3.2
-twitter.common.metrics==0.3.2
-twitter.common.options==0.3.2
-twitter.common.process==0.3.2
-twitter.common.quantity==0.3.2
-twitter.common.recordio==0.3.2
-twitter.common.rpc==0.3.2
-twitter.common.string==0.3.2
-twitter.common.testing==0.3.2
-twitter.common.zookeeper==0.3.2
+twitter.common.app==0.3.3
+twitter.common.collections==0.3.3
+twitter.common.concurrent==0.3.3
+twitter.common.contextutil==0.3.3
+twitter.common.decorators==0.3.3
+twitter.common.dirutil==0.3.3
+twitter.common.exceptions==0.3.3
+twitter.common.http==0.3.3
+twitter.common.lang==0.3.3
+twitter.common.log==0.3.3
+twitter.common.metrics==0.3.3
+twitter.common.options==0.3.3
+twitter.common.process==0.3.3
+twitter.common.quantity==0.3.3
+twitter.common.recordio==0.3.3
+twitter.common.rpc==0.3.3
+twitter.common.string==0.3.3
+twitter.common.testing==0.3.3
+twitter.common.zookeeper==0.3.3
watchdog==0.7.0
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/131060f3/src/main/python/apache/aurora/executor/gc_executor.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/executor/gc_executor.py b/src/main/python/apache/aurora/executor/gc_executor.py
index 43b415b..dbec82f 100644
--- a/src/main/python/apache/aurora/executor/gc_executor.py
+++ b/src/main/python/apache/aurora/executor/gc_executor.py
@@ -461,6 +461,7 @@ class ThermosGCExecutor(ExecutorBase, ExceptionalThread, Observable):
pass
if self._driver is not None:
self.clean_orphans(self._driver)
+ # TODO(wickman) This should be polling with self._clock
self._stop_event.wait(self.POLL_WAIT.as_(Time.SECONDS))
# shutdown
@@ -474,7 +475,9 @@ class ThermosGCExecutor(ExecutorBase, ExceptionalThread, Observable):
'Garbage collection skipped - GC executor shutting down')
# TODO(jon) Remove this once external MESOS-243 is resolved.
self.log('Sleeping briefly to mitigate https://issues.apache.org/jira/browse/MESOS-243')
+ self.log('Clock is %r, time is %s' % (self._clock, self._clock.time()))
self._clock.sleep(self.PERSISTENCE_WAIT.as_(Time.SECONDS))
+ self.log('Finished sleeping.')
self._driver.stop()
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/131060f3/src/test/python/apache/aurora/executor/common/test_health_checker.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/executor/common/test_health_checker.py b/src/test/python/apache/aurora/executor/common/test_health_checker.py
index def249c..a4e215d 100644
--- a/src/test/python/apache/aurora/executor/common/test_health_checker.py
+++ b/src/test/python/apache/aurora/executor/common/test_health_checker.py
@@ -36,13 +36,9 @@ from .fixtures import HELLO_WORLD, MESOS_JOB
from gen.apache.aurora.api.ttypes import AssignedTask, ExecutorConfig, TaskConfig
-def thread_yield():
- time.sleep(0.1)
-
-
class TestHealthChecker(unittest.TestCase):
def setUp(self):
- self._clock = ThreadedClock()
+ self._clock = ThreadedClock(0)
self._checker = mock.Mock(spec=HttpSignaler)
self.fake_health_checks = []
@@ -59,14 +55,17 @@ class TestHealthChecker(unittest.TestCase):
self.append_health_checks(False)
hct = HealthChecker(self._checker.health, interval_secs=5, clock=self._clock)
hct.start()
- thread_yield()
+ assert self._clock.converge(threads=[hct.threaded_health_checker], timeout=1)
+ self._clock.assert_waiting(hct.threaded_health_checker, 10)
assert hct.status is None
self._clock.tick(6)
+ assert self._clock.converge(threads=[hct.threaded_health_checker], timeout=1)
assert hct.status is None
self._clock.tick(3)
+ assert self._clock.converge(threads=[hct.threaded_health_checker], timeout=1)
assert hct.status is None
self._clock.tick(5)
- thread_yield()
+ assert self._clock.converge(threads=[hct.threaded_health_checker], timeout=1)
assert hct.status.status == TaskState.Value('TASK_FAILED')
hct.stop()
assert self._checker.health.call_count == 1
@@ -74,14 +73,18 @@ class TestHealthChecker(unittest.TestCase):
def test_initial_interval_whatev(self):
self.append_health_checks(False)
hct = HealthChecker(
- self._checker.health,
- interval_secs=5,
- initial_interval_secs=0,
- clock=self._clock)
+ self._checker.health,
+ interval_secs=5,
+ initial_interval_secs=0,
+ clock=self._clock)
hct.start()
+ assert self._clock.converge(threads=[hct.threaded_health_checker], timeout=1)
assert hct.status.status == TaskState.Value('TASK_FAILED')
hct.stop()
- assert self._checker.health.call_count == 1
+ # this is an implementation detail -- we healthcheck in the initializer and
+ # healthcheck in the run loop. if we ever change the implementation, expect
+ # this to break.
+ assert self._checker.health.call_count == 2
def test_consecutive_failures(self):
'''Verify that a task is unhealthy only after max_consecutive_failures is exceeded'''
@@ -100,19 +103,24 @@ class TestHealthChecker(unittest.TestCase):
# 2 consecutive health check failures followed by a successful health check.
self._clock.tick(initial_interval_secs)
+ assert self._clock.converge(threads=[hct.threaded_health_checker], timeout=1)
assert hct.status is None
self._clock.tick(interval_secs)
+ assert self._clock.converge(threads=[hct.threaded_health_checker], timeout=1)
assert hct.status is None
self._clock.tick(interval_secs)
+ assert self._clock.converge(threads=[hct.threaded_health_checker], timeout=1)
assert hct.status is None
# 3 consecutive health check failures.
self._clock.tick(interval_secs)
+ assert self._clock.converge(threads=[hct.threaded_health_checker], timeout=1)
assert hct.status is None
self._clock.tick(interval_secs)
+ assert self._clock.converge(threads=[hct.threaded_health_checker], timeout=1)
assert hct.status is None
self._clock.tick(interval_secs)
- thread_yield()
+ assert self._clock.converge(threads=[hct.threaded_health_checker], timeout=1)
assert hct.status.status == TaskState.Value('TASK_FAILED')
hct.stop()
assert self._checker.health.call_count == 6
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/131060f3/src/test/python/apache/aurora/executor/test_gc_executor.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/executor/test_gc_executor.py b/src/test/python/apache/aurora/executor/test_gc_executor.py
index b1bbc89..27dee7f 100644
--- a/src/test/python/apache/aurora/executor/test_gc_executor.py
+++ b/src/test/python/apache/aurora/executor/test_gc_executor.py
@@ -25,6 +25,7 @@ from itertools import product
import mock
from mesos.interface import mesos_pb2
from thrift.TSerialization import serialize as thrift_serialize
+from twitter.common import log
from twitter.common.concurrent import deadline, Timeout
from twitter.common.contextutil import temporary_dir
from twitter.common.dirutil import safe_rmtree
@@ -62,7 +63,6 @@ TASK_ID = 'gc_executor_task_id'
if 'THERMOS_DEBUG' in os.environ:
- from twitter.common import log
from twitter.common.log.options import LogOptions
LogOptions.set_disk_log_level('NONE')
LogOptions.set_stderr_log_level('DEBUG')
@@ -101,9 +101,11 @@ class ProxyDriver(object):
self.updates = []
def stop(self):
+ log.debug('ProxyDriver.stop')
self.stopped.set()
def sendStatusUpdate(self, update): # noqa
+ log.debug('ProxyDriver.sendStatusUpdate %r' % update)
self.updates.append(StatusUpdate(update.state, update.task_id.value))
@@ -383,6 +385,8 @@ def build_blocking_gc_executor(td, proxy_driver):
class LongGCThinTestThermosGCExecutor(ThinTestThermosGCExecutor):
def _run_gc(self, task, retain_tasks, retain_start):
# just block until we shutdown
+ log.debug('%r : _run_gc called (%r, %r, %r)' % (
+ self, task, retain_tasks, retain_start))
self._start_time = retain_start
self._task_id = task.task_id.value
self._stop_event.wait()
@@ -469,26 +473,6 @@ def test_gc_shutdown():
assert len(proxy_driver.updates) == 0
-def test_gc_shutdown_queued():
- TASK2_ID = "task2"
- proxy_driver = ProxyDriver()
- with temporary_dir() as td:
- executor = build_blocking_gc_executor(td, proxy_driver)
- executor.launchTask(proxy_driver, serialize_art(AdjustRetainedTasks()))
- thread_yield()
- executor.launchTask(proxy_driver, serialize_art(AdjustRetainedTasks(), task_id=TASK2_ID))
- thread_yield()
- assert len(executor._gc_task_queue) == 1
- executor.shutdown(proxy_driver)
- executor._clock.tick(executor.PERSISTENCE_WAIT.as_(Time.SECONDS))
- assert executor._stop_event.is_set()
- proxy_driver.stopped.wait(timeout=1.0)
- assert proxy_driver.stopped.is_set()
- assert len(proxy_driver.updates) == 1
- assert proxy_driver.updates[-1][0] == mesos_pb2.TASK_FINISHED
- assert proxy_driver.updates[-1][1] == TASK2_ID
-
-
def test_ignores_launch_task_when_shutting_down():
"""Newly launched tasks should be rejected if shutdown was already called."""
TASK_ID = "task"