aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject aurora git commit: Retry scheduler connection after unknown failures.
Date Mon, 02 Nov 2015 18:54:10 GMT
Repository: aurora
Updated Branches:
  refs/heads/master b712d5773 -> 3ecce6dc3


Retry scheduler connection after unknown failures.

Bugs closed: AURORA-1533

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


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

Branch: refs/heads/master
Commit: 3ecce6dc3cff9c51f2dfbad8b6bf8bf6633fd71a
Parents: b712d57
Author: Stephan Erb <stephan@dev.static-void.de>
Authored: Mon Nov 2 10:54:04 2015 -0800
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Mon Nov 2 10:54:04 2015 -0800

----------------------------------------------------------------------
 .../apache/aurora/client/api/scheduler_client.py   |  2 +-
 .../aurora/client/api/test_scheduler_client.py     | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/3ecce6dc/src/main/python/apache/aurora/client/api/scheduler_client.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/scheduler_client.py b/src/main/python/apache/aurora/client/api/scheduler_client.py
index 8ff21bf..a469eec 100644
--- a/src/main/python/apache/aurora/client/api/scheduler_client.py
+++ b/src/main/python/apache/aurora/client/api/scheduler_client.py
@@ -227,7 +227,7 @@ class SchedulerProxy(object):
   def with_scheduler(method):
     """Decorator magic to make sure a connection is made to the scheduler"""
     def _wrapper(self, *args, **kwargs):
-      if not self._scheduler_client:
+      if not self._client:
         self._construct_scheduler()
       return method(self, *args, **kwargs)
     return _wrapper

http://git-wip-us.apache.org/repos/asf/aurora/blob/3ecce6dc/src/test/python/apache/aurora/client/api/test_scheduler_client.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_scheduler_client.py b/src/test/python/apache/aurora/client/api/test_scheduler_client.py
index 1b4ff9c..5a17ab6 100644
--- a/src/test/python/apache/aurora/client/api/test_scheduler_client.py
+++ b/src/test/python/apache/aurora/client/api/test_scheduler_client.py
@@ -438,6 +438,23 @@ def test_transient_error(_, client):
   assert mock_thrift_client.killTasks.call_count == 3
 
 
+@mock.patch('apache.aurora.client.api.scheduler_client.SchedulerClient',
+            spec=scheduler_client.SchedulerClient)
+def test_unknown_connection_error(client):
+  mock_scheduler_client = mock.create_autospec(spec=scheduler_client.SchedulerClient, instance=True)
+  client.get.return_value = mock_scheduler_client
+  proxy = TestSchedulerProxy(Cluster(name='local'))
+
+  # unknown, transient connection error
+  mock_scheduler_client.get_thrift_client.side_effect = RuntimeError
+  with pytest.raises(Exception):
+    proxy.client()
+
+  # successful connection on re-attempt
+  mock_scheduler_client.get_thrift_client.side_effect = None
+  assert proxy.client() is not None
+
+
 @mock.patch('apache.aurora.client.api.scheduler_client.TRequestsTransport', spec=TRequestsTransport)
 def test_connect_direct_scheduler_with_user_agent(mock_transport):
   mock_transport.return_value.open.side_effect = [TTransport.TTransportException, True]


Mime
View raw message