You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wf...@apache.org on 2014/10/08 23:43:59 UTC

git commit: Fix exit condition for RPC loop, fix test_status_api_failure test.

Repository: incubator-aurora
Updated Branches:
  refs/heads/master 05129ed53 -> 964e16b31


Fix exit condition for RPC loop, fix test_status_api_failure test.

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


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

Branch: refs/heads/master
Commit: 964e16b3170c9dd9cbd019ec6a08c6f12fc5aeb7
Parents: 05129ed
Author: Bill Farner <wf...@apache.org>
Authored: Wed Oct 8 14:43:54 2014 -0700
Committer: Bill Farner <wf...@apache.org>
Committed: Wed Oct 8 14:43:54 2014 -0700

----------------------------------------------------------------------
 .../python/apache/aurora/client/api/__init__.py |  9 +-
 .../apache/aurora/client/api/command_runner.py  |  8 +-
 .../apache/aurora/client/api/job_monitor.py     |  8 +-
 .../aurora/client/api/scheduler_client.py       |  6 +-
 .../python/apache/aurora/client/api/updater.py  |  8 +-
 .../apache/aurora/common/aurora_job_key.py      |  4 +-
 .../aurora/client/api/test_job_monitor.py       |  8 +-
 .../aurora/client/api/test_scheduler_client.py  |  7 +-
 .../apache/aurora/client/api/test_updater.py    | 15 +---
 .../aurora/client/cli/test_api_from_cli.py      | 91 ++++++++++++--------
 .../aurora/client/cli/test_cancel_update.py     | 19 ++--
 .../aurora/client/cli/test_command_hooks.py     |  6 +-
 .../apache/aurora/client/cli/test_create.py     |  6 +-
 .../apache/aurora/client/cli/test_diff.py       |  6 +-
 .../apache/aurora/client/cli/test_kill.py       | 13 +--
 .../apache/aurora/client/cli/test_logging.py    |  9 +-
 .../apache/aurora/client/cli/test_plugins.py    |  6 +-
 .../apache/aurora/client/cli/test_status.py     |  8 +-
 .../apache/aurora/client/cli/test_task_run.py   |  9 +-
 .../apache/aurora/client/cli/test_update.py     | 15 ++--
 .../apache/aurora/client/commands/test_admin.py |  4 +-
 .../client/commands/test_cancel_update.py       | 19 ++--
 .../aurora/client/commands/test_create.py       |  6 +-
 .../apache/aurora/client/commands/test_diff.py  |  6 +-
 .../apache/aurora/client/commands/test_hooks.py |  9 +-
 .../apache/aurora/client/commands/test_kill.py  |  9 +-
 .../apache/aurora/client/commands/test_run.py   |  6 +-
 .../apache/aurora/client/commands/test_ssh.py   |  7 +-
 .../aurora/client/commands/test_status.py       | 12 +--
 .../aurora/client/commands/test_update.py       | 15 ++--
 30 files changed, 159 insertions(+), 195 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/main/python/apache/aurora/client/api/__init__.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/__init__.py b/src/main/python/apache/aurora/client/api/__init__.py
index 2630079..d12132f 100644
--- a/src/main/python/apache/aurora/client/api/__init__.py
+++ b/src/main/python/apache/aurora/client/api/__init__.py
@@ -28,7 +28,7 @@ from .updater_util import UpdaterConfig
 
 from gen.apache.aurora.api.constants import LIVE_STATES
 from gen.apache.aurora.api.ttypes import (
-    Identity,
+    JobKey,
     JobUpdateQuery,
     JobUpdateRequest,
     Lock,
@@ -98,7 +98,6 @@ class AuroraClientAPI(object):
 
     # Leave query.owner.user unset so the query doesn't filter jobs only submitted by a particular
     # user.
-    # TODO(wfarner): Refactor this when Identity is removed from TaskQuery.
     query = job_key.to_thrift_query()
     if instances is not None:
       log.info("Instances to be killed: %s" % instances)
@@ -113,11 +112,9 @@ class AuroraClientAPI(object):
 
   @classmethod
   def build_query(cls, role, job, instances=None, statuses=LIVE_STATES, env=None):
-    return TaskQuery(owner=Identity(role=role),
-                     jobName=job,
+    return TaskQuery(jobKeys=[JobKey(role=role, environment=env, name=job)],
                      statuses=statuses,
-                     instanceIds=instances,
-                     environment=env)
+                     instanceIds=instances)
 
   def query(self, query):
     try:

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/main/python/apache/aurora/client/api/command_runner.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/command_runner.py b/src/main/python/apache/aurora/client/api/command_runner.py
index a1fed5f..14a316b 100644
--- a/src/main/python/apache/aurora/client/api/command_runner.py
+++ b/src/main/python/apache/aurora/client/api/command_runner.py
@@ -28,7 +28,7 @@ from apache.aurora.config.schema.base import MesosContext
 from apache.thermos.config.schema import ThermosContext
 
 from gen.apache.aurora.api.constants import LIVE_STATES
-from gen.apache.aurora.api.ttypes import Identity, ResponseCode, TaskQuery
+from gen.apache.aurora.api.ttypes import JobKey, ResponseCode, TaskQuery
 
 
 class CommandRunnerTrait(Cluster.Trait):
@@ -95,7 +95,7 @@ class DistributedCommandRunner(object):
 
   @classmethod
   def query_from(cls, role, env, job):
-    return TaskQuery(statuses=LIVE_STATES, owner=Identity(role), jobName=job, environment=env)
+    return TaskQuery(statuses=LIVE_STATES, jobKeys=[JobKey(role=role, environment=env, name=job)])
 
   def __init__(self, cluster, role, env, jobs, ssh_user=None,
       log_fn=log.log):
@@ -142,9 +142,7 @@ class InstanceDistributedCommandRunner(DistributedCommandRunner):
   def query_from(cls, role, env, job, instances=None):
     return TaskQuery(
         statuses=LIVE_STATES,
-        owner=Identity(role),
-        jobName=job,
-        environment=env,
+        jobKeys=[JobKey(role=role, environment=env, name=job)],
         instanceIds=instances)
 
   def __init__(self, cluster, role, env, job, ssh_user=None, instances=None, log_fn=logging.log):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/main/python/apache/aurora/client/api/job_monitor.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/job_monitor.py b/src/main/python/apache/aurora/client/api/job_monitor.py
index 18d5c03..aa7e976 100644
--- a/src/main/python/apache/aurora/client/api/job_monitor.py
+++ b/src/main/python/apache/aurora/client/api/job_monitor.py
@@ -19,7 +19,7 @@ from twitter.common.quantity import Amount, Time
 from .task_util import StatusMuxHelper
 
 from gen.apache.aurora.api.constants import LIVE_STATES, TERMINAL_STATES
-from gen.apache.aurora.api.ttypes import Identity, TaskQuery
+from gen.apache.aurora.api.ttypes import JobKey, TaskQuery
 
 
 class JobMonitor(object):
@@ -60,9 +60,9 @@ class JobMonitor(object):
 
   def create_query(self, instances=None):
     return TaskQuery(
-        owner=Identity(role=self._job_key.role),
-        environment=self._job_key.env,
-        jobName=self._job_key.name,
+        jobKeys=[JobKey(role=self._job_key.role,
+                        environment=self._job_key.env,
+                        name=self._job_key.name)],
         instanceIds=frozenset([int(s) for s in instances]) if instances else None)
 
   def wait_until(self, predicate, instances=None, with_timeout=False):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/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 311c954..7f1c82b 100644
--- a/src/main/python/apache/aurora/client/api/scheduler_client.py
+++ b/src/main/python/apache/aurora/client/api/scheduler_client.py
@@ -297,17 +297,17 @@ class SchedulerProxy(object):
                   [m for m in resp.details] if resp.details else []))
             return resp
           except (TTransport.TTransportException, self.TimeoutError, self.TransientError) as e:
-            if not self._terminating:
+            if not self._terminating.is_set():
               log.warning('Connection error with scheduler: %s, reconnecting...' % e)
               self.invalidate()
               self._terminating.wait(self.RPC_RETRY_INTERVAL.as_(Time.SECONDS))
           except Exception as e:
             # Take any error that occurs during the RPC call, and transform it
             # into something clients can handle.
-            if not self._terminating:
+            if not self._terminating.is_set():
               raise self.ThriftInternalError("Error during thrift call %s to %s: %s" %
                                             (method_name, self.cluster.name, e))
-        if not self._terminating:
+        if not self._terminating.is_set():
           raise self.TimeoutError('Timed out attempting to issue %s to %s' % (
               method_name, self.cluster.name))
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/main/python/apache/aurora/client/api/updater.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/updater.py b/src/main/python/apache/aurora/client/api/updater.py
index bb4a755..2e6bc9f 100644
--- a/src/main/python/apache/aurora/client/api/updater.py
+++ b/src/main/python/apache/aurora/client/api/updater.py
@@ -35,7 +35,6 @@ from .updater_util import FailureThreshold, UpdaterConfig
 from gen.apache.aurora.api.constants import ACTIVE_STATES
 from gen.apache.aurora.api.ttypes import (
     AddInstancesConfig,
-    Identity,
     JobKey,
     Lock,
     LockKey,
@@ -642,12 +641,7 @@ class Updater(object):
       return False
 
   def _create_task_query(self, instanceIds=None):
-    return TaskQuery(
-        owner=Identity(role=self._job_key.role),
-        environment=self._job_key.environment,
-        jobName=self._job_key.name,
-        statuses=ACTIVE_STATES,
-        instanceIds=instanceIds)
+    return TaskQuery(jobKeys=[self._job_key], statuses=ACTIVE_STATES, instanceIds=instanceIds)
 
   def _failed_response(self, message):
     return Response(responseCode=ResponseCode.ERROR, details=[ResponseDetail(message=message)])

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/main/python/apache/aurora/common/aurora_job_key.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/common/aurora_job_key.py b/src/main/python/apache/aurora/common/aurora_job_key.py
index a7ca7b6..88896c6 100644
--- a/src/main/python/apache/aurora/common/aurora_job_key.py
+++ b/src/main/python/apache/aurora/common/aurora_job_key.py
@@ -17,7 +17,7 @@ import re
 from twitter.common.lang import Compatibility, total_ordering
 
 from gen.apache.aurora.api.constants import GOOD_IDENTIFIER_PATTERN_PYTHON
-from gen.apache.aurora.api.ttypes import Identity, JobKey, TaskQuery
+from gen.apache.aurora.api.ttypes import JobKey, TaskQuery
 
 
 # TODO(ksweeney): This can just probably just extend namedtuple.
@@ -86,7 +86,7 @@ class AuroraJobKey(object):
     return JobKey(role=self.role, environment=self.env, name=self.name)
 
   def to_thrift_query(self):
-    return TaskQuery(owner=Identity(role=self.role), environment=self.env, jobName=self.name)
+    return TaskQuery(jobKeys=[JobKey(role=self.role, environment=self.env, name=self.name)])
 
   def __iter__(self):
     """Support 'cluster, role, env, name = job_key' assignment."""

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/api/test_job_monitor.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_job_monitor.py b/src/test/python/apache/aurora/client/api/test_job_monitor.py
index 5b26539..cb2503e 100644
--- a/src/test/python/apache/aurora/client/api/test_job_monitor.py
+++ b/src/test/python/apache/aurora/client/api/test_job_monitor.py
@@ -20,7 +20,7 @@ from apache.aurora.common.aurora_job_key import AuroraJobKey
 
 from gen.apache.aurora.api.ttypes import (
     AssignedTask,
-    Identity,
+    JobKey,
     Response,
     ResponseCode,
     Result,
@@ -71,10 +71,8 @@ class JobMonitorTest(unittest.TestCase):
     self._scheduler.getTasksWithoutConfigs.return_value = resp
 
   def expect_task_status(self, once=False, instances=None):
-    query = TaskQuery(
-        owner=Identity(role=self._job_key.role),
-        environment=self._job_key.env,
-        jobName=self._job_key.name)
+    query = TaskQuery(jobKeys=[
+        JobKey(role=self._job_key.role, environment=self._job_key.env, name=self._job_key.name)])
     if instances is not None:
       query.instanceIds = frozenset([int(s) for s in instances])
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/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 1835843..d78e7dc 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
@@ -98,7 +98,7 @@ class TestSchedulerProxyInjection(unittest.TestCase):
     self.mox.VerifyAll()
 
   def make_scheduler_proxy(self):
-    return TestSchedulerProxy('local')
+    return TestSchedulerProxy(Cluster(name='local'))
 
   def test_startCronJob(self):
     self.mock_thrift_client.startCronJob(IsA(JobKey), IsA(SessionKey))
@@ -350,6 +350,9 @@ def test_connect_scheduler(mock_client):
 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),
@@ -361,7 +364,7 @@ def test_transient_error(client):
   mock_scheduler_client.get_thrift_client.return_value = mock_thrift_client
   client.get.return_value = mock_scheduler_client
 
-  proxy = TestSchedulerProxy('local')
+  proxy = TestSchedulerProxy(Cluster(name='local'))
   proxy.killTasks(TaskQuery())
 
   assert mock_thrift_client.killTasks.call_count == 3

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/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 fe27391..e8eaa9e 100644
--- a/src/test/python/apache/aurora/client/api/test_updater.py
+++ b/src/test/python/apache/aurora/client/api/test_updater.py
@@ -195,11 +195,7 @@ class UpdaterTest(TestCase):
       if not ignore_ids or index not in ignore_ids:
         scheduled.append(ScheduledTask(assignedTask=AssignedTask(task=task, instanceId=index)))
     response.result = Result(scheduleStatusResult=ScheduleStatusResult(tasks=scheduled))
-    query = TaskQuery(
-        owner=Identity(role=self._job_key.role),
-        environment=self._job_key.environment,
-        jobName=self._job_key.name,
-        statuses=ACTIVE_STATES)
+    query = TaskQuery(jobKeys=[self._job_key], statuses=ACTIVE_STATES)
     self._scheduler.getTasksStatus(query).AndReturn(response)
 
   def expect_cron_replace(self, job_config, response_code=None):
@@ -221,12 +217,9 @@ class UpdaterTest(TestCase):
     for i in instance_ids:
       response_code = ResponseCode.OK if response_code is None else response_code
       response = Response(responseCode=response_code, messageDEPRECATED='test')
-      query = TaskQuery(
-          owner=Identity(role=self._job_key.role),
-          environment=self._job_key.environment,
-          jobName=self._job_key.name,
-          statuses=ACTIVE_STATES,
-          instanceIds=frozenset([int(i)]))
+      query = TaskQuery(jobKeys=[self._job_key],
+                        statuses=ACTIVE_STATES,
+                        instanceIds=frozenset([int(i)]))
       self._scheduler.killTasks(
           query,
           self._lock,

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/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 733327b..a2b28ba 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
@@ -16,15 +16,23 @@ import contextlib
 
 from mock import Mock, patch
 
+from apache.aurora.client.api.scheduler_client import SchedulerClient
 from apache.aurora.client.cli import EXIT_UNKNOWN_ERROR
 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,
     Identity,
+    JobConfiguration,
     JobKey,
+    Response,
     ResponseCode,
+    Result,
+    ScheduledTask,
     ScheduleStatus,
     ScheduleStatusResult,
     TaskConfig,
@@ -40,53 +48,53 @@ class TestApiFromCLI(AuroraClientCommandTest):
 
   @classmethod
   def create_mock_scheduled_tasks(cls):
-    jobs = []
+    tasks = []
     for name in ['foo', 'bar', 'baz']:
-      job = Mock()
-      job.key = JobKey(role=cls.TEST_ROLE, environment=cls.TEST_ENV, name=name)
-      job.failure_count = 0
-      job.assignedTask = Mock(spec=AssignedTask)
-      job.assignedTask.slaveHost = 'slavehost'
-      job.assignedTask.task = Mock(spec=TaskConfig)
-      job.assignedTask.task.maxTaskFailures = 1
-      job.assignedTask.task.metadata = []
-      job.assignedTask.task.owner = Identity(role='bozo')
-      job.assignedTask.task.environment = 'test'
-      job.assignedTask.task.jobName = 'woops'
-      job.assignedTask.task.numCpus = 2
-      job.assignedTask.task.ramMb = 2
-      job.assignedTask.task.diskMb = 2
-      job.assignedTask.instanceId = 4237894
-      job.assignedTask.assignedPorts = None
-      job.status = ScheduleStatus.RUNNING
+      task = Mock(spec=ScheduledTask)
+      task.key = JobKey(role=cls.TEST_ROLE, environment=cls.TEST_ENV, name=name)
+      task.failure_count = 0
+      task.assignedTask = Mock(spec=AssignedTask)
+      task.assignedTask.slaveHost = 'slavehost'
+      task.assignedTask.task = Mock(spec=TaskConfig)
+      task.assignedTask.task.maxTaskFailures = 1
+      task.assignedTask.task.metadata = []
+      task.assignedTask.task.owner = Identity(role='bozo')
+      task.assignedTask.task.environment = 'test'
+      task.assignedTask.task.jobName = 'woops'
+      task.assignedTask.task.numCpus = 2
+      task.assignedTask.task.ramMb = 2
+      task.assignedTask.task.diskMb = 2
+      task.assignedTask.instanceId = 4237894
+      task.assignedTask.assignedPorts = None
+      task.status = ScheduleStatus.RUNNING
       mockEvent = Mock(spec=TaskEvent)
       mockEvent.timestamp = 28234726395
       mockEvent.status = ScheduleStatus.RUNNING
       mockEvent.message = "Hi there"
-      job.taskEvents = [mockEvent]
-      jobs.append(job)
-    return jobs
+      task.taskEvents = [mockEvent]
+      tasks.append(task)
+    return tasks
 
   @classmethod
   def create_mock_scheduled_task_no_metadata(cls):
     result = cls.create_mock_scheduled_tasks()
-    for job in result:
-      job.assignedTask.task.metadata = None
+    for task in result:
+      task.assignedTask.task.metadata = None
     return result
 
   @classmethod
   def create_getjobs_response(cls):
-    result = Mock()
+    result = Mock(spec=Response)
     result.responseCode = ResponseCode.OK
-    result.result = Mock()
-    result.result.getJobsResult = Mock()
-    mock_job_one = Mock()
-    mock_job_one.key = Mock()
+    result.result = Mock(spec=Result)
+    result.result.getJobsResult = Mock(spec=GetJobsResult)
+    mock_job_one = Mock(spec=JobConfiguration)
+    mock_job_one.key = Mock(spec=JobKey)
     mock_job_one.key.role = 'RoleA'
     mock_job_one.key.environment = 'test'
     mock_job_one.key.name = 'hithere'
-    mock_job_two = Mock()
-    mock_job_two.key = Mock()
+    mock_job_two = Mock(spec=JobConfiguration)
+    mock_job_two.key = Mock(spec=JobKey)
     mock_job_two.key.role = 'bozo'
     mock_job_two.key.environment = 'test'
     mock_job_two.key.name = 'hello'
@@ -114,21 +122,26 @@ class TestApiFromCLI(AuroraClientCommandTest):
   def test_successful_status_deep(self):
     """Test the status command more deeply: in a request with a fully specified
     job, it should end up doing a query using getTasksWithoutConfigs."""
-    (mock_api, mock_scheduler_proxy) = self.create_mock_api()
+    _, mock_scheduler_proxy = self.create_mock_api()
     mock_scheduler_proxy.query.return_value = self.create_status_response()
     with contextlib.nested(
         patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler_proxy),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       cmd = AuroraCommandLine()
       cmd.execute(['job', 'status', 'west/bozo/test/hello'])
-      mock_scheduler_proxy.getTasksWithoutConfigs.assert_called_with(TaskQuery(jobName='hello',
-          environment='test', owner=Identity(role='bozo')))
+      mock_scheduler_proxy.getTasksWithoutConfigs.assert_called_with(
+          TaskQuery(jobKeys=[JobKey(role='bozo', environment='test', name='hello')]))
 
   def test_status_api_failure(self):
-    # Following should use spec=SchedulerClient, but due to introspection for the RPC calls,
-    # the necessary methods aren't in that spec.
-    mock_scheduler_client = Mock()
-    mock_scheduler_client.getTasksWithoutConfigs.side_effect = IOError("Uh-Oh")
+    # TODO(wfarner): Consider spec_set instead of spec.
+    mock_scheduler_client = Mock(spec=SchedulerClient)
+    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',
             return_value=mock_scheduler_client),
@@ -140,4 +153,6 @@ 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_scheduler_client.getTasksWithoutConfigs.assert_call_count == 1
+      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/964e16b3/src/test/python/apache/aurora/client/cli/test_cancel_update.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_cancel_update.py b/src/test/python/apache/aurora/client/cli/test_cancel_update.py
index c15e142..e705246 100644
--- a/src/test/python/apache/aurora/client/cli/test_cancel_update.py
+++ b/src/test/python/apache/aurora/client/cli/test_cancel_update.py
@@ -21,13 +21,7 @@ from apache.aurora.client.cli.client import AuroraCommandLine
 from apache.aurora.client.cli.util import AuroraClientCommandTest, FakeAuroraCommandContext
 from apache.aurora.common.aurora_job_key import AuroraJobKey
 
-from gen.apache.aurora.api.ttypes import (
-    Identity,
-    JobKey,
-    ScheduleStatus,
-    ScheduleStatusResult,
-    TaskQuery
-)
+from gen.apache.aurora.api.ttypes import JobKey, ScheduleStatus, ScheduleStatusResult, TaskQuery
 
 
 class TestClientCancelUpdateCommand(AuroraClientCommandTest):
@@ -52,11 +46,6 @@ class TestClientCancelUpdateCommand(AuroraClientCommandTest):
     return mock_query_result
 
   @classmethod
-  def create_mock_query(cls):
-    return TaskQuery(owner=Identity(role=cls.TEST_ROLE), environment=cls.TEST_ENV,
-        jobName=cls.TEST_JOB)
-
-  @classmethod
   def get_cancel_update_response(cls):
     return cls.create_simple_success_response()
 
@@ -85,8 +74,10 @@ class TestClientCancelUpdateCommand(AuroraClientCommandTest):
   def get_expected_task_query(cls, shards=None):
     instance_ids = frozenset(shards) if shards is not None else None
     # Helper to create the query that will be a parameter to job kill.
-    return TaskQuery(taskIds=None, jobName=cls.TEST_JOB, environment=cls.TEST_ENV,
-        instanceIds=instance_ids, owner=Identity(role=cls.TEST_ROLE, user=None))
+    return TaskQuery(
+        taskIds=None,
+        instanceIds=instance_ids,
+        jobKeys=[JobKey(role=cls.TEST_ROLE, environment=cls.TEST_ENV, name=cls.TEST_JOB)])
 
   @classmethod
   def get_release_lock_response(cls):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/cli/test_command_hooks.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_command_hooks.py b/src/test/python/apache/aurora/client/cli/test_command_hooks.py
index 3acd2ba..9fc6fe2 100644
--- a/src/test/python/apache/aurora/client/cli/test_command_hooks.py
+++ b/src/test/python/apache/aurora/client/cli/test_command_hooks.py
@@ -25,7 +25,7 @@ from apache.aurora.config import AuroraConfig
 
 from gen.apache.aurora.api.ttypes import (
     AssignedTask,
-    Identity,
+    JobKey,
     ScheduledTask,
     ScheduleStatus,
     ScheduleStatusResult,
@@ -123,8 +123,8 @@ class TestClientCreateCommand(AuroraClientCommandTest):
 
   @classmethod
   def create_mock_query(cls):
-    return TaskQuery(owner=Identity(role=cls.TEST_ROLE), environment=cls.TEST_ENV,
-        jobName=cls.TEST_JOB)
+    return TaskQuery(
+        jobKeys=[JobKey(role=cls.TEST_ROLE, environment=cls.TEST_ENV, name=cls.TEST_JOB)])
 
   @classmethod
   def get_createjob_response(cls):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/cli/test_create.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_create.py b/src/test/python/apache/aurora/client/cli/test_create.py
index d172035..427f7ce 100644
--- a/src/test/python/apache/aurora/client/cli/test_create.py
+++ b/src/test/python/apache/aurora/client/cli/test_create.py
@@ -31,7 +31,7 @@ from apache.aurora.config import AuroraConfig
 
 from gen.apache.aurora.api.ttypes import (
     AssignedTask,
-    Identity,
+    JobKey,
     ScheduledTask,
     ScheduleStatus,
     ScheduleStatusResult,
@@ -69,8 +69,8 @@ class TestClientCreateCommand(AuroraClientCommandTest):
 
   @classmethod
   def create_mock_query(cls):
-    return TaskQuery(owner=Identity(role=cls.TEST_ROLE), environment=cls.TEST_ENV,
-        jobName=cls.TEST_JOB)
+    return TaskQuery(
+        jobKeys=[JobKey(role=cls.TEST_ROLE, environment=cls.TEST_ENV, name=cls.TEST_JOB)])
 
   @classmethod
   def get_createjob_response(cls):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/cli/test_diff.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_diff.py b/src/test/python/apache/aurora/client/cli/test_diff.py
index e1a6f76..1081769 100644
--- a/src/test/python/apache/aurora/client/cli/test_diff.py
+++ b/src/test/python/apache/aurora/client/cli/test_diff.py
@@ -121,8 +121,8 @@ class TestDiffCommand(AuroraClientCommandTest):
 
         # Diff should get the task status, populate a config, and run diff.
         mock_scheduler_proxy.getTasksStatus.assert_called_with(
-            TaskQuery(jobName='hello', environment='test', owner=Identity(role='bozo'),
-                statuses=ACTIVE_STATES))
+            TaskQuery(jobKeys=[JobKey(role='bozo', environment='test', name='hello')],
+                      statuses=ACTIVE_STATES))
         assert mock_scheduler_proxy.populateJobConfig.call_count == 1
         assert isinstance(mock_scheduler_proxy.populateJobConfig.call_args[0][0], JobConfiguration)
         assert (mock_scheduler_proxy.populateJobConfig.call_args[0][0].key ==
@@ -185,7 +185,7 @@ class TestDiffCommand(AuroraClientCommandTest):
         # In this error case, we should have called the server getTasksStatus;
         # but since it fails, we shouldn't call populateJobConfig or subprocess.
         mock_scheduler_proxy.getTasksStatus.assert_called_with(
-            TaskQuery(jobName='hello', environment='test', owner=Identity(role='bozo'),
+            TaskQuery(jobKeys=[JobKey(role='bozo', environment='test', name='hello')],
                 statuses=ACTIVE_STATES))
         assert mock_scheduler_proxy.populateJobConfig.call_count == 0
         assert subprocess_patch.call_count == 0

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/cli/test_kill.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_kill.py b/src/test/python/apache/aurora/client/cli/test_kill.py
index e3a366b..bac4485 100644
--- a/src/test/python/apache/aurora/client/cli/test_kill.py
+++ b/src/test/python/apache/aurora/client/cli/test_kill.py
@@ -24,7 +24,7 @@ from apache.aurora.client.cli.options import parse_instances
 from apache.aurora.client.cli.util import AuroraClientCommandTest, FakeAuroraCommandContext
 from apache.aurora.common.aurora_job_key import AuroraJobKey
 
-from gen.apache.aurora.api.ttypes import Identity, ScheduleStatus, ScheduleStatusResult, TaskQuery
+from gen.apache.aurora.api.ttypes import JobKey, ScheduleStatus, ScheduleStatusResult, TaskQuery
 
 
 class TestInstancesParser(unittest.TestCase):
@@ -55,8 +55,11 @@ class TestClientKillCommand(AuroraClientCommandTest):
   @classmethod
   def get_expected_task_query(cls, instances=None):
     instance_ids = frozenset(instances) if instances is not None else None
-    return TaskQuery(taskIds=None, jobName=cls.TEST_JOB, environment=cls.TEST_ENV,
-                     instanceIds=instance_ids, owner=Identity(role=cls.TEST_ROLE, user=None))
+    return TaskQuery(taskIds=None,
+                     instanceIds=instance_ids,
+                     jobKeys=[JobKey(role=cls.TEST_ROLE,
+                                     environment=cls.TEST_ENV,
+                                     name=cls.TEST_JOB)])
 
   def test_killall_job(self):
     """Test kill client-side API logic."""
@@ -330,8 +333,8 @@ class TestClientKillCommand(AuroraClientCommandTest):
       # Now check that the right API calls got made.
       assert mock_scheduler_proxy.killTasks.call_count == 1
       mock_scheduler_proxy.killTasks.assert_called_with(
-        TaskQuery(jobName='hello', environment='test', instanceIds=frozenset([0, 2, 4, 5, 6]),
-            owner=Identity(role='bozo')), None)
+          TaskQuery(jobKeys=[JobKey(role='bozo', environment='test', name='hello')],
+                    instanceIds=frozenset([0, 2, 4, 5, 6])), None)
 
   def test_killall_job_output(self):
     """Test kill output."""

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/cli/test_logging.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_logging.py b/src/test/python/apache/aurora/client/cli/test_logging.py
index 6285fbb..9ca4dce 100644
--- a/src/test/python/apache/aurora/client/cli/test_logging.py
+++ b/src/test/python/apache/aurora/client/cli/test_logging.py
@@ -24,12 +24,10 @@ from apache.aurora.config import AuroraConfig
 
 from gen.apache.aurora.api.ttypes import (
     AssignedTask,
-    Identity,
     ScheduledTask,
     ScheduleStatus,
     ScheduleStatusResult,
-    TaskEvent,
-    TaskQuery
+    TaskEvent
 )
 
 
@@ -70,11 +68,6 @@ class TestLogging(AuroraClientCommandTest):
     return mock_query_result
 
   @classmethod
-  def create_mock_query(cls):
-    return TaskQuery(owner=Identity(role=cls.TEST_ROLE), environment=cls.TEST_ENV,
-        jobName=cls.TEST_JOB)
-
-  @classmethod
   def get_createjob_response(cls):
     # Then, we call api.create_job(config)
     return cls.create_simple_success_response()

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/cli/test_plugins.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_plugins.py b/src/test/python/apache/aurora/client/cli/test_plugins.py
index 7c79c7a..dc5edd4 100644
--- a/src/test/python/apache/aurora/client/cli/test_plugins.py
+++ b/src/test/python/apache/aurora/client/cli/test_plugins.py
@@ -25,7 +25,7 @@ from apache.aurora.config import AuroraConfig
 
 from gen.apache.aurora.api.ttypes import (
     AssignedTask,
-    Identity,
+    JobKey,
     ScheduledTask,
     ScheduleStatus,
     ScheduleStatusResult,
@@ -91,8 +91,8 @@ class TestPlugins(AuroraClientCommandTest):
 
   @classmethod
   def create_mock_query(cls):
-    return TaskQuery(owner=Identity(role=cls.TEST_ROLE), environment=cls.TEST_ENV,
-        jobName=cls.TEST_JOB)
+    return TaskQuery(
+        jobKeys=[JobKey(role=cls.TEST_ROLE, environment=cls.TEST_ENV, name=cls.TEST_JOB)])
 
   @classmethod
   def get_createjob_response(cls):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/cli/test_status.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_status.py b/src/test/python/apache/aurora/client/cli/test_status.py
index d263712..c704dae 100644
--- a/src/test/python/apache/aurora/client/cli/test_status.py
+++ b/src/test/python/apache/aurora/client/cli/test_status.py
@@ -218,8 +218,8 @@ class TestJobStatus(AuroraClientCommandTest):
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       cmd = AuroraCommandLine()
       cmd.execute(['job', 'status', 'west/bozo/test/hello'])
-      mock_scheduler_proxy.getTasksWithoutConfigs.assert_called_with(TaskQuery(jobName='hello',
-          environment='test', owner=Identity(role='bozo')))
+      mock_scheduler_proxy.getTasksWithoutConfigs.assert_called_with(
+          TaskQuery(jobKeys=[JobKey(role='bozo', environment='test', name='hello')]))
 
   def test_successful_status_output_no_metadata(self):
     """Test the status command more deeply: in a request with a fully specified
@@ -297,8 +297,8 @@ class TestJobStatus(AuroraClientCommandTest):
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       cmd = AuroraCommandLine()
       cmd.execute(['job', 'status', 'west/bozo/test/hello'])
-      mock_scheduler_proxy.getTasksWithoutConfigs.assert_called_with(TaskQuery(jobName='hello',
-          environment='test', owner=Identity(role='bozo')))
+      mock_scheduler_proxy.getTasksWithoutConfigs.assert_called_with(
+          TaskQuery(jobKeys=[JobKey(role='bozo', environment='test', name='hello')]))
 
   def test_status_wildcard(self):
     """Test status using a wildcard. It should first call api.get_jobs, and then do a

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/cli/test_task_run.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_task_run.py b/src/test/python/apache/aurora/client/cli/test_task_run.py
index 1ce9a63..16fde14 100644
--- a/src/test/python/apache/aurora/client/cli/test_task_run.py
+++ b/src/test/python/apache/aurora/client/cli/test_task_run.py
@@ -129,8 +129,8 @@ class TestRunCommand(AuroraClientCommandTest):
       # The status command sends a getTasksStatus query to the scheduler,
       # and then prints the result. The use of shards, above, should change
       # this query - that's the focus of the instances test.
-      mock_scheduler_proxy.getTasksStatus.assert_called_with(TaskQuery(jobName='hello',
-          environment='test', owner=Identity(role='bozo'),
+      mock_scheduler_proxy.getTasksStatus.assert_called_with(TaskQuery(
+          jobKeys=[JobKey(role='bozo', environment='test', name='hello')],
           statuses=set([ScheduleStatus.RUNNING, ScheduleStatus.KILLING, ScheduleStatus.RESTARTING,
               ScheduleStatus.PREEMPTING, ScheduleStatus.DRAINING]),
           instanceIds=instances))
@@ -215,8 +215,9 @@ class TestSshCommand(AuroraClientCommandTest):
 
       # The status command sends a getTasksStatus query to the scheduler,
       # and then prints the result.
-      mock_scheduler_proxy.getTasksStatus.assert_called_with(TaskQuery(jobName='hello',
-          environment='test', owner=Identity(role='bozo'), instanceIds=set([1]),
+      mock_scheduler_proxy.getTasksStatus.assert_called_with(TaskQuery(
+          jobKeys=[JobKey(role='bozo', environment='test', name='hello')],
+          instanceIds=set([1]),
           statuses=set([ScheduleStatus.RUNNING, ScheduleStatus.KILLING, ScheduleStatus.RESTARTING,
               ScheduleStatus.PREEMPTING, ScheduleStatus.DRAINING
               ])))

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/cli/test_update.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_update.py b/src/test/python/apache/aurora/client/cli/test_update.py
index 85b1db1..cff1b65 100644
--- a/src/test/python/apache/aurora/client/cli/test_update.py
+++ b/src/test/python/apache/aurora/client/cli/test_update.py
@@ -31,7 +31,6 @@ from gen.apache.aurora.api.ttypes import (
     AcquireLockResult,
     AddInstancesConfig,
     AssignedTask,
-    Identity,
     JobKey,
     PopulateJobResult,
     ResponseCode,
@@ -313,10 +312,10 @@ class TestUpdateCommand(AuroraClientCommandTest):
     assert api.killTasks.call_count == 20
     # Check the last call's parameters.
     api.killTasks.assert_called_with(
-        TaskQuery(taskIds=None, jobName='hello', environment='test',
+        TaskQuery(taskIds=None,
+            jobKeys=[JobKey(role='bozo', environment='test', name='hello')],
             instanceIds=frozenset([19]),
-            owner=Identity(role=u'bozo', user=None),
-           statuses=ACTIVE_STATES),
+            statuses=ACTIVE_STATES),
         'foo')
 
   @classmethod
@@ -332,9 +331,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
     for status_call in status_calls:
       status_call[0][0] == TaskQuery(
         taskIds=None,
-        jobName='hello',
-        environment='test',
-        owner=Identity(role='bozo', user=None),
+        jobKeys=[JobKey(role='bozo', environment='test', name='hello')],
         statuses=set([ScheduleStatus.RUNNING]))
 
     # getTasksStatus is called only once to build an generate update instructions
@@ -342,7 +339,5 @@ class TestUpdateCommand(AuroraClientCommandTest):
 
     api.getTasksStatus.assert_called_once_with(TaskQuery(
       taskIds=None,
-      jobName='hello',
-      environment='test',
-      owner=Identity(role=u'bozo', user=None),
+      jobKeys=[JobKey(role='bozo', environment='test', name='hello')],
       statuses=ACTIVE_STATES))

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/commands/test_admin.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/test_admin.py b/src/test/python/apache/aurora/client/commands/test_admin.py
index 1192556..769545b 100644
--- a/src/test/python/apache/aurora/client/commands/test_admin.py
+++ b/src/test/python/apache/aurora/client/commands/test_admin.py
@@ -78,9 +78,7 @@ class TestQueryCommand(AuroraClientCommandTest):
   @classmethod
   def task_query(cls):
     return TaskQuery(
-        owner=Identity(role=None),
-        environment=None,
-        jobName=None,
+        jobKeys=[JobKey(role=None, environment=None, name=None)],
         instanceIds=set(),
         statuses=set([ScheduleStatus.RUNNING]))
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/commands/test_cancel_update.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/test_cancel_update.py b/src/test/python/apache/aurora/client/commands/test_cancel_update.py
index 5f05ef7..13aa1fe 100644
--- a/src/test/python/apache/aurora/client/commands/test_cancel_update.py
+++ b/src/test/python/apache/aurora/client/commands/test_cancel_update.py
@@ -21,13 +21,7 @@ from apache.aurora.client.commands.core import cancel_update
 from apache.aurora.client.commands.util import AuroraClientCommandTest
 from apache.aurora.common.aurora_job_key import AuroraJobKey
 
-from gen.apache.aurora.api.ttypes import (
-    Identity,
-    JobKey,
-    ScheduleStatus,
-    ScheduleStatusResult,
-    TaskQuery
-)
+from gen.apache.aurora.api.ttypes import JobKey, ScheduleStatus, ScheduleStatusResult, TaskQuery
 
 
 class TestClientCancelUpdateCommand(AuroraClientCommandTest):
@@ -63,11 +57,6 @@ class TestClientCancelUpdateCommand(AuroraClientCommandTest):
     return mock_query_result
 
   @classmethod
-  def create_mock_query(cls):
-    return TaskQuery(owner=Identity(role=cls.TEST_ROLE), environment=cls.TEST_ENV,
-        jobName=cls.TEST_JOB)
-
-  @classmethod
   def get_cancel_update_response(cls):
     return cls.create_simple_success_response()
 
@@ -102,8 +91,10 @@ class TestClientCancelUpdateCommand(AuroraClientCommandTest):
   def get_expected_task_query(cls, shards=None):
     instance_ids = frozenset(shards) if shards is not None else None
     # Helper to create the query that will be a parameter to job kill.
-    return TaskQuery(taskIds=None, jobName=cls.TEST_JOB, environment=cls.TEST_ENV,
-        instanceIds=instance_ids, owner=Identity(role=cls.TEST_ROLE, user=None))
+    return TaskQuery(
+        taskIds=None,
+        jobKeys=[JobKey(role=cls.TEST_ROLE, environment=cls.TEST_ENV, name=cls.TEST_JOB)],
+        instanceIds=instance_ids)
 
   @classmethod
   def get_release_lock_response(cls):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/commands/test_create.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/test_create.py b/src/test/python/apache/aurora/client/commands/test_create.py
index 7503345..4a753fb 100644
--- a/src/test/python/apache/aurora/client/commands/test_create.py
+++ b/src/test/python/apache/aurora/client/commands/test_create.py
@@ -24,7 +24,7 @@ from apache.aurora.config import AuroraConfig
 
 from gen.apache.aurora.api.ttypes import (
     AssignedTask,
-    Identity,
+    JobKey,
     ScheduledTask,
     ScheduleStatus,
     ScheduleStatusResult,
@@ -69,8 +69,8 @@ class TestClientCreateCommand(AuroraClientCommandTest):
 
   @classmethod
   def create_mock_query(cls):
-    return TaskQuery(owner=Identity(role=cls.TEST_ROLE), environment=cls.TEST_ENV,
-        jobName=cls.TEST_JOB)
+    return TaskQuery(
+        jobKeys=[JobKey(role=cls.TEST_ROLE, environment=cls.TEST_ENV, name=cls.TEST_JOB)])
 
   @classmethod
   def get_createjob_response(cls):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/commands/test_diff.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/test_diff.py b/src/test/python/apache/aurora/client/commands/test_diff.py
index 8f5da7d..c8d0145 100644
--- a/src/test/python/apache/aurora/client/commands/test_diff.py
+++ b/src/test/python/apache/aurora/client/commands/test_diff.py
@@ -128,7 +128,8 @@ class TestDiffCommand(AuroraClientCommandTest):
 
         # Diff should get the task status, populate a config, and run diff.
         mock_scheduler_proxy.getTasksStatus.assert_called_with(
-            TaskQuery(jobName='hello', environment='test', owner=Identity(role='mchucarroll'),
+            TaskQuery(
+                jobKeys=[JobKey(role='mchucarroll', environment='test', name='hello')],
                 statuses=ACTIVE_STATES))
         assert mock_scheduler_proxy.populateJobConfig.call_count == 1
         assert isinstance(mock_scheduler_proxy.populateJobConfig.call_args[0][0], JobConfiguration)
@@ -190,7 +191,8 @@ class TestDiffCommand(AuroraClientCommandTest):
         # In this error case, we should have called the server getTasksStatus;
         # but since it fails, we shouldn't call populateJobConfig or subprocess.
         mock_scheduler_proxy.getTasksStatus.assert_called_with(
-            TaskQuery(jobName='hello', environment='test', owner=Identity(role='mchucarroll'),
+            TaskQuery(
+                jobKeys=[JobKey(role='mchucarroll', environment='test', name='hello')],
                 statuses=ACTIVE_STATES))
         assert mock_scheduler_proxy.populateJobConfig.call_count == 0
         assert subprocess_patch.call_count == 0

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/commands/test_hooks.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/test_hooks.py b/src/test/python/apache/aurora/client/commands/test_hooks.py
index 0861f13..d4d8d3c 100644
--- a/src/test/python/apache/aurora/client/commands/test_hooks.py
+++ b/src/test/python/apache/aurora/client/commands/test_hooks.py
@@ -24,12 +24,10 @@ from apache.aurora.client.hooks.hooked_api import HookedAuroraClientAPI
 
 from gen.apache.aurora.api.ttypes import (
     AssignedTask,
-    Identity,
     ScheduledTask,
     ScheduleStatus,
     ScheduleStatusResult,
-    TaskEvent,
-    TaskQuery
+    TaskEvent
 )
 
 
@@ -86,11 +84,6 @@ class TestClientCreateCommand(AuroraClientCommandTest):
     return mock_query_result
 
   @classmethod
-  def create_mock_query(cls):
-    return TaskQuery(owner=Identity(role=cls.TEST_ROLE), environment=cls.TEST_ENV,
-        jobName=cls.TEST_JOB)
-
-  @classmethod
   def get_createjob_response(cls):
     # Then, we call api.create_job(config)
     return cls.create_simple_success_response()

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/commands/test_kill.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/test_kill.py b/src/test/python/apache/aurora/client/commands/test_kill.py
index c0a6fd4..1e13b92 100644
--- a/src/test/python/apache/aurora/client/commands/test_kill.py
+++ b/src/test/python/apache/aurora/client/commands/test_kill.py
@@ -23,7 +23,7 @@ from apache.aurora.common.aurora_job_key import AuroraJobKey
 
 from gen.apache.aurora.api.ttypes import (
     AssignedTask,
-    Identity,
+    JobKey,
     Response,
     ResponseCode,
     Result,
@@ -330,8 +330,11 @@ class TestClientKillCommand(AuroraClientCommandTest):
   def get_expected_task_query(cls, shards=None):
     """Helper to create the query that will be a parameter to job kill."""
     instance_ids = frozenset(shards) if shards is not None else None
-    return TaskQuery(taskIds=None, jobName=cls.TEST_JOB, environment=cls.TEST_ENV,
-        instanceIds=instance_ids, owner=Identity(role=cls.TEST_ROLE, user=None))
+    return TaskQuery(taskIds=None,
+                     instanceIds=instance_ids,
+                     jobKeys=[JobKey(role=cls.TEST_ROLE,
+                                     environment=cls.TEST_ENV,
+                                     name=cls.TEST_JOB)])
 
   def test_kill_job_api_level(self):
     """Test kill client-side API logic."""

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/commands/test_run.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/test_run.py b/src/test/python/apache/aurora/client/commands/test_run.py
index e97b515..0c395f7 100644
--- a/src/test/python/apache/aurora/client/commands/test_run.py
+++ b/src/test/python/apache/aurora/client/commands/test_run.py
@@ -119,9 +119,9 @@ class TestRunCommand(AuroraClientCommandTest):
 
       # The status command sends a getTasksStatus query to the scheduler,
       # and then prints the result.
-      mock_scheduler_proxy.getTasksStatus.assert_called_with(TaskQuery(jobName='hello',
-          environment='test', owner=Identity(role='mchucarroll'),
-          statuses=LIVE_STATES))
+      mock_scheduler_proxy.getTasksStatus.assert_called_with(
+          TaskQuery(jobKeys=[JobKey(role='mchucarroll', environment='test', name='hello')],
+                    statuses=LIVE_STATES))
 
       # The mock status call returns 3 three ScheduledTasks, so three commands should have been run
       assert mock_subprocess.call_count == 3

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/commands/test_ssh.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/test_ssh.py b/src/test/python/apache/aurora/client/commands/test_ssh.py
index 3326224..abb657b 100644
--- a/src/test/python/apache/aurora/client/commands/test_ssh.py
+++ b/src/test/python/apache/aurora/client/commands/test_ssh.py
@@ -116,9 +116,10 @@ class TestSshCommand(AuroraClientCommandTest):
 
       # The status command sends a getTasksStatus query to the scheduler,
       # and then prints the result.
-      mock_scheduler_proxy.getTasksStatus.assert_called_with(TaskQuery(jobName='hello',
-          environment='test', owner=Identity(role='mchucarroll'), instanceIds=set([1]),
-          statuses=LIVE_STATES))
+      mock_scheduler_proxy.getTasksStatus.assert_called_with(
+          TaskQuery(jobKeys=[JobKey(role='mchucarroll', environment='test', name='hello')],
+                    instanceIds=set([1]),
+                    statuses=LIVE_STATES))
       mock_subprocess.assert_called_with(['ssh', '-t', 'mchucarroll@slavehost',
           'cd /slaveroot/slaves/*/frameworks/*/executors/thermos-1287391823/runs/'
           'slaverun/sandbox;ls'])

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/commands/test_status.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/test_status.py b/src/test/python/apache/aurora/client/commands/test_status.py
index bda1f28..6397635 100644
--- a/src/test/python/apache/aurora/client/commands/test_status.py
+++ b/src/test/python/apache/aurora/client/commands/test_status.py
@@ -110,8 +110,8 @@ class TestListJobs(AuroraClientCommandTest):
       status(['west/mchucarroll/test/hello'], mock_options)
       # The status command sends a getTasksWithoutConfigs query to the scheduler,
       # and then prints the result.
-      mock_scheduler_proxy.getTasksWithoutConfigs.assert_called_with(TaskQuery(jobName='hello',
-          environment='test', owner=Identity(role='mchucarroll')))
+      mock_scheduler_proxy.getTasksWithoutConfigs.assert_called_with(
+          TaskQuery(jobKeys=[JobKey(role='mchucarroll', environment='test', name='hello')]))
 
   def test_unsuccessful_status(self):
     """Test the status command when the user asks the status of a job that doesn't exist."""
@@ -125,8 +125,8 @@ class TestListJobs(AuroraClientCommandTest):
         patch('twitter.common.app.get_options', return_value=mock_options)):
 
       self.assertRaises(SystemExit, status, ['west/mchucarroll/test/hello'], mock_options)
-      mock_scheduler_proxy.getTasksWithoutConfigs.assert_called_with(TaskQuery(jobName='hello',
-          environment='test', owner=Identity(role='mchucarroll')))
+      mock_scheduler_proxy.getTasksWithoutConfigs.assert_called_with(
+          TaskQuery(jobKeys=[JobKey(role='mchucarroll', environment='test', name='hello')]))
 
   def test_successful_status_nometadata(self):
     """Test the status command with no metadata."""
@@ -140,5 +140,5 @@ class TestListJobs(AuroraClientCommandTest):
         patch('twitter.common.app.get_options', return_value=mock_options)):
 
       status(['west/mchucarroll/test/hello'], mock_options)
-      mock_scheduler_proxy.getTasksWithoutConfigs.assert_called_with(TaskQuery(jobName='hello',
-          environment='test', owner=Identity(role='mchucarroll')))
+      mock_scheduler_proxy.getTasksWithoutConfigs.assert_called_with(
+          TaskQuery(jobKeys=[JobKey(role='mchucarroll', environment='test', name='hello')]))

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964e16b3/src/test/python/apache/aurora/client/commands/test_update.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/commands/test_update.py b/src/test/python/apache/aurora/client/commands/test_update.py
index af2cbc7..07cbe53 100644
--- a/src/test/python/apache/aurora/client/commands/test_update.py
+++ b/src/test/python/apache/aurora/client/commands/test_update.py
@@ -32,7 +32,6 @@ from gen.apache.aurora.api.ttypes import (
     AcquireLockResult,
     AddInstancesConfig,
     AssignedTask,
-    Identity,
     JobConfiguration,
     JobKey,
     PopulateJobResult,
@@ -272,10 +271,10 @@ class TestUpdateCommand(AuroraClientCommandTest):
     assert api.killTasks.call_count == 20
     # Check the last call's parameters.
     api.killTasks.assert_called_with(
-        TaskQuery(taskIds=None, jobName='hello', environment='test',
+        TaskQuery(taskIds=None,
+            jobKeys=[JobKey(role='mchucarroll', environment='test', name='hello')],
             instanceIds=frozenset([19]),
-            owner=Identity(role=u'mchucarroll', user=None),
-           statuses=ACTIVE_STATES),
+            statuses=ACTIVE_STATES),
         'foo')
 
   @classmethod
@@ -291,9 +290,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
     for status_call in status_calls:
       status_call[0][0] == TaskQuery(
         taskIds=None,
-        jobName='hello',
-        environment='test',
-        owner=Identity(role='mchucarroll', user=None),
+        jobKeys=[JobKey(role='mchucarroll', environment='test', name='hello')],
         statuses=set([ScheduleStatus.RUNNING]))
 
     # getTasksStatus is called only once to build an generate update instructions
@@ -301,7 +298,5 @@ class TestUpdateCommand(AuroraClientCommandTest):
 
     api.getTasksStatus.assert_called_once_with(TaskQuery(
       taskIds=None,
-      jobName='hello',
-      environment='test',
-      owner=Identity(role=u'mchucarroll', user=None),
+      jobKeys=[JobKey(role='mchucarroll', environment='test', name='hello')],
       statuses=ACTIVE_STATES))