diff --git a/sahara/plugins/ambari/plugin.py b/sahara/plugins/ambari/plugin.py index 05bfe4e8..a07f7133 100644 --- a/sahara/plugins/ambari/plugin.py +++ b/sahara/plugins/ambari/plugin.py @@ -179,8 +179,13 @@ class AmbariPluginProvider(p.ProvisioningPluginBase): return edp_engine.EDPOozieEngine(cluster) return None - def get_edp_job_types(self, versions=None): - return edp_engine.EDPOozieEngine.get_supported_job_types() + def get_edp_job_types(self, versions=[]): + res = {} + for version in self.get_versions(): + if not versions or version in versions: + oozie_engine = edp_engine.EDPOozieEngine + res[version] = oozie_engine.get_supported_job_types() + return res def get_edp_config_hints(self, job_type, version): if job_type in edp_engine.EDPOozieEngine.get_supported_job_types(): diff --git a/sahara/tests/unit/plugins/ambari/test_plugin.py b/sahara/tests/unit/plugins/ambari/test_plugin.py new file mode 100644 index 00000000..1ce8e2be --- /dev/null +++ b/sahara/tests/unit/plugins/ambari/test_plugin.py @@ -0,0 +1,39 @@ +# Copyright (c) 2015 Mirantis Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from sahara.plugins.ambari import plugin +from sahara.tests.unit import base as test_base + + +class TestPlugin(test_base.SaharaTestCase): + def setUp(self): + self.plugin = plugin.AmbariPluginProvider() + super(TestPlugin, self).setUp() + + def test_job_types(self): + self.assertEqual({ + '2.2': [ + 'Hive', 'Java', 'MapReduce', 'MapReduce.Streaming', + 'Pig', 'Shell'], + '2.3': [ + 'Hive', 'Java', 'MapReduce', 'MapReduce.Streaming', + 'Pig', 'Shell'] + }, self.plugin.get_edp_job_types()) + + self.assertEqual({ + '2.3': [ + 'Hive', 'Java', 'MapReduce', 'MapReduce.Streaming', + 'Pig', 'Shell'], + }, self.plugin.get_edp_job_types(versions=['2.3']))