aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jco...@apache.org
Subject aurora git commit: Only perform escalation wait when http teardown signal could be dispatched
Date Wed, 15 Apr 2015 19:01:48 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 669f27999 -> 10e75fc1e


Only perform escalation wait when http teardown signal could be dispatched

Testing Done:
./pants test.pytest --no-fast --options=-v src/test/python/apache/aurora/executor:thermos_task_runner

In addition, manual verification that shutdown of health-checked services without lifecycle
methods is 10 seconds faster.

Bugs closed: AURORA-1275

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


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

Branch: refs/heads/master
Commit: 10e75fc1e3649ddbcf3f810dbaba960ae35ee94a
Parents: 669f279
Author: Stephan Erb <stephan@dev.static-void.de>
Authored: Wed Apr 15 12:01:29 2015 -0700
Committer: Joshua Cohen <jcohen@apache.org>
Committed: Wed Apr 15 12:01:29 2015 -0700

----------------------------------------------------------------------
 .../aurora/executor/thermos_task_runner.py      | 17 ++++-----
 src/test/python/apache/aurora/executor/BUILD    |  1 +
 .../aurora/executor/test_thermos_task_runner.py | 37 ++++++++++++++++++--
 3 files changed, 41 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/10e75fc1/src/main/python/apache/aurora/executor/thermos_task_runner.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/executor/thermos_task_runner.py b/src/main/python/apache/aurora/executor/thermos_task_runner.py
index 505a1e6..8ce9168 100644
--- a/src/main/python/apache/aurora/executor/thermos_task_runner.py
+++ b/src/main/python/apache/aurora/executor/thermos_task_runner.py
@@ -119,17 +119,12 @@ class ThermosTaskRunner(TaskRunner):
 
     http_signaler = HttpSignaler(self._ports['health'])
 
-    # pass 1
-    http_signaler.quitquitquit()
-    self._clock.sleep(self.ESCALATION_WAIT.as_(Time.SECONDS))
-    if self.status is not None:
-      return True
-
-    # pass 2
-    http_signaler.abortabortabort()
-    self._clock.sleep(self.ESCALATION_WAIT.as_(Time.SECONDS))
-    if self.status is not None:
-      return True
+    for exit_request in [http_signaler.quitquitquit, http_signaler.abortabortabort]:
+      handled, _ = exit_request()
+      if handled:
+        self._clock.sleep(self.ESCALATION_WAIT.as_(Time.SECONDS))
+        if self.status is not None:
+          return
 
   @property
   def artifact_dir(self):

http://git-wip-us.apache.org/repos/asf/aurora/blob/10e75fc1/src/test/python/apache/aurora/executor/BUILD
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/executor/BUILD b/src/test/python/apache/aurora/executor/BUILD
index 013f056..f415ecc 100644
--- a/src/test/python/apache/aurora/executor/BUILD
+++ b/src/test/python/apache/aurora/executor/BUILD
@@ -83,6 +83,7 @@ python_tests(name = 'thermos_task_runner',
   sources = ['test_thermos_task_runner.py'],
   dependencies = [
     '3rdparty/python:mesos.interface',
+    '3rdparty/python:mock',
     '3rdparty/python:twitter.common.contextutil',
     '3rdparty/python:twitter.common.dirutil',
     '3rdparty/python:twitter.common.log',

http://git-wip-us.apache.org/repos/asf/aurora/blob/10e75fc1/src/test/python/apache/aurora/executor/test_thermos_task_runner.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/executor/test_thermos_task_runner.py b/src/test/python/apache/aurora/executor/test_thermos_task_runner.py
index a1005a8..1e21a11 100644
--- a/src/test/python/apache/aurora/executor/test_thermos_task_runner.py
+++ b/src/test/python/apache/aurora/executor/test_thermos_task_runner.py
@@ -23,6 +23,7 @@ import time
 
 import pytest
 from mesos.interface import mesos_pb2
+from mock import call, Mock, patch
 from twitter.common import log
 from twitter.common.contextutil import temporary_dir
 from twitter.common.dirutil import safe_rmtree
@@ -78,7 +79,7 @@ class TestThermosTaskRunnerIntegration(object):
       print('Saving executor logs in %s' % cls.LOG_DIR)
 
   @contextlib.contextmanager
-  def yield_runner(self, runner_class, **bindings):
+  def yield_runner(self, runner_class, portmap={}, clock=time, **bindings):
     with contextlib.nested(temporary_dir(), temporary_dir()) as (td1, td2):
       sandbox = DirectorySandbox(td1)
       checkpoint_root = td2
@@ -88,16 +89,19 @@ class TestThermosTaskRunnerIntegration(object):
           task_id='hello_world',
           task=TASK.bind(**bindings).task(),
           role=getpass.getuser(),
-          portmap={},
+          portmap=portmap,
+          clock=clock,
           sandbox=sandbox,
           checkpoint_root=checkpoint_root,
       )
 
       yield task_runner
 
-  def yield_sleepy(self, runner_class, sleep, exit_code):
+  def yield_sleepy(self, runner_class, sleep, exit_code, portmap={}, clock=time):
     return self.yield_runner(
         runner_class,
+        portmap=portmap,
+        clock=clock,
         command='sleep {{__sleep}} && exit {{__exit_code}}',
         __sleep=sleep,
         __exit_code=exit_code)
@@ -211,6 +215,33 @@ class TestThermosTaskRunnerIntegration(object):
       assert task_runner.status is not None
       assert task_runner.status.status == mesos_pb2.TASK_KILLED
 
+  @patch('apache.aurora.executor.thermos_task_runner.HttpSignaler')
+  def test_integration_http_teardown(self, SignalerClass):
+    signaler = SignalerClass.return_value
+    signaler.quitquitquit.return_value = (False, 'failed to dispatch')
+    signaler.abortabortabort.return_value = (True, None)
+
+    clock = Mock(wraps=time)
+
+    class ShortEscalationRunner(ThermosTaskRunner):
+      ESCALATION_WAIT = Amount(1, Time.MICROSECONDS)
+
+    with self.yield_sleepy(
+        ShortEscalationRunner,
+        portmap={'health': 3141},
+        clock=clock,
+        sleep=1000,
+        exit_code=0) as task_runner:
+
+      task_runner.start()
+      task_runner.forked.wait()
+
+      task_runner.stop()
+
+      escalation_wait = call(ShortEscalationRunner.ESCALATION_WAIT.as_(Time.SECONDS))
+      assert clock.sleep.mock_calls.count(escalation_wait) == 1
+      assert signaler.mock_calls == [call.quitquitquit(), call.abortabortabort()]
+
   def test_thermos_normal_exit_status(self):
     with self.exit_with_status(0, TaskState.SUCCESS) as task_runner:
       assert task_runner._popen_signal == 0


Mime
View raw message