Merge "Added test to check list/show extensions-neutron"
diff --git a/tempest/api/network/test_extensions.py b/tempest/api/network/test_extensions.py
new file mode 100644
index 0000000..1b27d1b
--- /dev/null
+++ b/tempest/api/network/test_extensions.py
@@ -0,0 +1,79 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 OpenStack, Foundation
+# 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.api.network import base
+from tempest.test import attr
+
+
+class ExtensionsTestJSON(base.BaseNetworkTest):
+ _interface = 'json'
+
+ """
+ Tests the following operations in the Neutron API using the REST client for
+ Neutron:
+
+ List all available extensions
+
+ v2.0 of the Neutron API is assumed. It is also assumed that the following
+ options are defined in the [network] section of etc/tempest.conf:
+
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(ExtensionsTestJSON, cls).setUpClass()
+
+ @attr(type='smoke')
+ def test_list_show_extensions(self):
+ # List available extensions for the tenant
+ expected_alias = ['security-group', 'l3_agent_scheduler',
+ 'ext-gw-mode', 'binding', 'quotas',
+ 'agent', 'dhcp_agent_scheduler', 'provider',
+ 'router', 'extraroute', 'external-net',
+ 'allowed-address-pairs', 'extra_dhcp_opt']
+ actual_alias = list()
+ resp, extensions = self.client.list_extensions()
+ self.assertEqual('200', resp['status'])
+ list_extensions = extensions['extensions']
+ # Show and verify the details of the available extensions
+ for ext in list_extensions:
+ ext_name = ext['name']
+ ext_alias = ext['alias']
+ actual_alias.append(ext['alias'])
+ resp, ext_details = self.client.show_extension_details(ext_alias)
+ self.assertEqual('200', resp['status'])
+ ext_details = ext_details['extension']
+
+ self.assertIsNotNone(ext_details)
+ self.assertIn('updated', ext_details.keys())
+ self.assertIn('name', ext_details.keys())
+ self.assertIn('description', ext_details.keys())
+ self.assertIn('namespace', ext_details.keys())
+ self.assertIn('links', ext_details.keys())
+ self.assertIn('alias', ext_details.keys())
+ self.assertEqual(ext_details['name'], ext_name)
+ self.assertEqual(ext_details['alias'], ext_alias)
+ self.assertEqual(ext_details, ext)
+ # Verify if expected extensions are present in the actual list
+ # of extensions returned
+ for e in expected_alias:
+ self.assertIn(e, actual_alias)
+
+
+class ExtensionsTestXML(ExtensionsTestJSON):
+ _interface = 'xml'
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index 369dd81..c2d701d 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -598,3 +598,15 @@
health_monitor_id)
resp, body = self.delete(uri, headers=self.headers)
return resp, body
+
+ def list_extensions(self):
+ uri = '%s/extensions' % (self.uri_prefix)
+ resp, body = self.get(uri, self.headers)
+ body = json.loads(body)
+ return resp, body
+
+ def show_extension_details(self, ext_alias):
+ uri = '%s/extensions/%s' % (self.uri_prefix, ext_alias)
+ resp, body = self.get(uri, headers=self.headers)
+ body = json.loads(body)
+ return resp, body
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
index a9b5512..1523ed0 100755
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -428,6 +428,19 @@
health_monitor_id)
return self.delete(uri, self.headers)
+ def list_extensions(self):
+ url = '%s/extensions' % (self.uri_prefix)
+ resp, body = self.get(url, self.headers)
+ extensions = self._parse_array(etree.fromstring(body))
+ extensions = {"extensions": extensions}
+ return resp, extensions
+
+ def show_extension_details(self, ext_alias):
+ uri = '%s/extensions/%s' % (self.uri_prefix, str(ext_alias))
+ resp, body = self.get(uri, self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
def _root_tag_fetcher_and_xml_to_json_parse(xml_returned_body):
body = ET.fromstring(xml_returned_body)