aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject git commit: Remove use of the getVersion RPC from the client.
Date Thu, 16 Oct 2014 00:31:02 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 253cb7370 -> 797b8152b


Remove use of the getVersion RPC from the client.

Bugs closed: AURORA-142

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


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

Branch: refs/heads/master
Commit: 797b8152b5341dcdba1bb81046e4d7f489a6cd81
Parents: 253cb73
Author: Bill Farner <wfarner@apache.org>
Authored: Wed Oct 15 17:24:02 2014 -0700
Committer: Bill Farner <wfarner@apache.org>
Committed: Wed Oct 15 17:24:02 2014 -0700

----------------------------------------------------------------------
 .../aurora/client/api/scheduler_client.py       |  12 +-
 .../apache/aurora/client/api/test_restarter.py  |  21 +-
 .../aurora/client/api/test_scheduler_client.py  | 224 +++++++++++--------
 .../apache/aurora/client/api/test_updater.py    |  42 +++-
 .../aurora/client/cli/test_api_from_cli.py      |   5 -
 .../aurora/client/fake_scheduler_proxy.py       |   2 +-
 6 files changed, 184 insertions(+), 122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/797b8152/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 7f1c82b..696dc3b 100644
--- a/src/main/python/apache/aurora/client/api/scheduler_client.py
+++ b/src/main/python/apache/aurora/client/api/scheduler_client.py
@@ -30,7 +30,7 @@ from apache.aurora.common.cluster import Cluster
 from apache.aurora.common.transport import TRequestsTransport
 
 from gen.apache.aurora.api import AuroraAdmin, ReadOnlyScheduler
-from gen.apache.aurora.api.constants import CURRENT_API_VERSION
+from gen.apache.aurora.api.constants import THRIFT_API_VERSION
 from gen.apache.aurora.api.ttypes import ResponseCode
 
 try:
@@ -264,11 +264,6 @@ class SchedulerProxy(object):
     if not self._client:
       raise self.TimeoutError('Timed out trying to connect to scheduler at %s' % self.cluster.name)
 
-    server_version = self._client.getVersion().result.getVersionResult
-    if server_version != CURRENT_API_VERSION:
-      raise self.APIVersionError("Client Version: %s, Server Version: %s" %
-                                 (CURRENT_API_VERSION, server_version))
-
   def __getattr__(self, method_name):
     # If the method does not exist, getattr will return AttributeError for us.
     method = getattr(AuroraAdmin.Client, method_name)
@@ -279,8 +274,6 @@ 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):
 
@@ -295,6 +288,9 @@ class SchedulerProxy(object):
             if resp is not None and resp.responseCode == ResponseCode.ERROR_TRANSIENT:
               raise self.TransientError(", ".join(
                   [m for m in resp.details] if resp.details else []))
+            if resp.serverInfo.thriftAPIVersion != THRIFT_API_VERSION:
+              raise self.APIVersionError("Client Version: %s, Server Version: %s" %
+                  (THRIFT_API_VERSION, resp.serverInfo.thriftAPIVersion))
             return resp
           except (TTransport.TTransportException, self.TimeoutError, self.TransientError)
as e:
             if not self._terminating.is_set():

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/797b8152/src/test/python/apache/aurora/client/api/test_restarter.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_restarter.py b/src/test/python/apache/aurora/client/api/test_restarter.py
index f1bf545..2b264de 100644
--- a/src/test/python/apache/aurora/client/api/test_restarter.py
+++ b/src/test/python/apache/aurora/client/api/test_restarter.py
@@ -19,8 +19,10 @@ from apache.aurora.client.api.restarter import Restarter
 from apache.aurora.client.api.updater_util import UpdaterConfig
 from apache.aurora.client.fake_scheduler_proxy import FakeSchedulerProxy
 from apache.aurora.common.aurora_job_key import AuroraJobKey
+from apache.aurora.common.cluster import Cluster
 
 from gen.apache.aurora.api.AuroraSchedulerManager import Client as scheduler_client
+from gen.apache.aurora.api.constants import THRIFT_API_VERSION
 from gen.apache.aurora.api.ttypes import (
     AssignedTask,
     Response,
@@ -29,11 +31,12 @@ from gen.apache.aurora.api.ttypes import (
     ScheduledTask,
     ScheduleStatus,
     ScheduleStatusResult,
+    ServerInfo,
     TaskConfig
 )
 
 SESSION_KEY = 'test_session'
-CLUSTER = 'smfd'
+CLUSTER = 'east'
 JOB = AuroraJobKey(CLUSTER, 'johndoe', 'test', 'test_job')
 HEALTH_CHECK_INTERVAL_SECONDS = 5
 UPDATER_CONFIG = UpdaterConfig(
@@ -56,11 +59,18 @@ class TestRestarter(MoxTestBase):
     self.lock = None
 
     self.restarter = Restarter(
-        JOB, UPDATER_CONFIG, HEALTH_CHECK_INTERVAL_SECONDS,
-        FakeSchedulerProxy(CLUSTER, self.mock_scheduler, SESSION_KEY), self.mock_instance_watcher)
+        JOB,
+        UPDATER_CONFIG,
+        HEALTH_CHECK_INTERVAL_SECONDS,
+        FakeSchedulerProxy(
+            Cluster(name=CLUSTER),
+            self.mock_scheduler,
+            SESSION_KEY),
+        self.mock_instance_watcher)
 
   def mock_restart_instances(self, instances, lock=None):
     response = Response(responseCode=ResponseCode.OK, messageDEPRECATED='test')
+    response.serverInfo = ServerInfo(thriftAPIVersion=THRIFT_API_VERSION)
 
     self.mock_scheduler.restartShards(
         JOB.to_thrift(),
@@ -98,6 +108,7 @@ class TestRestarter(MoxTestBase):
           assignedTask=AssignedTask(task=TaskConfig(), instanceId=i)
       ))
     response = Response(responseCode=ResponseCode.OK, messageDEPRECATED='test')
+    response.serverInfo = ServerInfo(thriftAPIVersion=THRIFT_API_VERSION)
     response.result = Result()
     response.result.scheduleStatusResult = ScheduleStatusResult(tasks=tasks)
 
@@ -113,6 +124,7 @@ class TestRestarter(MoxTestBase):
 
   def mock_status_no_active_task(self):
     response = Response(responseCode=ResponseCode.INVALID_REQUEST, messageDEPRECATED='test')
+    response.serverInfo = ServerInfo(thriftAPIVersion=THRIFT_API_VERSION)
     self.mock_scheduler.getTasksWithoutConfigs(IgnoreArg()).AndReturn(response)
 
   def test_restart_no_instance_active(self):
@@ -124,7 +136,7 @@ class TestRestarter(MoxTestBase):
 
   def mock_restart_fails(self):
     response = Response(responseCode=ResponseCode.ERROR, messageDEPRECATED='test error')
-
+    response.serverInfo = ServerInfo(thriftAPIVersion=THRIFT_API_VERSION)
     self.mock_scheduler.restartShards(
         JOB.to_thrift(),
         IgnoreArg(),
@@ -141,6 +153,7 @@ class TestRestarter(MoxTestBase):
 
   def mock_restart_watch_fails(self, instances):
     response = Response(responseCode=ResponseCode.OK, messageDEPRECATED='test')
+    response.serverInfo = ServerInfo(thriftAPIVersion=THRIFT_API_VERSION)
 
     self.mock_scheduler.restartShards(
         JOB.to_thrift(),

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/797b8152/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 d78e7dc..e97bb2a 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
@@ -30,7 +30,7 @@ from apache.aurora.common.transport import TRequestsTransport
 
 import gen.apache.aurora.api.AuroraAdmin as AuroraAdmin
 import gen.apache.aurora.api.AuroraSchedulerManager as AuroraSchedulerManager
-from gen.apache.aurora.api.constants import CURRENT_API_VERSION, DEFAULT_ENVIRONMENT
+from gen.apache.aurora.api.constants import DEFAULT_ENVIRONMENT, THRIFT_API_VERSION
 from gen.apache.aurora.api.ttypes import (
     Hosts,
     JobConfiguration,
@@ -42,9 +42,9 @@ from gen.apache.aurora.api.ttypes import (
     ResourceAggregate,
     Response,
     ResponseCode,
-    Result,
     RewriteConfigsRequest,
     ScheduleStatus,
+    ServerInfo,
     SessionKey,
     TaskQuery
 )
@@ -52,6 +52,7 @@ from gen.apache.aurora.api.ttypes import (
 ROLE = 'foorole'
 JOB_NAME = 'barjobname'
 JOB_KEY = JobKey(role=ROLE, environment=DEFAULT_ENVIRONMENT, name=JOB_NAME)
+DEFAULT_RESPONSE = Response(serverInfo=ServerInfo(thriftAPIVersion=THRIFT_API_VERSION))
 
 
 def test_coverage():
@@ -88,11 +89,6 @@ class TestSchedulerProxyInjection(unittest.TestCase):
         self.mock_scheduler_client)
     self.mock_scheduler_client.get_thrift_client().AndReturn(self.mock_thrift_client)
 
-    version_resp = Response(responseCode=ResponseCode.OK)
-    version_resp.result = Result(getVersionResult=CURRENT_API_VERSION)
-
-    self.mock_thrift_client.getVersion().AndReturn(version_resp)
-
   def tearDown(self):
     self.mox.UnsetStubs()
     self.mox.VerifyAll()
@@ -101,187 +97,230 @@ class TestSchedulerProxyInjection(unittest.TestCase):
     return TestSchedulerProxy(Cluster(name='local'))
 
   def test_startCronJob(self):
-    self.mock_thrift_client.startCronJob(IsA(JobKey), IsA(SessionKey))
+    self.mock_thrift_client.startCronJob(IsA(JobKey), IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().startCronJob(JOB_KEY)
 
   def test_createJob(self):
-    self.mock_thrift_client.createJob(IsA(JobConfiguration), IsA(SessionKey))
+    self.mock_thrift_client.createJob(
+        IsA(JobConfiguration),
+        IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().createJob(JobConfiguration())
 
   def test_replaceCronTemplate(self):
-    self.mock_thrift_client.replaceCronTemplate(IsA(JobConfiguration), IsA(Lock), IsA(SessionKey))
+    self.mock_thrift_client.replaceCronTemplate(
+        IsA(JobConfiguration),
+        IsA(Lock),
+        IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().replaceCronTemplate(JobConfiguration(), Lock())
 
   def test_scheduleCronJob(self):
-    self.mock_thrift_client.scheduleCronJob(IsA(JobConfiguration), IsA(SessionKey))
+    self.mock_thrift_client.scheduleCronJob(
+        IsA(JobConfiguration),
+        IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().scheduleCronJob(JobConfiguration())
 
   def test_descheduleCronJob(self):
-    self.mock_thrift_client.descheduleCronJob(IsA(JobKey), IsA(SessionKey))
+    self.mock_thrift_client.descheduleCronJob(
+        IsA(JobKey),
+        IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().descheduleCronJob(JOB_KEY)
 
   def test_populateJobConfig(self):
-    self.mock_thrift_client.populateJobConfig(IsA(JobConfiguration))
+    self.mock_thrift_client.populateJobConfig(IsA(JobConfiguration)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().populateJobConfig(JobConfiguration())
 
   def test_restartShards(self):
-    self.mock_thrift_client.restartShards(IsA(JobKey), IgnoreArg(), IsA(SessionKey))
+    self.mock_thrift_client.restartShards(
+        IsA(JobKey),
+        IgnoreArg(),
+        IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().restartShards(JOB_KEY, set([0]))
 
   def test_getTasksStatus(self):
-    self.mock_thrift_client.getTasksStatus(IsA(TaskQuery))
+    self.mock_thrift_client.getTasksStatus(IsA(TaskQuery)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().getTasksStatus(TaskQuery())
 
   def test_getJobs(self):
-    self.mock_thrift_client.getJobs(IgnoreArg())
+    self.mock_thrift_client.getJobs(IgnoreArg()).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().getJobs(ROLE)
 
   def test_killTasks(self):
-    self.mock_thrift_client.killTasks(IsA(TaskQuery), IsA(SessionKey))
+    self.mock_thrift_client.killTasks(IsA(TaskQuery), IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().killTasks(TaskQuery())
 
   def test_getQuota(self):
-    self.mock_thrift_client.getQuota(IgnoreArg())
+    self.mock_thrift_client.getQuota(IgnoreArg()).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().getQuota(ROLE)
 
-  def test_startMaintenance(self):
-    self.mock_thrift_client.startMaintenance(IsA(Hosts), IsA(SessionKey))
+  def test_api_version_mismatch(self):
+    resp = Response(serverInfo=ServerInfo(thriftAPIVersion=THRIFT_API_VERSION + 1))
+    self.mock_thrift_client.getQuota(IgnoreArg()).AndReturn(resp)
     self.mox.ReplayAll()
-    self.make_scheduler_proxy().startMaintenance(Hosts())
+    with pytest.raises(scheduler_client.SchedulerProxy.ThriftInternalError):
+      self.make_scheduler_proxy().getQuota(ROLE)
 
-  def test_drainHosts(self):
-    self.mock_thrift_client.drainHosts(IsA(Hosts), IsA(SessionKey))
+  def test_addInstances(self):
+    self.mock_thrift_client.addInstances(
+      IsA(JobKey),
+      IgnoreArg(),
+      IsA(Lock),
+      IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
-    self.make_scheduler_proxy().drainHosts(Hosts())
+    self.make_scheduler_proxy().addInstances(JobKey(), {}, Lock())
 
-  def test_maintenanceStatus(self):
-    self.mock_thrift_client.maintenanceStatus(IsA(Hosts), IsA(SessionKey))
+  def test_acquireLock(self):
+    self.mock_thrift_client.acquireLock(IsA(Lock), IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
-    self.make_scheduler_proxy().maintenanceStatus(Hosts())
+    self.make_scheduler_proxy().acquireLock(Lock())
 
-  def test_endMaintenance(self):
-    self.mock_thrift_client.endMaintenance(IsA(Hosts), IsA(SessionKey))
+  def test_releaseLock(self):
+    self.mock_thrift_client.releaseLock(
+        IsA(Lock),
+        IsA(LockValidation),
+        IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
-    self.make_scheduler_proxy().endMaintenance(Hosts())
+    self.make_scheduler_proxy().releaseLock(Lock(), LockValidation())
 
-  def test_getVersion(self):
-    self.mock_thrift_client.getVersion()
+  def test_getJobUpdateSummaries(self):
+    self.mock_thrift_client.getJobUpdateSummaries(IsA(JobUpdateQuery)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
-    self.make_scheduler_proxy().getVersion()
+    self.make_scheduler_proxy().getJobUpdateSummaries(JobUpdateQuery())
 
-  def test_addInstances(self):
-    self.mock_thrift_client.addInstances(IsA(JobKey), IgnoreArg(), IsA(Lock), IsA(SessionKey))
+  def test_getJobUpdateDetails(self):
+    self.mock_thrift_client.getJobUpdateDetails('update_id').AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
-    self.make_scheduler_proxy().addInstances(JobKey(), {}, Lock())
+    self.make_scheduler_proxy().getJobUpdateDetails('update_id')
 
-  def test_acquireLock(self):
-    self.mock_thrift_client.acquireLock(IsA(Lock), IsA(SessionKey))
+  def test_startJobUpdate(self):
+    self.mock_thrift_client.startJobUpdate(
+        IsA(JobUpdateRequest),
+        IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
-    self.make_scheduler_proxy().acquireLock(Lock())
+    self.make_scheduler_proxy().startJobUpdate(JobUpdateRequest())
 
-  def test_releaseLock(self):
-    self.mock_thrift_client.releaseLock(IsA(Lock), IsA(LockValidation), IsA(SessionKey))
+  def test_pauseJobUpdate(self):
+    self.mock_thrift_client.pauseJobUpdate('update_id', IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
-    self.make_scheduler_proxy().releaseLock(Lock(), LockValidation())
+    self.make_scheduler_proxy().pauseJobUpdate('update_id')
+
+  def test_resumeJobUpdate(self):
+    self.mock_thrift_client.resumeJobUpdate(
+        'update_id',
+        IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
+    self.mox.ReplayAll()
+    self.make_scheduler_proxy().resumeJobUpdate('update_id')
+
+  def test_abortJobUpdate(self):
+    self.mock_thrift_client.abortJobUpdate('update_id', IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
+    self.mox.ReplayAll()
+    self.make_scheduler_proxy().abortJobUpdate('update_id')
 
 
 class TestSchedulerProxyAdminInjection(TestSchedulerProxyInjection):
+  def test_startMaintenance(self):
+    self.mock_thrift_client.startMaintenance(
+      IsA(Hosts),
+      IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
+    self.mox.ReplayAll()
+    self.make_scheduler_proxy().startMaintenance(Hosts())
+
+  def test_drainHosts(self):
+    self.mock_thrift_client.drainHosts(IsA(Hosts), IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
+    self.mox.ReplayAll()
+    self.make_scheduler_proxy().drainHosts(Hosts())
+
+  def test_maintenanceStatus(self):
+    self.mock_thrift_client.maintenanceStatus(
+      IsA(Hosts),
+      IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
+    self.mox.ReplayAll()
+    self.make_scheduler_proxy().maintenanceStatus(Hosts())
+
+  def test_endMaintenance(self):
+    self.mock_thrift_client.endMaintenance(IsA(Hosts), IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
+    self.mox.ReplayAll()
+    self.make_scheduler_proxy().endMaintenance(Hosts())
+
   def test_setQuota(self):
-    self.mock_thrift_client.setQuota(IgnoreArg(), IsA(ResourceAggregate), IsA(SessionKey))
+    self.mock_thrift_client.setQuota(
+        IgnoreArg(),
+        IsA(ResourceAggregate),
+        IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().setQuota(ROLE, ResourceAggregate())
 
   def test_forceTaskState(self):
-    self.mock_thrift_client.forceTaskState('taskid', IgnoreArg(), IsA(SessionKey))
+    self.mock_thrift_client.forceTaskState(
+        'taskid',
+        IgnoreArg(),
+        IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().forceTaskState('taskid', ScheduleStatus.LOST)
 
   def test_performBackup(self):
-    self.mock_thrift_client.performBackup(IsA(SessionKey))
+    self.mock_thrift_client.performBackup(IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().performBackup()
 
   def test_listBackups(self):
-    self.mock_thrift_client.listBackups(IsA(SessionKey))
+    self.mock_thrift_client.listBackups(IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().listBackups()
 
   def test_stageRecovery(self):
-    self.mock_thrift_client.stageRecovery(IsA(TaskQuery), IsA(SessionKey))
+    self.mock_thrift_client.stageRecovery(
+        IsA(TaskQuery),
+        IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().stageRecovery(TaskQuery())
 
   def test_queryRecovery(self):
-    self.mock_thrift_client.queryRecovery(IsA(TaskQuery), IsA(SessionKey))
+    self.mock_thrift_client.queryRecovery(
+      IsA(TaskQuery),
+      IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().queryRecovery(TaskQuery())
 
   def test_deleteRecoveryTasks(self):
-    self.mock_thrift_client.deleteRecoveryTasks(IsA(TaskQuery), IsA(SessionKey))
+    self.mock_thrift_client.deleteRecoveryTasks(
+        IsA(TaskQuery),
+        IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().deleteRecoveryTasks(TaskQuery())
 
   def test_commitRecovery(self):
-    self.mock_thrift_client.commitRecovery(IsA(SessionKey))
+    self.mock_thrift_client.commitRecovery(IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().commitRecovery()
 
   def test_unloadRecovery(self):
-    self.mock_thrift_client.unloadRecovery(IsA(SessionKey))
+    self.mock_thrift_client.unloadRecovery(IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().unloadRecovery()
 
   def test_snapshot(self):
-    self.mock_thrift_client.snapshot(IsA(SessionKey))
+    self.mock_thrift_client.snapshot(IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().snapshot()
 
   def test_rewriteConfigs(self):
-    self.mock_thrift_client.rewriteConfigs(IsA(RewriteConfigsRequest), IsA(SessionKey))
+    self.mock_thrift_client.rewriteConfigs(
+        IsA(RewriteConfigsRequest),
+        IsA(SessionKey)).AndReturn(DEFAULT_RESPONSE)
     self.mox.ReplayAll()
     self.make_scheduler_proxy().rewriteConfigs(RewriteConfigsRequest())
 
-  def test_getJobUpdateSummaries(self):
-    self.mock_thrift_client.getJobUpdateSummaries(IsA(JobUpdateQuery))
-    self.mox.ReplayAll()
-    self.make_scheduler_proxy().getJobUpdateSummaries(JobUpdateQuery())
-
-  def test_getJobUpdateDetails(self):
-    self.mock_thrift_client.getJobUpdateDetails('update_id')
-    self.mox.ReplayAll()
-    self.make_scheduler_proxy().getJobUpdateDetails('update_id')
-
-  def test_startJobUpdate(self):
-    self.mock_thrift_client.startJobUpdate(IsA(JobUpdateRequest), IsA(SessionKey))
-    self.mox.ReplayAll()
-    self.make_scheduler_proxy().startJobUpdate(JobUpdateRequest())
-
-  def test_pauseJobUpdate(self):
-    self.mock_thrift_client.pauseJobUpdate('update_id', IsA(SessionKey))
-    self.mox.ReplayAll()
-    self.make_scheduler_proxy().pauseJobUpdate('update_id')
-
-  def test_resumeJobUpdate(self):
-    self.mock_thrift_client.resumeJobUpdate('update_id', IsA(SessionKey))
-    self.mox.ReplayAll()
-    self.make_scheduler_proxy().resumeJobUpdate('update_id')
-
-  def test_abortJobUpdate(self):
-    self.mock_thrift_client.abortJobUpdate('update_id', IsA(SessionKey))
-    self.mox.ReplayAll()
-    self.make_scheduler_proxy().abortJobUpdate('update_id')
-
 
 @pytest.mark.parametrize('scheme', ('http', 'https'))
 def test_url_when_not_connected_and_cluster_has_no_proxy_url(scheme):
@@ -347,19 +386,18 @@ def test_connect_scheduler(mock_client):
 
 @mock.patch('apache.aurora.client.api.scheduler_client.SchedulerClient',
             spec=scheduler_client.SchedulerClient)
-def test_transient_error(client):
+@mock.patch('threading._Event.wait')
+def test_transient_error(_, client):
   mock_scheduler_client = mock.Mock(spec=scheduler_client.SchedulerClient)
   mock_thrift_client = mock.Mock(spec=AuroraAdmin.Client)
-  version_resp = Response(responseCode=ResponseCode.OK)
-  version_resp.result = Result(getVersionResult=CURRENT_API_VERSION)
-  mock_thrift_client.getVersion.return_value = version_resp
   mock_thrift_client.killTasks.side_effect = [
-      Response(responseCode=ResponseCode.ERROR_TRANSIENT, details=["message1", "message2"]),
-      Response(responseCode=ResponseCode.ERROR_TRANSIENT),
-      Response(responseCode=ResponseCode.OK)]
-
-  mock_thrift_client.killTasks.return_value = Response(
-      responseCode=ResponseCode.OK, messageDEPRECATED="ok")
+      Response(responseCode=ResponseCode.ERROR_TRANSIENT,
+               details=["message1", "message2"],
+               serverInfo=DEFAULT_RESPONSE.serverInfo),
+      Response(responseCode=ResponseCode.ERROR_TRANSIENT,
+               serverInfo=DEFAULT_RESPONSE.serverInfo),
+      Response(responseCode=ResponseCode.OK,
+               serverInfo=DEFAULT_RESPONSE.serverInfo)]
 
   mock_scheduler_client.get_thrift_client.return_value = mock_thrift_client
   client.get.return_value = mock_scheduler_client

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/797b8152/src/test/python/apache/aurora/client/api/test_updater.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_updater.py b/src/test/python/apache/aurora/client/api/test_updater.py
index e8eaa9e..f0e45e3 100644
--- a/src/test/python/apache/aurora/client/api/test_updater.py
+++ b/src/test/python/apache/aurora/client/api/test_updater.py
@@ -26,9 +26,10 @@ from apache.aurora.client.api.scheduler_mux import SchedulerMux
 from apache.aurora.client.api.updater import Updater
 from apache.aurora.client.fake_scheduler_proxy import FakeSchedulerProxy
 from apache.aurora.common.aurora_job_key import AuroraJobKey
+from apache.aurora.common.cluster import Cluster
 
 from gen.apache.aurora.api.AuroraSchedulerManager import Client as scheduler_client
-from gen.apache.aurora.api.constants import ACTIVE_STATES
+from gen.apache.aurora.api.constants import ACTIVE_STATES, THRIFT_API_VERSION
 from gen.apache.aurora.api.ttypes import (
     AcquireLockResult,
     AddInstancesConfig,
@@ -49,6 +50,7 @@ from gen.apache.aurora.api.ttypes import (
     Result,
     ScheduledTask,
     ScheduleStatusResult,
+    ServerInfo,
     TaskConfig,
     TaskConstraint,
     TaskQuery,
@@ -63,6 +65,8 @@ if 'UPDATER_DEBUG' in environ:
   LogOptions.set_stderr_log_level('DEBUG')
   log.init('test_updater')
 
+SERVER_INFO = ServerInfo(thriftAPIVersion=THRIFT_API_VERSION)
+
 
 class FakeConfig(object):
   def __init__(self, role, name, env, update_config):
@@ -141,7 +145,9 @@ class UpdaterTest(TestCase):
     self._job_monitor = MockObject(JobMonitor)
     self._scheduler_mux = FakeSchedulerMux()
     self._scheduler = MockObject(scheduler_client)
-    self._scheduler_proxy = FakeSchedulerProxy('test-cluster', self._scheduler, self._session_key)
+    self._scheduler_proxy = FakeSchedulerProxy(Cluster(name='test-cluster'),
+                                               self._scheduler,
+                                               self._session_key)
     self._quota_check = MockObject(QuotaCheck)
     self.init_updater(deepcopy(self.UPDATE_CONFIG))
     self._num_cpus = 1.0
@@ -182,14 +188,16 @@ class UpdaterTest(TestCase):
 
   def expect_populate(self, job_config, response_code=None):
     response_code = ResponseCode.OK if response_code is None else response_code
-    resp = Response(responseCode=response_code, messageDEPRECATED='test')
+    resp = Response(responseCode=response_code, messageDEPRECATED='test', serverInfo=SERVER_INFO)
     result = set([deepcopy(job_config.taskConfig)])
     resp.result = Result(populateJobResult=PopulateJobResult(populatedDEPRECATED=result))
     self._scheduler.populateJobConfig(job_config).AndReturn(resp)
 
   def expect_get_tasks(self, tasks, ignore_ids=None, response_code=None):
     response_code = ResponseCode.OK if response_code is None else response_code
-    response = Response(responseCode=response_code, messageDEPRECATED='test')
+    response = Response(responseCode=response_code,
+                        messageDEPRECATED='test',
+                        serverInfo=SERVER_INFO)
     scheduled = []
     for index, task in enumerate(tasks):
       if not ignore_ids or index not in ignore_ids:
@@ -200,13 +208,15 @@ class UpdaterTest(TestCase):
 
   def expect_cron_replace(self, job_config, response_code=None):
     response_code = ResponseCode.OK if response_code is None else response_code
-    resp = Response(responseCode=response_code, messageDEPRECATED='test')
+    resp = Response(responseCode=response_code, messageDEPRECATED='test', serverInfo=SERVER_INFO)
     self._scheduler.replaceCronTemplate(job_config, self._lock, self._session_key).AndReturn(resp)
 
   def expect_restart(self, instance_ids, response_code=None):
     for i in instance_ids:
       response_code = ResponseCode.OK if response_code is None else response_code
-      response = Response(responseCode=response_code, messageDEPRECATED='test')
+      response = Response(responseCode=response_code,
+                          messageDEPRECATED='test',
+                          serverInfo=SERVER_INFO)
       self._scheduler.restartShards(
           self._job_key,
           [i],
@@ -216,7 +226,9 @@ class UpdaterTest(TestCase):
   def expect_kill(self, instance_ids, response_code=None, monitor_result=True, skip_monitor=False):
     for i in instance_ids:
       response_code = ResponseCode.OK if response_code is None else response_code
-      response = Response(responseCode=response_code, messageDEPRECATED='test')
+      response = Response(responseCode=response_code,
+                          messageDEPRECATED='test',
+                          serverInfo=SERVER_INFO)
       query = TaskQuery(jobKeys=[self._job_key],
                         statuses=ACTIVE_STATES,
                         instanceIds=frozenset([int(i)]))
@@ -239,7 +251,9 @@ class UpdaterTest(TestCase):
   def expect_add(self, instance_ids, task_config, response_code=None):
     for i in instance_ids:
       response_code = ResponseCode.OK if response_code is None else response_code
-      response = Response(responseCode=response_code, messageDEPRECATED='test')
+      response = Response(responseCode=response_code,
+                          messageDEPRECATED='test',
+                          serverInfo=SERVER_INFO)
       add_config = AddInstancesConfig(
           key=self._job_key,
           taskConfig=task_config,
@@ -266,13 +280,17 @@ class UpdaterTest(TestCase):
 
   def expect_start(self, response_code=None):
     response_code = ResponseCode.OK if response_code is None else response_code
-    response = Response(responseCode=response_code, messageDEPRECATED='test')
+    response = Response(responseCode=response_code,
+                        messageDEPRECATED='test',
+                        serverInfo=SERVER_INFO)
     response.result = Result(acquireLockResult=AcquireLockResult(lock=self._lock))
     self._scheduler.acquireLock(LockKey(job=self._job_key), self._session_key).AndReturn(response)
 
   def expect_finish(self, response_code=None):
     response_code = ResponseCode.OK if response_code is None else response_code
-    response = Response(responseCode=response_code, messageDEPRECATED='test')
+    response = Response(responseCode=response_code,
+                        messageDEPRECATED='test',
+                        serverInfo=SERVER_INFO)
     self._scheduler.releaseLock(
         self._lock,
         LockValidation.CHECKED,
@@ -280,7 +298,9 @@ class UpdaterTest(TestCase):
 
   def expect_quota_check(self, num_released, num_acquired, response_code=None, prod=True):
     response_code = ResponseCode.OK if response_code is None else response_code
-    response = Response(responseCode=response_code, messageDEPRECATED='test')
+    response = Response(responseCode=response_code,
+                        messageDEPRECATED='test',
+                        serverInfo=SERVER_INFO)
     released = CapacityRequest(ResourceAggregate(
         numCpus=num_released * self._num_cpus,
         ramMb=num_released * self._num_ram,

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/797b8152/src/test/python/apache/aurora/client/cli/test_api_from_cli.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_api_from_cli.py b/src/test/python/apache/aurora/client/cli/test_api_from_cli.py
index a2b28ba..95aa649 100644
--- a/src/test/python/apache/aurora/client/cli/test_api_from_cli.py
+++ b/src/test/python/apache/aurora/client/cli/test_api_from_cli.py
@@ -22,7 +22,6 @@ from apache.aurora.client.cli.client import AuroraCommandLine
 from apache.aurora.client.cli.util import AuroraClientCommandTest
 
 from gen.apache.aurora.api import AuroraAdmin
-from gen.apache.aurora.api.constants import CURRENT_API_VERSION
 from gen.apache.aurora.api.ttypes import (
     AssignedTask,
     GetJobsResult,
@@ -138,9 +137,6 @@ class TestApiFromCLI(AuroraClientCommandTest):
     mock_thrift_client = Mock(spec=AuroraAdmin.Client)
     mock_scheduler_client.get_thrift_client.return_value = mock_thrift_client
 
-    version_resp = Response(responseCode=ResponseCode.OK)
-    version_resp.result = Result(getVersionResult=CURRENT_API_VERSION)
-    mock_thrift_client.getVersion.return_value = version_resp
     mock_thrift_client.getTasksWithoutConfigs.side_effect = IOError("Uh-Oh")
     with contextlib.nested(
         patch('apache.aurora.client.api.scheduler_client.SchedulerClient.get',
@@ -153,6 +149,5 @@ class TestApiFromCLI(AuroraClientCommandTest):
       # exception, which results in the command failing with an error code.
       result = cmd.execute(['job', 'status', 'west/bozo/test/hello'])
       assert result == EXIT_UNKNOWN_ERROR
-      mock_thrift_client.getVersion.assert_called_once_with()
       mock_thrift_client.getTasksWithoutConfigs.assert_called_with(
         TaskQuery(jobKeys=[JobKey(role='bozo', environment='test', name='hello')]))

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/797b8152/src/test/python/apache/aurora/client/fake_scheduler_proxy.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/fake_scheduler_proxy.py b/src/test/python/apache/aurora/client/fake_scheduler_proxy.py
index 12e70e9..183d2d6 100644
--- a/src/test/python/apache/aurora/client/fake_scheduler_proxy.py
+++ b/src/test/python/apache/aurora/client/fake_scheduler_proxy.py
@@ -19,7 +19,7 @@ from apache.aurora.client.api.scheduler_client import SchedulerProxy
 
 class FakeSchedulerProxy(SchedulerProxy):
   def __init__(self, cluster, scheduler, session_key):
-    self._cluster = cluster
+    SchedulerProxy.__init__(self, cluster, verbose=True)
     self._scheduler = scheduler
     self._session_key = session_key
     self._lock = RLock()


Mime
View raw message