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 2014/09/25 18:34:45 UTC

git commit: Skip past irrelevant jobs when running cron show command.

Repository: incubator-aurora
Updated Branches:
  refs/heads/master e3ea01062 -> 2ff98859b


Skip past irrelevant jobs when running cron show command.

Bugs closed: AURORA-753

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


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

Branch: refs/heads/master
Commit: 2ff98859b48b63f5a57060847525a46571e203b0
Parents: e3ea010
Author: Bill Farner <wf...@apache.org>
Authored: Thu Sep 25 09:29:32 2014 -0700
Committer: Bill Farner <wf...@apache.org>
Committed: Thu Sep 25 09:29:32 2014 -0700

----------------------------------------------------------------------
 .../python/apache/aurora/client/cli/cron.py     |  6 ++--
 .../apache/aurora/client/cli/test_cron.py       | 33 ++++++++++++++++++++
 2 files changed, 35 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/2ff98859/src/main/python/apache/aurora/client/cli/cron.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/cron.py b/src/main/python/apache/aurora/client/cli/cron.py
index 3416c8e..33a6f91 100644
--- a/src/main/python/apache/aurora/client/cli/cron.py
+++ b/src/main/python/apache/aurora/client/cli/cron.py
@@ -128,10 +128,8 @@ class Show(Verb):
         else:
           context.print_out('%s\t %s' % (jobkey, job.cronSchedule))
           return EXIT_OK
-      else:
-        context.print_err("No cron entry found for job %s" % jobkey)
-        return EXIT_INVALID_PARAMETER
-    return EXIT_OK
+    context.print_err("No cron entry found for job %s" % jobkey)
+    return EXIT_INVALID_PARAMETER
 
 
 class CronNoun(Noun):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/2ff98859/src/test/python/apache/aurora/client/cli/test_cron.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_cron.py b/src/test/python/apache/aurora/client/cli/test_cron.py
index f488432..e9d0b98 100644
--- a/src/test/python/apache/aurora/client/cli/test_cron.py
+++ b/src/test/python/apache/aurora/client/cli/test_cron.py
@@ -156,3 +156,36 @@ class TestCronNoun(AuroraClientCommandTest):
       assert result == EXIT_OK
       mock_scheduler_proxy.getJobs.assert_called_once_with("bozo")
       mock_print.assert_called_with("west/bozo/test/hello\t * * * * *")
+
+  def test_cron_status_multiple_jobs(self):
+    (mock_api, mock_scheduler_proxy) = self.create_mock_api()
+    with contextlib.nested(
+        patch('time.sleep'),
+        patch('apache.aurora.client.api.SchedulerProxy', return_value=mock_scheduler_proxy),
+        patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS),
+        patch('apache.aurora.client.cli.context.AuroraCommandContext.print_out')) as (
+            _, _, _, mock_print):
+      response = self.create_simple_success_response()
+      response.result = Mock()
+      response.result.getJobsResult = Mock()
+      mockjob1 = Mock()
+      mockjob1.cronSchedule = "* * * * *"
+      mockjob1.key = Mock()
+      mockjob1.key.environment = "test"
+      mockjob1.key.name = "hello2"
+      mockjob1.key.role = "bozo"
+      mockjob2 = Mock()
+      mockjob2.cronSchedule = "* * * * *"
+      mockjob2.key = Mock()
+      mockjob2.key.environment = "test"
+      mockjob2.key.name = "hello"
+      mockjob2.key.role = "bozo"
+      response.result.getJobsResult.configs = [mockjob1, mockjob2]
+      mock_scheduler_proxy.getJobs.return_value = response
+
+      cmd = AuroraCommandLine()
+      result = cmd.execute(['cron', 'show', 'west/bozo/test/hello'])
+
+      assert result == EXIT_OK
+      mock_scheduler_proxy.getJobs.assert_called_once_with("bozo")
+      mock_print.assert_called_with("west/bozo/test/hello\t * * * * *")
\ No newline at end of file