aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject git commit: Add test coverage for new client API methods.
Date Mon, 04 Aug 2014 18:41:16 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master d224ae4ad -> 7f94b7323


Add test coverage for new client API methods.

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


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

Branch: refs/heads/master
Commit: 7f94b7323aeec929200815df65300538a4325740
Parents: d224ae4
Author: Bill Farner <wfarner@apache.org>
Authored: Mon Aug 4 11:34:10 2014 -0700
Committer: Bill Farner <wfarner@apache.org>
Committed: Mon Aug 4 11:34:10 2014 -0700

----------------------------------------------------------------------
 .../aurora/client/api/scheduler_client.py       | 15 +++-----
 .../thrift/org/apache/aurora/gen/api.thrift     |  2 +-
 .../aurora/client/api/test_scheduler_client.py  | 36 ++++++++++++++++++--
 3 files changed, 40 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/7f94b732/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 4b20efa..02222ba 100644
--- a/src/main/python/apache/aurora/client/api/scheduler_client.py
+++ b/src/main/python/apache/aurora/client/api/scheduler_client.py
@@ -29,7 +29,7 @@ from apache.aurora.common.auth import make_session_key, SessionKeyError
 from apache.aurora.common.cluster import Cluster
 from apache.aurora.common.transport import TRequestsTransport
 
-from gen.apache.aurora.api import AuroraAdmin
+from gen.apache.aurora.api import AuroraAdmin, ReadOnlyScheduler
 from gen.apache.aurora.api.constants import CURRENT_API_VERSION
 
 try:
@@ -181,14 +181,6 @@ class SchedulerProxy(object):
   CONNECT_MAXIMUM_WAIT = Amount(1, Time.MINUTES)
   RPC_RETRY_INTERVAL = Amount(5, Time.SECONDS)
   RPC_MAXIMUM_WAIT = Amount(10, Time.MINUTES)
-  UNAUTHENTICATED_RPCS = frozenset([
-    'populateJobConfig',
-    'getTasksStatus',
-    'getTasksWithoutConfigs',
-    'getJobs',
-    'getQuota',
-    'getVersion',
-  ])
 
   class Error(Exception): pass
   class TimeoutError(Error): pass
@@ -277,10 +269,13 @@ class SchedulerProxy(object):
     def method_wrapper(*args):
       with self._lock:
         start = time.time()
+        # TODO(wfarner): The while loop causes failed unit tests to spin for the retry
+        # period (currently 10 minutes).  Figure out a better approach.
         while not self._terminating.is_set() and (
             time.time() - start) < self.RPC_MAXIMUM_WAIT.as_(Time.SECONDS):
 
-          auth_args = () if method_name in self.UNAUTHENTICATED_RPCS else (self.session_key(),)
+          # Only automatically append a SessionKey if this is not part of the read-only API.
+          auth_args = () if hasattr(ReadOnlyScheduler.Iface, method_name) else (self.session_key(),)
           try:
             method = getattr(self.client(), method_name)
             if not callable(method):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/7f94b732/src/main/thrift/org/apache/aurora/gen/api.thrift
----------------------------------------------------------------------
diff --git a/src/main/thrift/org/apache/aurora/gen/api.thrift b/src/main/thrift/org/apache/aurora/gen/api.thrift
index 5c8ee52..595c8df 100644
--- a/src/main/thrift/org/apache/aurora/gen/api.thrift
+++ b/src/main/thrift/org/apache/aurora/gen/api.thrift
@@ -843,7 +843,7 @@ service ReadOnlyScheduler {
   Response populateJobConfig(1: JobConfiguration description)
 
   /** Returns all stored context specific resource/operation locks. */
-  Response getLocks()
+    Response getLocks()
 
   /** Gets job updates. Not implemented yet. */
   Response getUpdates(1: UpdateQuery updateQuery)

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/7f94b732/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 dd16fe2..e1f1a95 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
@@ -44,7 +44,9 @@ from gen.apache.aurora.api.ttypes import (
     RewriteConfigsRequest,
     ScheduleStatus,
     SessionKey,
-    TaskQuery
+    TaskQuery,
+    UpdateRequest,
+    UpdateQuery
 )
 
 ROLE = 'foorole'
@@ -201,7 +203,7 @@ class TestSchedulerProxyAdminInjection(TestSchedulerProxyInjection):
     self.make_scheduler_proxy().setQuota(ROLE, ResourceAggregate())
 
   def test_forceTaskState(self):
-    self.mock_thrift_client.forceTaskState(IgnoreArg(), IgnoreArg(), IsA(SessionKey))
+    self.mock_thrift_client.forceTaskState('taskid', IgnoreArg(), IsA(SessionKey))
     self.mox.ReplayAll()
     self.make_scheduler_proxy().forceTaskState('taskid', ScheduleStatus.LOST)
 
@@ -250,6 +252,36 @@ class TestSchedulerProxyAdminInjection(TestSchedulerProxyInjection):
     self.mox.ReplayAll()
     self.make_scheduler_proxy().rewriteConfigs(RewriteConfigsRequest())
 
+  def test_getUpdates(self):
+    self.mock_thrift_client.getUpdates(IsA(UpdateQuery))
+    self.mox.ReplayAll()
+    self.make_scheduler_proxy().getUpdates(UpdateQuery())
+
+  def test_getUpdateDetails(self):
+    self.mock_thrift_client.getUpdateDetails('update_id')
+    self.mox.ReplayAll()
+    self.make_scheduler_proxy().getUpdateDetails('update_id')
+
+  def test_startUpdate(self):
+    self.mock_thrift_client.startUpdate(IsA(UpdateRequest), IsA(Lock), IsA(SessionKey))
+    self.mox.ReplayAll()
+    self.make_scheduler_proxy().startUpdate(UpdateRequest(), Lock())
+
+  def test_pauseUpdate(self):
+    self.mock_thrift_client.pauseUpdate('update_id', IsA(Lock), IsA(SessionKey))
+    self.mox.ReplayAll()
+    self.make_scheduler_proxy().pauseUpdate('update_id', Lock())
+
+  def test_resumeUpdate(self):
+    self.mock_thrift_client.resumeUpdate('update_id', IsA(Lock), IsA(SessionKey))
+    self.mox.ReplayAll()
+    self.make_scheduler_proxy().resumeUpdate('update_id', Lock())
+
+  def test_abortUpdate(self):
+    self.mock_thrift_client.abortUpdate('update_id', IsA(Lock), IsA(SessionKey))
+    self.mox.ReplayAll()
+    self.make_scheduler_proxy().abortUpdate('update_id', Lock())
+
 
 @pytest.mark.parametrize('scheme', ('http', 'https'))
 def test_url_when_not_connected_and_cluster_has_no_proxy_url(scheme):


Mime
View raw message