You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by me...@apache.org on 2017/05/03 05:02:47 UTC
aurora git commit: AURORA-1915 Add automatic browser tab open feature
for aurora update start
Repository: aurora
Updated Branches:
refs/heads/master 6f9383c30 -> 8a6e01c34
AURORA-1915 Add automatic browser tab open feature for aurora update start
Aurora client automatically opens a browser tab following `aurora job create` and `aurora cron schedule` commands. This patch provide similar functionality for `aurora update start`.
Reviewed at https://reviews.apache.org/r/58265/
Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/8a6e01c3
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/8a6e01c3
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/8a6e01c3
Branch: refs/heads/master
Commit: 8a6e01c348319c7f94f8ed482df0bc1eeec99e50
Parents: 6f9383c
Author: Takuya Kuwahara <ta...@gmail.com>
Authored: Tue May 2 21:54:27 2017 -0700
Committer: Mehrdad Nurolahzade <mn...@twitter.com>
Committed: Tue May 2 21:54:27 2017 -0700
----------------------------------------------------------------------
.../python/apache/aurora/client/cli/update.py | 4 ++++
.../apache/aurora/client/cli/test_supdate.py | 19 +++++++++++++++++++
2 files changed, 23 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aurora/blob/8a6e01c3/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 c701196..7abc5d1 100644
--- a/src/main/python/apache/aurora/client/cli/update.py
+++ b/src/main/python/apache/aurora/client/cli/update.py
@@ -19,6 +19,7 @@ import json
import textwrap
import time
import uuid
+import webbrowser
from collections import namedtuple
from apache.aurora.client.api import AuroraClientAPI
@@ -210,6 +211,9 @@ class StartUpdate(Verb):
resp.result.startJobUpdateResult.key.id)
context.print_out(self.UPDATE_MSG_TEMPLATE % url)
+ if context.options.open_browser:
+ webbrowser.open_new_tab(url)
+
if context.options.wait:
return wait_for_update(context, self._clock, api, update_key, update_state_to_err_code)
else:
http://git-wip-us.apache.org/repos/asf/aurora/blob/8a6e01c3/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 92ab375..8b90885 100644
--- a/src/test/python/apache/aurora/client/cli/test_supdate.py
+++ b/src/test/python/apache/aurora/client/cli/test_supdate.py
@@ -102,6 +102,7 @@ class TestStartUpdate(AuroraClientCommandTest):
self._fake_context.set_options(self._mock_options)
self._mock_api = self._fake_context.get_api('UNUSED')
self._formatter = Mock(spec=DiffFormatter)
+ super(TestStartUpdate, self).setUp()
@classmethod
def create_mock_config(cls, is_cron=False):
@@ -351,6 +352,24 @@ class TestStartUpdate(AuroraClientCommandTest):
assert e.value == error
assert self._mock_api.start_job_update.mock_calls == [call(ANY, None, None, ANY)]
+ def test_start_update_and_open_page(self):
+ mock_config = self.create_mock_config()
+ self._fake_context.get_job_config = Mock(return_value=mock_config)
+ self._mock_options.open_browser = True
+
+ resp = self.create_simple_success_response()
+ resp.result = Result(startJobUpdateResult=StartJobUpdateResult(
+ key=JobUpdateKey(job=JobKey(role="role", environment="env", name="name"), id="id")))
+ self._mock_api.start_job_update.return_value = resp
+
+ with patch('apache.aurora.client.cli.update.DiffFormatter') as formatter:
+ formatter.return_value = self._formatter
+ assert self._command.execute(self._fake_context) == EXIT_OK
+
+ assert self.mock_webbrowser.mock_calls == [
+ call('http://something_or_other/scheduler/role/env/name/update/id')
+ ]
+
class TestListUpdates(AuroraClientCommandTest):