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 2015/05/01 18:22:35 UTC
aurora git commit: Handle UpdateConfigError when starting a job
update.
Repository: aurora
Updated Branches:
refs/heads/master f9b60c6a2 -> f3da5aea2
Handle UpdateConfigError when starting a job update.
Bugs closed: AURORA-1299
Reviewed at https://reviews.apache.org/r/33740/
Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/f3da5aea
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/f3da5aea
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/f3da5aea
Branch: refs/heads/master
Commit: f3da5aea2230787c1809749954ff1c27ae08785f
Parents: f9b60c6
Author: Bill Farner <wf...@apache.org>
Authored: Fri May 1 09:22:32 2015 -0700
Committer: Bill Farner <wf...@apache.org>
Committed: Fri May 1 09:22:32 2015 -0700
----------------------------------------------------------------------
src/main/python/apache/aurora/client/cli/update.py | 8 +++++++-
.../python/apache/aurora/client/cli/test_supdate.py | 16 ++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aurora/blob/f3da5aea/src/main/python/apache/aurora/client/cli/update.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/update.py b/src/main/python/apache/aurora/client/cli/update.py
index 9f190a6..8296db5 100644
--- a/src/main/python/apache/aurora/client/cli/update.py
+++ b/src/main/python/apache/aurora/client/cli/update.py
@@ -19,10 +19,12 @@ import json
import textwrap
from collections import namedtuple
+from apache.aurora.client.api import AuroraClientAPI
from apache.aurora.client.base import combine_messages, get_update_page
from apache.aurora.client.cli import (
EXIT_API_ERROR,
EXIT_COMMAND_FAILURE,
+ EXIT_INVALID_CONFIGURATION,
EXIT_INVALID_PARAMETER,
EXIT_OK,
Noun,
@@ -155,7 +157,11 @@ class StartUpdate(Verb):
"Cron jobs may only be updated with \"aurora cron schedule\" command")
api = context.get_api(config.cluster())
- resp = api.start_job_update(config, context.options.message, instances)
+ try:
+ resp = api.start_job_update(config, context.options.message, instances)
+ except AuroraClientAPI.UpdateConfigError as e:
+ raise context.CommandError(EXIT_INVALID_CONFIGURATION, e.message)
+
context.log_response_and_raise(resp, err_code=EXIT_API_ERROR,
err_msg="Failed to start update due to error:")
http://git-wip-us.apache.org/repos/asf/aurora/blob/f3da5aea/src/test/python/apache/aurora/client/cli/test_supdate.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_supdate.py b/src/test/python/apache/aurora/client/cli/test_supdate.py
index ccbcae6..6fb1f71 100644
--- a/src/test/python/apache/aurora/client/cli/test_supdate.py
+++ b/src/test/python/apache/aurora/client/cli/test_supdate.py
@@ -90,6 +90,7 @@ class TestStartUpdate(AuroraClientCommandTest):
@classmethod
def create_mock_config(cls, is_cron=False):
+ # TODO(wfarner): Consider using a real AuroraConfig object for this.
mock_config = create_autospec(spec=AuroraConfig, spec_set=True, instance=True)
raw_config = Job(cron_schedule='something' if is_cron else Empty)
mock_config.raw = Mock(return_value=raw_config)
@@ -167,6 +168,21 @@ class TestStartUpdate(AuroraClientCommandTest):
assert self._fake_context.get_out() == ["Noop update."]
assert self._fake_context.get_err() == []
+ def test_update_pulse_interval_too_small(self):
+ mock_config = self.create_mock_config()
+ self._fake_context.get_job_config = Mock(return_value=mock_config)
+
+ error = Context.CommandError(100, 'something failed')
+ self._mock_api.start_job_update.side_effect = error
+
+ with pytest.raises(Context.CommandError) as e:
+ self._command.execute(self._fake_context)
+
+ assert e.value == error
+ assert self._mock_api.start_job_update.mock_calls == [
+ call(ANY, None, None)
+ ]
+
class TestListUpdates(AuroraClientCommandTest):