aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mchucarr...@apache.org
Subject git commit: Fix error when "job create" is called with "--open-browser".
Date Mon, 27 Oct 2014 15:10:41 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 3778330cd -> ece8f4ec7


Fix error when "job create" is called with "--open-browser".

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


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

Branch: refs/heads/master
Commit: ece8f4ec7bb41a33ea56d4b3b5953112e6a374fe
Parents: 3778330
Author: Mark Chu-Carroll <mchucarroll@twopensource.com>
Authored: Mon Oct 27 11:08:12 2014 -0400
Committer: Mark Chu-Carroll <mchucarroll@twitter.com>
Committed: Mon Oct 27 11:08:12 2014 -0400

----------------------------------------------------------------------
 .../python/apache/aurora/client/cli/jobs.py     |  2 +-
 .../apache/aurora/client/cli/test_create.py     | 29 +++++++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/ece8f4ec/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 625cb80..b4d9360 100644
--- a/src/main/python/apache/aurora/client/cli/jobs.py
+++ b/src/main/python/apache/aurora/client/cli/jobs.py
@@ -122,7 +122,7 @@ class CreateJobCommand(Verb):
     context.check_and_log_response(resp, err_code=EXIT_COMMAND_FAILURE,
                                    err_msg="Job creation failed due to error:")
     if context.options.open_browser:
-      context.open_job_page(api, config)
+      context.open_job_page(api, context.options.jobspec)
     if context.options.wait_until == "RUNNING":
       JobMonitor(api.scheduler_proxy, config.job_key()).wait_until(JobMonitor.running_or_finished)
     elif context.options.wait_until == "FINISHED":

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/ece8f4ec/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 8a5aef8..a56d8b9 100644
--- a/src/test/python/apache/aurora/client/cli/test_create.py
+++ b/src/test/python/apache/aurora/client/cli/test_create.py
@@ -123,13 +123,40 @@ class TestClientCreateCommand(AuroraClientCommandTest):
         fp.flush()
         cmd = AuroraCommandLine()
         cmd.execute(['job', 'create', '--wait-until=RUNNING', 'west/bozo/test/hello',
-            fp.name])
+                     fp.name])
 
       # Now check that the right API calls got made.
       # Check that create_job was called exactly once, with an AuroraConfig parameter.
       self.assert_create_job_called(api)
       self.assert_scheduler_called(api, mock_query, 2)
 
+  def test_simple_successful_create_job_open_page(self):
+    mock_context = FakeAuroraCommandContext()
+    with contextlib.nested(
+        # TODO(maxim): Patching threading.Event with all possible namespace/patch/mock
+        #              combinations did not produce the desired effect. Investigate why (AURORA-510)
+        patch('threading._Event.wait'),
+        patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context)):
+      mock_query = self.create_mock_query()
+      mock_context.add_expected_status_query_result(
+        self.create_mock_status_query_result(ScheduleStatus.PENDING))
+      mock_context.add_expected_status_query_result(
+        self.create_mock_status_query_result(ScheduleStatus.RUNNING))
+      api = mock_context.get_api('west')
+      api.create_job.return_value = self.get_createjob_response()
+      with temporary_file() as fp:
+        fp.write(self.get_valid_config())
+        fp.flush()
+        cmd = AuroraCommandLine()
+        result = cmd.execute(['job', 'create', '--wait-until=RUNNING', '--open-browser',
+                     'west/bozo/test/hello',
+            fp.name])
+        assert result == EXIT_OK
+
+      self.assert_create_job_called(api)
+      self.assert_scheduler_called(api, mock_query, 2)
+      assert mock_context.showed_urls == ["http://something_or_other/scheduler/bozo/test/hello"]
+
   def test_create_job_fail_and_write_log(self):
     """Check that when an unknown error occurs during command execution,
     the command-line framework catches it, and writes out an error log file


Mime
View raw message