You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by ma...@apache.org on 2014/12/11 20:46:47 UTC

incubator-aurora git commit: Changing the default --batch-size to 1.

Repository: incubator-aurora
Updated Branches:
  refs/heads/master 5d8d3e1fd -> 73a500c84


Changing the default --batch-size to 1.

Bugs closed: AURORA-961

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


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

Branch: refs/heads/master
Commit: 73a500c845b8315f3bba2e081cab88bc06ec7db3
Parents: 5d8d3e1
Author: Maxim Khutornenko <ma...@apache.org>
Authored: Thu Dec 11 11:46:31 2014 -0800
Committer: -l <ma...@apache.org>
Committed: Thu Dec 11 11:46:31 2014 -0800

----------------------------------------------------------------------
 .../python/apache/aurora/client/cli/options.py  |   2 +-
 .../apache/aurora/client/cli/test_kill.py       | 293 +++++++------------
 .../python/apache/aurora/client/cli/util.py     |   6 +-
 3 files changed, 107 insertions(+), 194 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/73a500c8/src/main/python/apache/aurora/client/cli/options.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/options.py b/src/main/python/apache/aurora/client/cli/options.py
index e844cf3..b7f5a03 100644
--- a/src/main/python/apache/aurora/client/cli/options.py
+++ b/src/main/python/apache/aurora/client/cli/options.py
@@ -196,7 +196,7 @@ def instance_specifier(spec_str):
   return TaskInstanceKey(jobkey, instances)
 
 
-BATCH_OPTION = CommandOption('--batch-size', type=int, default=5,
+BATCH_OPTION = CommandOption('--batch-size', type=int, default=1,
         help='Number of instances to be operate on in one iteration')
 
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/73a500c8/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 1eda72a..3036f9c 100644
--- a/src/test/python/apache/aurora/client/cli/test_kill.py
+++ b/src/test/python/apache/aurora/client/cli/test_kill.py
@@ -16,16 +16,16 @@ import contextlib
 import unittest
 
 import pytest
-from mock import create_autospec, patch
+from mock import call, Mock, patch
 from twitter.common.contextutil import temporary_file
 
-from apache.aurora.client.cli import Context, EXIT_TIMEOUT
+from apache.aurora.client.api.job_monitor import JobMonitor
+from apache.aurora.client.cli import Context
 from apache.aurora.client.cli.client import AuroraCommandLine
 from apache.aurora.client.cli.jobs import KillCommand
 from apache.aurora.client.cli.options import parse_instances, TaskInstanceKey
 from apache.aurora.common.aurora_job_key import AuroraJobKey
 
-from ..api.api_util import SchedulerThriftApiSpec
 from .util import AuroraClientCommandTest, FakeAuroraCommandContext, mock_verb_options
 
 from gen.apache.aurora.api.ttypes import (
@@ -104,19 +104,6 @@ class TestKillCommand(unittest.TestCase):
 
 class TestClientKillCommand(AuroraClientCommandTest):
   @classmethod
-  def get_kill_job_response(cls):
-    return cls.create_simple_success_response()
-
-  @classmethod
-  def assert_kill_job_called(cls, mock_api):
-    assert mock_api.kill_job.call_count == 1
-
-  @classmethod
-  def assert_scheduler_called(cls, mock_api, mock_query, num_queries):
-    assert mock_api.scheduler_proxy.getTasksWithoutConfigs.call_count == num_queries
-    mock_api.scheduler_proxy.getTasksWithoutConfigs.assert_called_with(mock_query)
-
-  @classmethod
   def get_expected_task_query(cls, instances=None):
     instance_ids = frozenset(instances) if instances is not None else None
     return TaskQuery(taskIds=None,
@@ -125,214 +112,165 @@ class TestClientKillCommand(AuroraClientCommandTest):
                                      environment=cls.TEST_ENV,
                                      name=cls.TEST_JOB)])
 
-  def test_killall_job(self):
-    """Test kill client-side API logic."""
-    mock_context = FakeAuroraCommandContext()
-    mock_scheduler_proxy = create_autospec(spec=SchedulerThriftApiSpec, instance=True)
-    with contextlib.nested(
-        patch('threading._Event.wait'),
-        patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
-        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
+  @classmethod
+  def get_monitor_mock(cls):
+    mock_monitor = Mock(spec=JobMonitor)
+    mock_monitor.wait_until.return_value = True
+    return mock_monitor
 
-      api = mock_context.get_api('west')
-      mock_scheduler_proxy.getTasksWithoutConfigs.return_value = self.create_status_call_result()
-      api.kill_job.return_value = self.get_kill_job_response()
-      mock_scheduler_proxy.killTasks.return_value = self.get_kill_job_response()
-      mock_context.add_expected_status_query_result(self.create_status_call_result(
-          self.create_mock_task(ScheduleStatus.KILLED)))
-      with temporary_file() as fp:
-        fp.write(self.get_valid_config())
-        fp.flush()
-        cmd = AuroraCommandLine()
-        cmd.execute(['job', 'killall', '--no-batching', '--config=%s' % fp.name,
-            'west/bozo/test/hello'])
+  @classmethod
+  def assert_kill_calls(cls, api, instance_range=None, instances=None):
+    if instances:
+      kill_calls = [call(AuroraJobKey.from_path(cls.TEST_JOBSPEC), instances)]
+    else:
+      kill_calls = [call(AuroraJobKey.from_path(cls.TEST_JOBSPEC), [i]) for i in instance_range]
+    assert api.kill_job.mock_calls == kill_calls
 
-      # Now check that the right API calls got made.
-      assert api.kill_job.call_count == 1
-      api.kill_job.assert_called_with(AuroraJobKey.from_path('west/bozo/test/hello'), None)
-      self.assert_scheduler_called(api, self.get_expected_task_query(), 2)
+  @classmethod
+  def assert_wait_calls(cls, mock_monitor, terminal, instance_range=None, instances=None):
+    if instances:
+      wait_calls = [call(terminal, instances=instances, with_timeout=True)]
+    else:
+      wait_calls = [call(terminal, instances=[i], with_timeout=True) for i in instance_range]
+    assert mock_monitor.wait_until.mock_calls == wait_calls
 
-  def test_killall_job_wait_until_timeout(self):
-    """Test kill client-side API logic."""
+  @classmethod
+  def assert_kill_call_no_instances(cls, api):
+    assert api.kill_job.mock_calls == call((AuroraJobKey.from_path(cls.TEST_JOBSPEC), None))
+
+  @classmethod
+  def assert_query(cls, fake_api):
+    calls = [call(cls.TEST_JOBKEY)]
+    assert fake_api.check_status.mock_calls == calls
+
+  def test_killall_job(self):
+    """Test killall client-side API logic."""
     mock_context = FakeAuroraCommandContext()
-    mock_scheduler_proxy = create_autospec(spec=SchedulerThriftApiSpec, instance=True)
+    mock_monitor = self.get_monitor_mock()
     with contextlib.nested(
-        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
-        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
+        patch('apache.aurora.client.cli.jobs.JobMonitor', return_value=mock_monitor),
+        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)) as (_, m, _):
 
       api = mock_context.get_api('west')
-      mock_scheduler_proxy.getTasksWithoutConfigs.return_value = self.create_status_call_result()
-      api.kill_job.return_value = self.get_kill_job_response()
-      mock_scheduler_proxy.killTasks.return_value = self.get_kill_job_response()
-      for _ in range(8):
-        mock_context.add_expected_status_query_result(self.create_status_call_result(
-            self.create_mock_task(ScheduleStatus.RUNNING)))
+      api.kill_job.return_value = self.create_simple_success_response()
 
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
         fp.flush()
         cmd = AuroraCommandLine()
-        assert EXIT_TIMEOUT == cmd.execute(
-            ['job', 'killall', '--no-batching', '--config=%s' % fp.name, 'west/bozo/test/hello'])
+        cmd.execute(['job', 'killall', '--no-batching', '--config=%s' % fp.name, self.TEST_JOBSPEC])
 
-      # Now check that the right API calls got made.
-      assert api.kill_job.call_count == 1
-      api.kill_job.assert_called_with(AuroraJobKey.from_path('west/bozo/test/hello'), None)
-      self.assert_scheduler_called(api, self.get_expected_task_query(), 8)
+      self.assert_kill_call_no_instances(api)
+      assert mock_monitor.wait_until.mock_calls == [
+          call(m.terminal, instances=None, with_timeout=True)]
 
-  def test_killall_job_something_else(self):
-    """Test kill client-side API logic."""
+  def test_killall_job_batched(self):
+    """Test killall command with batching."""
     mock_context = FakeAuroraCommandContext()
-    mock_scheduler_proxy = create_autospec(spec=SchedulerThriftApiSpec, instance=True)
+    mock_monitor = self.get_monitor_mock()
     with contextlib.nested(
-        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
-        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
+        patch('apache.aurora.client.cli.jobs.JobMonitor', return_value=mock_monitor),
+        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)) as (_, m, _):
 
       api = mock_context.get_api('west')
-      api.kill_job.return_value = self.get_kill_job_response()
+      api.kill_job.return_value = self.create_simple_success_response()
       mock_context.add_expected_status_query_result(self.create_status_call_result())
-      mock_scheduler_proxy.killTasks.return_value = self.get_kill_job_response()
-      mock_context.add_expected_status_query_result(self.create_status_call_result(
-          self.create_mock_task(ScheduleStatus.KILLED)))
+
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
         fp.flush()
         cmd = AuroraCommandLine()
-        cmd.execute(['job', 'killall', '--config=%s' % fp.name, 'west/bozo/test/hello'])
+        cmd.execute(['job', 'killall', '--config=%s' % fp.name, self.TEST_JOBSPEC])
 
-      # Now check that the right API calls got made.
-      assert api.kill_job.call_count == 4
-      instances = [15, 16, 17, 18, 19]
-      api.kill_job.assert_called_with(AuroraJobKey.from_path('west/bozo/test/hello'), instances)
-      self.assert_scheduler_called(api, self.get_expected_task_query(instances), 6)
+      self.assert_kill_calls(api, instance_range=range(20))
+      self.assert_wait_calls(mock_monitor, m.terminal, instance_range=range(20))
+      self.assert_query(api)
 
   def test_kill_job_with_instances_nobatching(self):
     """Test kill client-side API logic."""
     mock_context = FakeAuroraCommandContext()
+    mock_monitor = self.get_monitor_mock()
     with contextlib.nested(
-        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
-        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
+        patch('apache.aurora.client.cli.jobs.JobMonitor', return_value=mock_monitor),
+        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)) as (_, m, _):
       api = mock_context.get_api('west')
-      self.setup_get_tasks_status_calls(api.scheduler_proxy)
-      api.kill_job.return_value = self.get_kill_job_response()
-      mock_context.add_expected_status_query_result(self.create_status_call_result(
-          self.create_mock_task(ScheduleStatus.KILLED)))
+      api.kill_job.return_value = self.create_simple_success_response()
+
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
         fp.flush()
         cmd = AuroraCommandLine()
         cmd.execute(['job', 'kill', '--config=%s' % fp.name, '--no-batching',
-            'west/bozo/test/hello/0,2,4-6'])
+            self.get_instance_spec('0,2,4-6')])
 
-      # Now check that the right API calls got made.
-      assert api.kill_job.call_count == 1
       instances = [0, 2, 4, 5, 6]
-      api.kill_job.assert_called_with(AuroraJobKey.from_path('west/bozo/test/hello'), instances)
-      self.assert_scheduler_called(api, self.get_expected_task_query(instances), 2)
+      self.assert_kill_calls(api, instances=instances)
+      self.assert_wait_calls(mock_monitor, m.terminal, instances=instances)
 
   def test_kill_job_with_invalid_instances_strict(self):
     """Test kill client-side API logic."""
     mock_context = FakeAuroraCommandContext()
     with contextlib.nested(
-        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       api = mock_context.get_api('west')
-      self.setup_get_tasks_status_calls(api.scheduler_proxy)
-      api.kill_job.return_value = self.get_kill_job_response()
-      mock_context.add_expected_status_query_result(self.create_status_call_result(
-          self.create_mock_task(ScheduleStatus.KILLED)))
+      api.kill_job.return_value = self.create_simple_success_response()
+
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
         fp.flush()
         cmd = AuroraCommandLine()
         cmd.execute(['job', 'kill', '--config=%s' % fp.name, '--no-batching', '--strict',
-            'west/bozo/test/hello/0,2,4-6,11-20'])
+             self.get_instance_spec('0,2,4-6,11-20')])
 
-      # Now check that the right API calls got made.
       assert api.kill_job.call_count == 0
 
   def test_kill_job_with_invalid_instances_nonstrict(self):
     """Test kill client-side API logic."""
     mock_context = FakeAuroraCommandContext()
+    mock_monitor = self.get_monitor_mock()
     with contextlib.nested(
-        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
-        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
+        patch('apache.aurora.client.cli.jobs.JobMonitor', return_value=mock_monitor),
+        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)) as (_, m, _):
       api = mock_context.get_api('west')
-      self.setup_get_tasks_status_calls(api.scheduler_proxy)
-      api.kill_job.return_value = self.get_kill_job_response()
-      mock_context.add_expected_status_query_result(self.create_status_call_result(
-          self.create_mock_task(ScheduleStatus.KILLED)))
+      api.kill_job.return_value = self.create_simple_success_response()
+
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
         fp.flush()
         cmd = AuroraCommandLine()
         cmd.execute(['job', 'kill', '--config=%s' % fp.name, '--no-batching',
-            'west/bozo/test/hello/0,2,4-6,11-13'])
+             self.get_instance_spec('0,2,4-6,11-13')])
 
-      # Now check that the right API calls got made.
-      assert api.kill_job.call_count == 1
       instances = [0, 2, 4, 5, 6, 11, 12, 13]
-      api.kill_job.assert_called_with(AuroraJobKey.from_path('west/bozo/test/hello'), instances)
-      self.assert_scheduler_called(api, self.get_expected_task_query(instances), 2)
+      self.assert_kill_calls(api, instances=instances)
+      self.assert_wait_calls(mock_monitor, m.terminal, instances=instances)
 
   def test_kill_job_with_instances_batched(self):
     """Test kill client-side API logic."""
     mock_context = FakeAuroraCommandContext()
+    mock_monitor = self.get_monitor_mock()
     with contextlib.nested(
-        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
-        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
-      api = mock_context.get_api('west')
-      status_result = self.create_status_call_result()
-      mock_context.add_expected_status_query_result(status_result)
-      api.kill_job.return_value = self.get_kill_job_response()
-      mock_context.add_expected_status_query_result(self.create_status_call_result(
-          self.create_mock_task(ScheduleStatus.KILLED)))
-
-      with temporary_file() as fp:
-        fp.write(self.get_valid_config())
-        fp.flush()
-        cmd = AuroraCommandLine()
-        cmd.execute(['job', 'kill', '--config=%s' % fp.name, 'west/bozo/test/hello/0,2,4-6'])
-
-      # Now check that the right API calls got made.
-      assert api.kill_job.call_count == 1
-      instances = [0, 2, 4, 5, 6]
-      api.kill_job.assert_called_with(AuroraJobKey.from_path('west/bozo/test/hello'), instances)
-      # Expect total 3 calls (one from JobMonitor).
-      self.assert_scheduler_called(api, self.get_expected_task_query(instances), 3)
-
-  def test_kill_job_with_instances_batched_large(self):
-    """Test kill client-side API logic."""
-    mock_context = FakeAuroraCommandContext()
-    with contextlib.nested(
-        patch('threading._Event.wait'),
-        patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
-        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
+        patch('apache.aurora.client.cli.jobs.JobMonitor', return_value=mock_monitor),
+        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)) as (_, m, _):
       api = mock_context.get_api('west')
-      status_result = self.create_status_call_result()
-      mock_context.add_expected_status_query_result(status_result)
-      api.kill_job.return_value = self.get_kill_job_response()
-      mock_context.add_expected_status_query_result(self.create_status_call_result(
-          self.create_mock_task(ScheduleStatus.KILLED)))
+      mock_context.add_expected_status_query_result(self.create_status_call_result())
+      api.kill_job.return_value = self.create_simple_success_response()
 
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
         fp.flush()
         cmd = AuroraCommandLine()
-        cmd.execute(['job', 'kill', '--config=%s' % fp.name, 'west/bozo/test/hello/0,2,4-13'])
+        cmd.execute(['job', 'kill', '--config=%s' % fp.name, self.get_instance_spec('0-6')])
 
-      # Now check that the right API calls got made.
-      assert api.kill_job.call_count == 3
-      api.kill_job.assert_called_with(AuroraJobKey.from_path('west/bozo/test/hello'),
-          [12, 13])
-      # Expect total 5 calls (3 from JobMonitor).
-      self.assert_scheduler_called(api, self.get_expected_task_query([12, 13]), 5)
+      self.assert_kill_calls(api, instance_range=range(7))
+      self.assert_wait_calls(mock_monitor, m.terminal, instance_range=range(7))
+      self.assert_query(api)
 
   def test_kill_job_with_instances_batched_maxerrors(self):
     """Test kill client-side API logic."""
@@ -341,8 +279,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       api = mock_context.get_api('west')
-      status_result = self.create_status_call_result()
-      mock_context.add_expected_status_query_result(status_result)
+      mock_context.add_expected_status_query_result(self.create_status_call_result())
       api.kill_job.return_value = self.create_error_response()
 
       with temporary_file() as fp:
@@ -350,17 +287,16 @@ class TestClientKillCommand(AuroraClientCommandTest):
         fp.flush()
         cmd = AuroraCommandLine()
         cmd.execute(['job', 'kill', '--max-total-failures=1', '--config=%s' % fp.name,
-            'west/bozo/test/hello/0,2,4-13'])
+            self.get_instance_spec('0-4')])
 
-      # Now check that the right API calls got made. We should have aborted after the second batch.
-      assert api.kill_job.call_count == 2
-      assert api.scheduler_proxy.getTasksWithoutConfigs.call_count == 0
+      # We should have aborted after the second batch.
+      self.assert_kill_calls(api, instance_range=range(2))
+      self.assert_query(api)
 
   def test_kill_job_with_empty_instances_batched(self):
     """Test kill client-side API logic."""
     mock_context = FakeAuroraCommandContext()
     with contextlib.nested(
-        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       api = mock_context.get_api('west')
@@ -368,57 +304,32 @@ class TestClientKillCommand(AuroraClientCommandTest):
       status_response = self.create_simple_success_response()
       status_response.result = Result(scheduleStatusResult=ScheduleStatusResult(tasks=[]))
       mock_context.add_expected_status_query_result(status_response)
-      api.kill_job.return_value = self.get_kill_job_response()
+      api.kill_job.return_value = self.create_simple_success_response()
+
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
         fp.flush()
         cmd = AuroraCommandLine()
-        cmd.execute(['job', 'kill', '--config=%s' % fp.name, 'west/bozo/test/hello/0,2,4-13'])
+        cmd.execute(['job', 'kill', '--config=%s' % fp.name, self.get_instance_spec('0,2,4-13')])
 
-      # Now check that the right API calls got made.
       assert api.kill_job.call_count == 0
 
-  def test_kill_job_with_instances_deep_api(self):
-    """Test kill client-side API logic."""
-    (mock_api, mock_scheduler_proxy) = self.create_mock_api()
-    with contextlib.nested(
-        patch('threading._Event.wait'),
-        patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler_proxy),
-        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
-      mock_scheduler_proxy.killTasks.return_value = self.get_kill_job_response()
-      self.setup_get_tasks_status_calls(mock_scheduler_proxy)
-      with temporary_file() as fp:
-        fp.write(self.get_valid_config())
-        fp.flush()
-        cmd = AuroraCommandLine()
-        cmd.execute(['job', 'kill', '--config=%s' % fp.name, 'west/bozo/test/hello/0,2,4-6'])
-      # 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(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."""
     mock_context = FakeAuroraCommandContext()
-    mock_scheduler_proxy = create_autospec(spec=SchedulerThriftApiSpec, instance=True)
     with contextlib.nested(
-        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
+        patch('apache.aurora.client.cli.jobs.JobMonitor', return_value=self.get_monitor_mock()),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
-
       api = mock_context.get_api('west')
-      mock_scheduler_proxy.getTasksWithoutConfigs.return_value = self.create_status_call_result()
-      api.kill_job.return_value = self.get_kill_job_response()
-      mock_scheduler_proxy.killTasks.return_value = self.get_kill_job_response()
-      mock_context.add_expected_status_query_result(self.create_status_call_result(
-          self.create_mock_task(ScheduleStatus.KILLED)))
+      api.kill_job.return_value = self.create_simple_success_response()
+
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
         fp.flush()
         cmd = AuroraCommandLine()
-        cmd.execute(['job', 'killall', '--no-batching', '--config=%s' % fp.name,
-            'west/bozo/test/hello'])
+        cmd.execute(['job', 'killall', '--no-batching', '--config=%s' % fp.name, self.TEST_JOBSPEC])
+
       assert mock_context.get_out() == ['job killall succeeded']
       assert mock_context.get_err() == []
 
@@ -426,21 +337,19 @@ class TestClientKillCommand(AuroraClientCommandTest):
     """Test kill client-side API logic."""
     mock_context = FakeAuroraCommandContext()
     with contextlib.nested(
-        patch('threading._Event.wait'),
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
+        patch('apache.aurora.client.cli.jobs.JobMonitor', return_value=self.get_monitor_mock()),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       api = mock_context.get_api('west')
-      status_result = self.create_status_call_result()
-      mock_context.add_expected_status_query_result(status_result)
-      api.kill_job.return_value = self.get_kill_job_response()
-      mock_context.add_expected_status_query_result(self.create_status_call_result(
-          self.create_mock_task(ScheduleStatus.KILLED)))
+      mock_context.add_expected_status_query_result(self.create_status_call_result())
+      api.kill_job.return_value = self.create_simple_success_response()
 
       with temporary_file() as fp:
         fp.write(self.get_valid_config())
         fp.flush()
         cmd = AuroraCommandLine()
-        cmd.execute(['job', 'kill', '--config=%s' % fp.name, 'west/bozo/test/hello/0,2,4-6'])
+        cmd.execute(['job', 'kill', '--config=%s' % fp.name, '--batch-size=5',
+                     self.get_instance_spec('0,2,4-6')])
 
     assert mock_context.get_out() == ['Successfully killed shards [0, 2, 4, 5, 6]',
         'job kill succeeded']
@@ -451,10 +360,10 @@ class TestClientKillCommand(AuroraClientCommandTest):
     mock_context = FakeAuroraCommandContext()
     with contextlib.nested(
         patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
+        patch('apache.aurora.client.cli.jobs.JobMonitor', return_value=self.get_monitor_mock()),
         patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
       api = mock_context.get_api('west')
-      status_result = self.create_status_call_result()
-      mock_context.add_expected_status_query_result(status_result)
+      mock_context.add_expected_status_query_result(self.create_status_call_result())
       api.kill_job.return_value = self.create_error_response()
 
       with temporary_file() as fp:
@@ -462,7 +371,7 @@ class TestClientKillCommand(AuroraClientCommandTest):
         fp.flush()
         cmd = AuroraCommandLine()
         cmd.execute(['job', 'kill', '--max-total-failures=1', '--config=%s' % fp.name,
-            'west/bozo/test/hello/0,2,4-13'])
+                     '--batch-size=5', self.get_instance_spec('0,2,4-13')])
 
       assert mock_context.get_out() == []
       assert mock_context.get_err() == [

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/73a500c8/src/test/python/apache/aurora/client/cli/util.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/util.py b/src/test/python/apache/aurora/client/cli/util.py
index 67d7eaa..6dba185 100644
--- a/src/test/python/apache/aurora/client/cli/util.py
+++ b/src/test/python/apache/aurora/client/cli/util.py
@@ -135,7 +135,6 @@ class AuroraClientCommandTest(unittest.TestCase):
     mock_scheduler = create_autospec(spec=SchedulerThriftApiSpec, instance=True)
     mock_scheduler.url = "http://something_or_other"
     mock_scheduler_client = create_autospec(spec=SchedulerProxyApiSpec, instance=True)
-    #mock_scheduler_client.scheduler.return_value = mock_scheduler
     mock_scheduler_client.url = "http://something_or_other"
     mock_api = create_autospec(spec=HookedAuroraClientAPI, instance=True)
     mock_api.scheduler_proxy = mock_scheduler_client
@@ -298,6 +297,11 @@ jobs = [HELLO_WORLD]
       auth_mechanism='UNAUTHENTICATED')])
 
   @classmethod
+  def get_instance_spec(cls, instances_spec):
+    """Create a job instance spec string"""
+    return '%s/%s' % (cls.TEST_JOBSPEC, instances_spec)
+
+  @classmethod
   def get_test_config(cls, base, cluster, role, env, job, filler=''):
     """Create a config from the template"""
     return base % {'job': job, 'role': role, 'env': env, 'cluster': cluster,