Return-Path: X-Original-To: apmail-aurora-commits-archive@minotaur.apache.org Delivered-To: apmail-aurora-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CDF3B114CA for ; Fri, 25 Apr 2014 23:36:16 +0000 (UTC) Received: (qmail 52550 invoked by uid 500); 25 Apr 2014 23:36:16 -0000 Delivered-To: apmail-aurora-commits-archive@aurora.apache.org Received: (qmail 52530 invoked by uid 500); 25 Apr 2014 23:36:15 -0000 Mailing-List: contact commits-help@aurora.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aurora.incubator.apache.org Delivered-To: mailing list commits@aurora.incubator.apache.org Received: (qmail 52523 invoked by uid 99); 25 Apr 2014 23:36:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Apr 2014 23:36:15 +0000 X-ASF-Spam-Status: No, hits=-2000.7 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 25 Apr 2014 23:36:14 +0000 Received: (qmail 42783 invoked by uid 99); 25 Apr 2014 23:35:17 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Apr 2014 23:35:17 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C352D952975; Fri, 25 Apr 2014 23:35:16 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mchucarroll@apache.org To: commits@aurora.incubator.apache.org Message-Id: <2b33e69952ab4ecbbbf7770b76bb341c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: Fix a plugins glitch. Date: Fri, 25 Apr 2014 23:35:16 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Repository: incubator-aurora Updated Branches: refs/heads/master 6148ae397 -> 0a8f9ca84 Fix a plugins glitch. The before_dispatch method in configuration plugins is allowed to alter command line arguments, to add or remove arguments needed to support specific environments. The default implementation of plugins doesn't provide any return value for the plugin methods. For before_dispatch, this meant that the default plugin method effectively removed all command line parameters! This change just turns the default before_dispatch plugin method into an effective no-op. If the user doesn't provide a before_dispatch method, the default implementation will leave the arguments correctly unchanged. Bugs closed: aurora-362 Reviewed at https://reviews.apache.org/r/20707/ Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/0a8f9ca8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/0a8f9ca8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/0a8f9ca8 Branch: refs/heads/master Commit: 0a8f9ca84d977bf6b229c04753eeeaa0d9a31024 Parents: 6148ae3 Author: Mark Chu-Carroll Authored: Fri Apr 25 19:31:50 2014 -0400 Committer: Mark Chu-Carroll Committed: Fri Apr 25 19:31:50 2014 -0400 ---------------------------------------------------------------------- .../python/apache/aurora/client/cli/__init__.py | 2 ++ .../apache/aurora/client/cli/test_plugins.py | 26 ++++++++++++++++++++ 2 files changed, 28 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/0a8f9ca8/src/main/python/apache/aurora/client/cli/__init__.py ---------------------------------------------------------------------- diff --git a/src/main/python/apache/aurora/client/cli/__init__.py b/src/main/python/apache/aurora/client/cli/__init__.py index 8f68501..78c109d 100644 --- a/src/main/python/apache/aurora/client/cli/__init__.py +++ b/src/main/python/apache/aurora/client/cli/__init__.py @@ -147,6 +147,7 @@ class ConfigurationPlugin(object): @abstractmethod def get_options(self): """Return the set of options processed by this plugin""" + return [] @abstractmethod def before_dispatch(self, raw_args): @@ -154,6 +155,7 @@ class ConfigurationPlugin(object): Returns a potentially modified version of the command line arguments. If a ConfigurationPlugin.Error exception is thrown, it aborts command execution. """ + return raw_args @abstractmethod def before_execution(self, context): http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/0a8f9ca8/src/test/python/apache/aurora/client/cli/test_plugins.py ---------------------------------------------------------------------- diff --git a/src/test/python/apache/aurora/client/cli/test_plugins.py b/src/test/python/apache/aurora/client/cli/test_plugins.py index 0ec2ed3..2dab749 100644 --- a/src/test/python/apache/aurora/client/cli/test_plugins.py +++ b/src/test/python/apache/aurora/client/cli/test_plugins.py @@ -66,6 +66,8 @@ class BogusPlugin(ConfigurationPlugin): context.after = True raise self.Error("Oops") +class EmptyPlugin(ConfigurationPlugin): + pass class TestPlugins(AuroraClientCommandTest): @@ -152,6 +154,30 @@ class TestPlugins(AuroraClientCommandTest): assert mock_context.bogosity == "maximum" assert mock_context.after == True + def test_empty_plugins_in_create_job(self): + """Installs a plugin that doesn't implement any of the plugin methods. + Prior to AURORA-362, this would cause the client to crash with an empty + argument list. + """ + mock_context = FakeAuroraCommandContext() + with 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.INIT)) + 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() + cmd.register_plugin(EmptyPlugin()) + cmd.execute(['job', 'create', '--wait-until=RUNNING', + 'west/bozo/test/hello', fp.name]) + self.assert_create_job_called(api) + self.assert_scheduler_called(api, mock_query, 2) def mock_print(self, str): for str in str.split('\n'):