Merge "Use service catalog_type when getting the heat/glance clients"
diff --git a/tempest/api/data_processing/test_plugins.py b/tempest/api/data_processing/test_plugins.py
new file mode 100644
index 0000000..3b941d8
--- /dev/null
+++ b/tempest/api/data_processing/test_plugins.py
@@ -0,0 +1,58 @@
+# Copyright (c) 2013 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 tempest.api.data_processing import base as dp_base
+from tempest.test import attr
+
+
+class PluginsTest(dp_base.BaseDataProcessingTest):
+    def _list_all_plugin_names(self):
+        """Returns all enabled plugin names.
+
+        It ensures response status and main plugins availability.
+        """
+        resp, plugins = self.client.list_plugins()
+
+        self.assertEqual(200, resp.status)
+
+        plugins_names = list([plugin['name'] for plugin in plugins])
+        self.assertIn('vanilla', plugins_names)
+        self.assertIn('hdp', plugins_names)
+
+        return plugins_names
+
+    @attr(type='smoke')
+    def test_plugin_list(self):
+        self._list_all_plugin_names()
+
+    @attr(type='smoke')
+    def test_plugin_get(self):
+        for plugin_name in self._list_all_plugin_names():
+            resp, plugin = self.client.get_plugin(plugin_name)
+
+            self.assertEqual(200, resp.status)
+            self.assertEqual(plugin_name, plugin['name'])
+
+            for plugin_version in plugin['versions']:
+                resp, detailed_plugin = self.client.get_plugin(plugin_name,
+                                                               plugin_version)
+
+                self.assertEqual(200, resp.status)
+                self.assertEqual(plugin_name, detailed_plugin['name'])
+
+                # check that required image tags contains name and version
+                image_tags = detailed_plugin['required_image_tags']
+                self.assertIn(plugin_name, image_tags)
+                self.assertIn(plugin_version, image_tags)
diff --git a/tempest/services/data_processing/v1_1/client.py b/tempest/services/data_processing/v1_1/client.py
index db21201..e96b44b 100644
--- a/tempest/services/data_processing/v1_1/client.py
+++ b/tempest/services/data_processing/v1_1/client.py
@@ -77,3 +77,17 @@
 
         uri = "node-group-templates/%s" % tmpl_id
         return self.delete(uri)
+
+    def list_plugins(self):
+        """List all enabled plugins."""
+
+        uri = 'plugins'
+        return self._request_and_parse(self.get, uri, 'plugins')
+
+    def get_plugin(self, plugin_name, plugin_version=None):
+        """Returns the details of a single plugin."""
+
+        uri = "plugins/%s" % plugin_name
+        if plugin_version:
+            uri += '/%s' % plugin_version
+        return self._request_and_parse(self.get, uri, 'plugin')
diff --git a/tempest/tests/negative/__init__.py b/tempest/tests/negative/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/tests/negative/__init__.py
diff --git a/tempest/tests/negative/test_generate_json.py b/tempest/tests/negative/test_generate_json.py
new file mode 100644
index 0000000..a0aa088
--- /dev/null
+++ b/tempest/tests/negative/test_generate_json.py
@@ -0,0 +1,53 @@
+# Copyright 2014 Deutsche Telekom AG
+# All Rights Reserved.
+#
+#    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 tempest.common import generate_json as gen
+import tempest.test
+
+
+class TestGenerateJson(tempest.test.BaseTestCase):
+
+    fake_input_str = {"type": "string",
+                      "minLength": 2,
+                      "maxLength": 8,
+                      'results': {'gen_number': 404}}
+
+    fake_input_int = {"type": "integer",
+                      "maximum": 255,
+                      "minimum": 1}
+
+    fake_input_obj = {"type": "object",
+                      "properties": {"minRam": {"type": "integer"},
+                                     "diskName": {"type": "string"},
+                                     "maxRam": {"type": "integer", }
+                                     }
+                      }
+
+    def _validate_result(self, data):
+        self.assertTrue(isinstance(data, list))
+        for t in data:
+            self.assertTrue(isinstance(t, tuple))
+
+    def test_generate_invalid_string(self):
+        result = gen.generate_invalid(self.fake_input_str)
+        self._validate_result(result)
+
+    def test_generate_invalid_integer(self):
+        result = gen.generate_invalid(self.fake_input_int)
+        self._validate_result(result)
+
+    def test_generate_invalid_obj(self):
+        result = gen.generate_invalid(self.fake_input_obj)
+        self._validate_result(result)
diff --git a/tempest/tests/negative/test_negative_auto_test.py b/tempest/tests/negative/test_negative_auto_test.py
new file mode 100644
index 0000000..4c59383
--- /dev/null
+++ b/tempest/tests/negative/test_negative_auto_test.py
@@ -0,0 +1,64 @@
+# Copyright 2014 Deutsche Telekom AG
+# All Rights Reserved.
+#
+#    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.
+
+import mock
+
+import tempest.test as test
+
+
+class TestNegativeAutoTest(test.BaseTestCase):
+    # Fake entries
+    _interface = 'json'
+    _service = 'compute'
+
+    fake_input_desc = {"name": "list-flavors-with-detail",
+                       "http-method": "GET",
+                       "url": "flavors/detail",
+                       "json-schema": {"type": "object",
+                                      "properties":
+                                      {"minRam": {"type": "integer"},
+                                       "minDisk": {"type": "integer"}}
+                                       },
+                       "resources": ["flavor", "volume", "image"]
+                       }
+
+    def _check_prop_entries(self, result, entry):
+        entries = [a for a in result if entry in a[0]]
+        self.assertIsNotNone(entries)
+        self.assertIs(len(entries), 2)
+        for entry in entries:
+            self.assertIsNotNone(entry[1]['schema'])
+
+    def _check_resource_entries(self, result, entry):
+        entries = [a for a in result if entry in a[0]]
+        self.assertIsNotNone(entries)
+        self.assertIs(len(entries), 3)
+        for entry in entries:
+            self.assertIsNotNone(entry[1]['resource'])
+
+    @mock.patch('tempest.test.NegativeAutoTest.load_schema')
+    def test_generate_scenario(self, open_mock):
+        open_mock.return_value = self.fake_input_desc
+        scenarios = test.NegativeAutoTest.\
+            generate_scenario(None)
+
+        self.assertIsInstance(scenarios, list)
+        for scenario in scenarios:
+            self.assertIsInstance(scenario, tuple)
+            self.assertIsInstance(scenario[0], str)
+            self.assertIsInstance(scenario[1], dict)
+        self._check_prop_entries(scenarios, "prop_minRam")
+        self._check_prop_entries(scenarios, "prop_minDisk")
+        self._check_resource_entries(scenarios, "inv_res")