aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wick...@apache.org
Subject git commit: Fix bad merge commit
Date Thu, 16 Jan 2014 00:00:36 GMT
Updated Branches:
  refs/heads/master beb085c18 -> a49d94cca


Fix bad merge commit

I noticed that there was some code in src/test/python/twitter that
shouldn't've been there.  This also uncovered a malformed BUILD and some
broken tests.

The test_status_wildcard still fails if you have /etc/aurora or ~/.aurora
populated with a clusters.json, but this probably won't be true on jenkins.

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


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

Branch: refs/heads/master
Commit: a49d94ccab0734caedc58f97dac8c914efc5a402
Parents: beb085c
Author: Brian Wickman <wickman@twopensource.com>
Authored: Wed Jan 15 16:00:07 2014 -0800
Committer: Brian Wickman <wickman@twitter.com>
Committed: Wed Jan 15 16:00:07 2014 -0800

----------------------------------------------------------------------
 .../python/apache/aurora/client/cli/jobs.py     |  16 +-
 src/test/python/apache/aurora/client/BUILD      |   1 +
 src/test/python/apache/aurora/client/cli/BUILD  |   3 +-
 .../apache/aurora/client/cli/test_diff.py       | 179 ++++++++++++++++++
 .../apache/aurora/client/cli/test_status.py     |   4 +-
 src/test/python/twitter/aurora/client/cli/BUILD |  30 ---
 .../twitter/aurora/client/cli/test_diff.py      | 182 -------------------
 7 files changed, 192 insertions(+), 223 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a49d94cc/src/main/python/apache/aurora/client/cli/jobs.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/jobs.py b/src/main/python/apache/aurora/client/cli/jobs.py
index 1d0f37e..c519e3c 100644
--- a/src/main/python/apache/aurora/client/cli/jobs.py
+++ b/src/main/python/apache/aurora/client/cli/jobs.py
@@ -8,18 +8,13 @@ import sys
 from tempfile import NamedTemporaryFile
 
 from apache.aurora.client.api.job_monitor import JobMonitor
-
-from gen.apache.aurora.constants import ACTIVE_STATES
-from gen.apache.aurora.ttypes import ResponseCode, ScheduleStatus
-
-from apache.aurora.client.api.job_monitor import JobMonitor
 from apache.aurora.client.cli import (
     EXIT_COMMAND_FAILURE,
     EXIT_INVALID_CONFIGURATION,
     EXIT_INVALID_PARAMETER,
     EXIT_OK,
     Noun,
-    Verb
+    Verb,
 )
 from apache.aurora.client.cli.context import AuroraCommandContext
 from apache.aurora.client.cli.options import (
@@ -27,10 +22,17 @@ from apache.aurora.client.cli.options import (
     BROWSER_OPTION,
     CONFIG_ARGUMENT,
     JOBSPEC_ARGUMENT,
-    JSON_OPTION
+    JSON_OPTION,
 )
 from apache.aurora.common.aurora_job_key import AuroraJobKey
 
+from gen.apache.aurora.constants import ACTIVE_STATES, AURORA_EXECUTOR_NAME
+from gen.apache.aurora.ttypes import (
+    ExecutorConfig,
+    ResponseCode,
+    ScheduleStatus,
+)
+
 from pystachio.config import Config
 from thrift.TSerialization import serialize
 from thrift.protocol import TJSONProtocol

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a49d94cc/src/test/python/apache/aurora/client/BUILD
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/BUILD b/src/test/python/apache/aurora/client/BUILD
index 27ebaf5..e3e8884 100644
--- a/src/test/python/apache/aurora/client/BUILD
+++ b/src/test/python/apache/aurora/client/BUILD
@@ -3,6 +3,7 @@ python_test_suite(name = 'all',
     pants(':binding_helper'),
     pants(':config'),
     pants('src/test/python/apache/aurora/client/api:all'),
+    pants('src/test/python/apache/aurora/client/cli:all'),
     pants('src/test/python/apache/aurora/client/commands:all'),
     pants('src/test/python/apache/aurora/client/hooks:all'),
   ],

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a49d94cc/src/test/python/apache/aurora/client/cli/BUILD
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/BUILD b/src/test/python/apache/aurora/client/cli/BUILD
index bf21590..97b0744 100644
--- a/src/test/python/apache/aurora/client/cli/BUILD
+++ b/src/test/python/apache/aurora/client/cli/BUILD
@@ -14,13 +14,12 @@ python_library(
 
 python_tests(
   name = 'job',
-  sources = [ 'test_create.py', 'test_kill.py', 'test_status.py' ],
+  sources = [ 'test_create.py', 'test_kill.py', 'test_status.py', 'test_diff.py' ],
   dependencies = [
     pants(':util'),
     pants('src/main/python/apache/aurora/BUILD.thirdparty:mock'),
     pants('aurora/twitterdeps/src/python/twitter/common/contextutil'),
     pants('src/main/python/apache/aurora/client/cli'),
-    pants('src/main/python/apache/aurora/client/cli'),
     pants('src/test/python/apache/aurora/client/commands:util')
   ]
 )

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a49d94cc/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
new file mode 100644
index 0000000..b8997e2
--- /dev/null
+++ b/src/test/python/apache/aurora/client/cli/test_diff.py
@@ -0,0 +1,179 @@
+import contextlib
+
+from apache.aurora.client.cli import (
+    AuroraCommandLine,
+    EXIT_INVALID_CONFIGURATION,
+    EXIT_INVALID_PARAMETER
+)
+from apache.aurora.client.cli.util import AuroraClientCommandTest
+
+from gen.apache.aurora.constants import ACTIVE_STATES
+from gen.apache.aurora.ttypes import (
+    AssignedTask,
+    ExecutorConfig,
+    Identity,
+    JobConfiguration,
+    JobKey,
+    PopulateJobResult,
+    ResponseCode,
+    ScheduleStatus,
+    ScheduleStatusResult,
+    TaskConfig,
+    TaskEvent,
+    TaskQuery,
+)
+
+from mock import Mock, patch
+from twitter.common.contextutil import temporary_file
+
+
+class TestDiffCommand(AuroraClientCommandTest):
+  @classmethod
+  def setup_mock_options(cls):
+    """set up to get a mock options object."""
+    mock_options = Mock()
+    mock_options = Mock()
+    mock_options.env = None
+    mock_options.json = False
+    mock_options.bindings = {}
+    mock_options.open_browser = False
+    mock_options.rename_from = None
+    mock_options.cluster = None
+    return mock_options
+
+  @classmethod
+  def create_mock_scheduled_tasks(cls):
+    jobs = []
+    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.executorConfig = Mock(spec=ExecutorConfig)
+      job.assignedTask.task.executorConfig.data = Mock()
+      job.assignedTask.task.packages = []
+      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
+      mockEvent = Mock(spec=TaskEvent)
+      mockEvent.timestamp = 28234726395
+      mockEvent.status = ScheduleStatus.RUNNING
+      mockEvent.message = "Hi there"
+      job.taskEvents = [mockEvent]
+      jobs.append(job)
+    return jobs
+
+  @classmethod
+  def create_status_response(cls):
+    resp = cls.create_simple_success_response()
+    resp.result.scheduleStatusResult = Mock(spec=ScheduleStatusResult)
+    resp.result.scheduleStatusResult.tasks = set(cls.create_mock_scheduled_tasks())
+    return resp
+
+  @classmethod
+  def create_failed_status_response(cls):
+    return cls.create_blank_response(ResponseCode.INVALID_REQUEST, 'No tasks found for query')
+
+  @classmethod
+  def setup_populate_job_config(cls, api):
+    populate = cls.create_simple_success_response()
+    populate.result.populateJobResult = Mock(spec=PopulateJobResult)
+    api.populateJobConfig.return_value = populate
+    populate.result.populateJobResult.populated = cls.create_mock_scheduled_tasks()
+    return populate
+
+  def test_successful_diff(self):
+    """Test the diff command."""
+    (mock_api, mock_scheduler) = self.setup_mock_api()
+    with contextlib.nested(
+        patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler),
+        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS),
+        patch('subprocess.call', return_value=0),
+        patch('json.loads', return_value=Mock())) as (_, _, subprocess_patch, _):
+      mock_scheduler.getTasksStatus.return_value = self.create_status_response()
+      self.setup_populate_job_config(mock_scheduler)
+      with temporary_file() as fp:
+        fp.write(self.get_valid_config())
+        fp.flush()
+        cmd = AuroraCommandLine()
+        cmd.execute(['job', 'diff', 'west/bozo/test/hello', fp.name])
+
+        # Diff should get the task status, populate a config, and run diff.
+        mock_scheduler.getTasksStatus.assert_called_with(
+            TaskQuery(jobName='hello', environment='test', owner=Identity(role='bozo'),
+                statuses=ACTIVE_STATES))
+        assert mock_scheduler.populateJobConfig.call_count == 1
+        assert isinstance(mock_scheduler.populateJobConfig.call_args[0][0], JobConfiguration)
+        assert (mock_scheduler.populateJobConfig.call_args[0][0].key ==
+            JobKey(environment=u'test', role=u'bozo', name=u'hello'))
+        # Subprocess should have been used to invoke diff with two parameters.
+        assert subprocess_patch.call_count == 1
+        assert len(subprocess_patch.call_args[0][0]) == 3
+        assert subprocess_patch.call_args[0][0][0] == 'diff'
+
+  def test_diff_invalid_config(self):
+    """Test the diff command if the user passes a config with an error in it."""
+    mock_options = self.setup_mock_options()
+    (mock_api, mock_scheduler) = self.create_mock_api()
+    mock_scheduler.getTasksStatus.return_value = self.create_status_response()
+    self.setup_populate_job_config(mock_scheduler)
+    with contextlib.nested(
+        patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler),
+        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS),
+        patch('twitter.common.app.get_options', return_value=mock_options),
+        patch('subprocess.call', return_value=0),
+        patch('json.loads', return_value=Mock())) as (
+            mock_scheduler_proxy_class,
+            mock_clusters,
+            options,
+            subprocess_patch,
+            json_patch):
+      with temporary_file() as fp:
+        fp.write(self.get_invalid_config('stupid="me"',))
+        fp.flush()
+        cmd = AuroraCommandLine()
+        result = cmd.execute(['job', 'diff', 'west/bozo/test/hello', fp.name])
+        assert result == EXIT_INVALID_CONFIGURATION
+        assert mock_scheduler.getTasksStatus.call_count == 0
+        assert mock_scheduler.populateJobConfig.call_count == 0
+        assert subprocess_patch.call_count == 0
+
+  def test_diff_server_error(self):
+    """Test the diff command if the user passes a config with an error in it."""
+    mock_options = self.setup_mock_options()
+    (mock_api, mock_scheduler) = self.create_mock_api()
+    mock_scheduler.getTasksStatus.return_value = self.create_failed_status_response()
+    self.setup_populate_job_config(mock_scheduler)
+    with contextlib.nested(
+        patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler),
+        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS),
+        patch('twitter.common.app.get_options', return_value=mock_options),
+        patch('subprocess.call', return_value=0),
+        patch('json.loads', return_value=Mock())) as (
+            mock_scheduler_proxy_class,
+            mock_clusters,
+            options,
+            subprocess_patch,
+            json_patch):
+      with temporary_file() as fp:
+        fp.write(self.get_valid_config())
+        fp.flush()
+        cmd = AuroraCommandLine()
+        result = cmd.execute(['job', 'diff', 'west/bozo/test/hello', fp.name])
+        assert result == EXIT_INVALID_PARAMETER
+        # In this error case, we should have called the server getTasksStatus;
+        # but since it fails, we shouldn't call populateJobConfig or subprocess.
+        mock_scheduler.getTasksStatus.assert_called_with(
+            TaskQuery(jobName='hello', environment='test', owner=Identity(role='bozo'),
+                statuses=ACTIVE_STATES))
+        assert mock_scheduler.populateJobConfig.call_count == 0
+        assert subprocess_patch.call_count == 0

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a49d94cc/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 38f3018..f4ca0d0 100644
--- a/src/test/python/apache/aurora/client/cli/test_status.py
+++ b/src/test/python/apache/aurora/client/cli/test_status.py
@@ -23,7 +23,6 @@ from mock import call, Mock, patch
 
 
 class TestJobStatus(AuroraClientCommandTest):
-
   @classmethod
   def create_mock_scheduled_tasks(cls):
     jobs = []
@@ -116,7 +115,8 @@ class TestJobStatus(AuroraClientCommandTest):
     mock_api.check_status.return_value = self.create_status_response()
     mock_api.get_jobs.return_value = self.create_getjobs_response()
     with contextlib.nested(
-        patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context)):
+        patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context),
+        patch('apache.aurora.client.cli.context.CLUSTERS', new=self.TEST_CLUSTERS)):
       cmd = AuroraCommandLine()
       cmd.execute(['job', 'status', '*'])
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a49d94cc/src/test/python/twitter/aurora/client/cli/BUILD
----------------------------------------------------------------------
diff --git a/src/test/python/twitter/aurora/client/cli/BUILD b/src/test/python/twitter/aurora/client/cli/BUILD
deleted file mode 100644
index e4ea5da..0000000
--- a/src/test/python/twitter/aurora/client/cli/BUILD
+++ /dev/null
@@ -1,30 +0,0 @@
-python_test_suite(
-  name = 'all',
-  dependencies = [ pants(':job') ]
-)
-
-python_library(
-  name = 'util',
-  sources = [ 'util.py' ],
-  dependencies = [
-    pants('src/main/python/apache/aurora/BUILD.thirdparty:mock'),
-    pants('src/main/python/apache/aurora/client/cli'),
-  ]
-)
-
-python_tests(
-  name = 'job',
-<<<<<<< HEAD
-  sources = [ 'test_create.py', 'test_kill.py', 'test_status.py', 'test_diff.py' ],
-=======
-  sources = [ 'test_create.py', 'test_kill.py', 'test_status.py' ],
->>>>>>> v2.2
-  dependencies = [
-    pants(':util'),
-    pants('src/main/python/apache/aurora/BUILD.thirdparty:mock'),
-    pants('aurora/twitterdeps/src/python/twitter/common/contextutil'),
-    pants('src/main/python/apache/aurora/client/cli'),
-    pants('src/main/python/apache/aurora/client/cli'),
-    pants('src/test/python/apache/aurora/client/commands:util')
-  ]
-)

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a49d94cc/src/test/python/twitter/aurora/client/cli/test_diff.py
----------------------------------------------------------------------
diff --git a/src/test/python/twitter/aurora/client/cli/test_diff.py b/src/test/python/twitter/aurora/client/cli/test_diff.py
deleted file mode 100644
index 363352f..0000000
--- a/src/test/python/twitter/aurora/client/cli/test_diff.py
+++ /dev/null
@@ -1,182 +0,0 @@
-import contextlib
-
-from twitter.aurora.client.cli import (
-    AuroraCommandLine,
-    EXIT_INVALID_CONFIGURATION,
-    EXIT_INVALID_PARAMETER
-)
-from twitter.aurora.client.cli.util import AuroraClientCommandTest
-from twitter.common.contextutil import temporary_file
-
-from gen.twitter.aurora.ttypes import (
-    AssignedTask,
-    ExecutorConfig,
-    Identity,
-    JobConfiguration,
-    JobKey,
-    PopulateJobResult,
-    ResponseCode,
-    ScheduleStatus,
-    ScheduleStatusResult,
-    TaskConfig,
-    TaskEvent,
-    TaskQuery,
-)
-
-from mock import Mock, patch
-
-
-class TestDiffCommand(AuroraClientCommandTest):
-  @classmethod
-  def setup_mock_options(cls):
-    """set up to get a mock options object."""
-    mock_options = Mock()
-    mock_options = Mock()
-    mock_options.env = None
-    mock_options.json = False
-    mock_options.bindings = {}
-    mock_options.open_browser = False
-    mock_options.rename_from = None
-    mock_options.cluster = None
-    return mock_options
-
-  @classmethod
-  def create_mock_scheduled_tasks(cls):
-    jobs = []
-    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.executorConfig = Mock(spec=ExecutorConfig)
-      job.assignedTask.task.executorConfig.data = Mock()
-      job.assignedTask.task.packages = []
-      job.assignedTask.task.owner = Identity(role='mchucarroll')
-      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
-      mockEvent = Mock(spec=TaskEvent)
-      mockEvent.timestamp = 28234726395
-      mockEvent.status = ScheduleStatus.RUNNING
-      mockEvent.message = "Hi there"
-      job.taskEvents = [mockEvent]
-      jobs.append(job)
-    return jobs
-
-  @classmethod
-  def create_status_response(cls):
-    resp = cls.create_simple_success_response()
-    resp.result.scheduleStatusResult = Mock(spec=ScheduleStatusResult)
-    resp.result.scheduleStatusResult.tasks = set(cls.create_mock_scheduled_tasks())
-    return resp
-
-  @classmethod
-  def create_failed_status_response(cls):
-    return cls.create_blank_response(ResponseCode.INVALID_REQUEST, 'No tasks found for query')
-
-  @classmethod
-  def setup_populate_job_config(cls, api):
-    populate = cls.create_simple_success_response()
-    populate.result.populateJobResult = Mock(spec=PopulateJobResult)
-    api.populateJobConfig.return_value = populate
-    populate.result.populateJobResult.populated = cls.create_mock_scheduled_tasks()
-    return populate
-
-  def test_successful_diff(self):
-    """Test the diff command."""
-    (mock_api, mock_scheduler) = self.setup_mock_api()
-    with contextlib.nested(
-        patch('twitter.aurora.client.api.SchedulerProxy', return_value=mock_scheduler),
-        patch('twitter.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS),
-        patch('subprocess.call', return_value=0),
-        patch('json.loads', return_value=Mock())) as (_, _, subprocess_patch, _):
-      mock_scheduler.getTasksStatus.return_value = self.create_status_response()
-      self.setup_populate_job_config(mock_scheduler)
-      with temporary_file() as fp:
-        fp.write(self.get_valid_config())
-        fp.flush()
-        cmd = AuroraCommandLine()
-        cmd.execute(['job', 'diff', 'west/mchucarroll/test/hello', fp.name])
-
-        # Diff should get the task status, populate a config, and run diff.
-        mock_scheduler.getTasksStatus.assert_called_with(
-            TaskQuery(jobName='hello', environment='test', owner=Identity(role='mchucarroll'),
-                statuses=set([ScheduleStatus.PENDING, ScheduleStatus.STARTING,
-                    ScheduleStatus.RUNNING, ScheduleStatus.KILLING, ScheduleStatus.ASSIGNED,
-                    ScheduleStatus.RESTARTING, ScheduleStatus.PREEMPTING])))
-        assert mock_scheduler.populateJobConfig.call_count == 1
-        assert isinstance(mock_scheduler.populateJobConfig.call_args[0][0], JobConfiguration)
-        assert (mock_scheduler.populateJobConfig.call_args[0][0].key ==
-            JobKey(environment=u'test', role=u'mchucarroll', name=u'hello'))
-        # Subprocess should have been used to invoke diff with two parameters.
-        assert subprocess_patch.call_count == 1
-        assert len(subprocess_patch.call_args[0][0]) == 3
-        assert subprocess_patch.call_args[0][0][0] == 'diff'
-
-  def test_diff_invalid_config(self):
-    """Test the diff command if the user passes a config with an error in it."""
-    mock_options = self.setup_mock_options()
-    (mock_api, mock_scheduler) = self.create_mock_api()
-    mock_scheduler.getTasksStatus.return_value = self.create_status_response()
-    self.setup_populate_job_config(mock_scheduler)
-    with contextlib.nested(
-        patch('twitter.aurora.client.api.SchedulerProxy', return_value=mock_scheduler),
-        patch('twitter.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS),
-        patch('twitter.common.app.get_options', return_value=mock_options),
-        patch('subprocess.call', return_value=0),
-        patch('json.loads', return_value=Mock())) as (
-            mock_scheduler_proxy_class,
-            mock_clusters,
-            options,
-            subprocess_patch,
-            json_patch):
-      with temporary_file() as fp:
-        fp.write(self.get_invalid_config('stupid="me"',))
-        fp.flush()
-        cmd = AuroraCommandLine()
-        result = cmd.execute(['job', 'diff', 'west/mchucarroll/test/hello', fp.name])
-        assert result == EXIT_INVALID_CONFIGURATION
-        assert mock_scheduler.getTasksStatus.call_count == 0
-        assert mock_scheduler.populateJobConfig.call_count == 0
-        assert subprocess_patch.call_count == 0
-
-  def test_diff_server_error(self):
-    """Test the diff command if the user passes a config with an error in it."""
-    mock_options = self.setup_mock_options()
-    (mock_api, mock_scheduler) = self.create_mock_api()
-    mock_scheduler.getTasksStatus.return_value = self.create_failed_status_response()
-    self.setup_populate_job_config(mock_scheduler)
-    with contextlib.nested(
-        patch('twitter.aurora.client.api.SchedulerProxy', return_value=mock_scheduler),
-        patch('twitter.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS),
-        patch('twitter.common.app.get_options', return_value=mock_options),
-        patch('subprocess.call', return_value=0),
-        patch('json.loads', return_value=Mock())) as (
-            mock_scheduler_proxy_class,
-            mock_clusters,
-            options,
-            subprocess_patch,
-            json_patch):
-      with temporary_file() as fp:
-        fp.write(self.get_valid_config())
-        fp.flush()
-        cmd = AuroraCommandLine()
-        result = cmd.execute(['job', 'diff', 'west/mchucarroll/test/hello', fp.name])
-        assert result == EXIT_INVALID_PARAMETER
-        # In this error case, we should have called the server getTasksStatus;
-        # but since it fails, we shouldn't call populateJobConfig or subprocess.
-        mock_scheduler.getTasksStatus.assert_called_with(
-            TaskQuery(jobName='hello', environment='test', owner=Identity(role='mchucarroll'),
-                statuses=set([ScheduleStatus.PENDING, ScheduleStatus.STARTING,
-                    ScheduleStatus.RUNNING, ScheduleStatus.KILLING, ScheduleStatus.ASSIGNED,
-                    ScheduleStatus.RESTARTING, ScheduleStatus.PREEMPTING])))
-        assert mock_scheduler.populateJobConfig.call_count == 0
-        assert subprocess_patch.call_count == 0


Mime
View raw message