Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 1 | # Copyright 2013 OpenStack, Foundation |
| 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
| 16 | |
| 17 | from tempest.api.network import base |
armando-migliaccio | 328d45d | 2013-12-13 13:46:20 -0800 | [diff] [blame] | 18 | from tempest import test |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 19 | |
| 20 | |
| 21 | class ExtensionsTestJSON(base.BaseNetworkTest): |
| 22 | _interface = 'json' |
| 23 | |
| 24 | """ |
| 25 | Tests the following operations in the Neutron API using the REST client for |
| 26 | Neutron: |
| 27 | |
| 28 | List all available extensions |
| 29 | |
| 30 | v2.0 of the Neutron API is assumed. It is also assumed that the following |
| 31 | options are defined in the [network] section of etc/tempest.conf: |
| 32 | |
| 33 | """ |
| 34 | |
| 35 | @classmethod |
Andrea Frittoli | da4a245 | 2014-09-15 13:12:08 +0100 | [diff] [blame^] | 36 | def resource_setup(cls): |
| 37 | super(ExtensionsTestJSON, cls).resource_setup() |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 38 | |
armando-migliaccio | 328d45d | 2013-12-13 13:46:20 -0800 | [diff] [blame] | 39 | @test.attr(type='smoke') |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 40 | def test_list_show_extensions(self): |
| 41 | # List available extensions for the tenant |
| 42 | expected_alias = ['security-group', 'l3_agent_scheduler', |
| 43 | 'ext-gw-mode', 'binding', 'quotas', |
| 44 | 'agent', 'dhcp_agent_scheduler', 'provider', |
| 45 | 'router', 'extraroute', 'external-net', |
| 46 | 'allowed-address-pairs', 'extra_dhcp_opt'] |
Yoshihiro Kaneko | 0567026 | 2014-01-18 19:22:44 +0900 | [diff] [blame] | 47 | expected_alias = [ext for ext in expected_alias if |
| 48 | test.is_extension_enabled(ext, 'network')] |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 49 | actual_alias = list() |
Rohan Kanade | eeb2164 | 2014-08-14 12:00:26 +0200 | [diff] [blame] | 50 | _, extensions = self.client.list_extensions() |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 51 | list_extensions = extensions['extensions'] |
| 52 | # Show and verify the details of the available extensions |
| 53 | for ext in list_extensions: |
| 54 | ext_name = ext['name'] |
| 55 | ext_alias = ext['alias'] |
| 56 | actual_alias.append(ext['alias']) |
Rohan Kanade | eeb2164 | 2014-08-14 12:00:26 +0200 | [diff] [blame] | 57 | _, ext_details = self.client.show_extension(ext_alias) |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 58 | ext_details = ext_details['extension'] |
| 59 | |
| 60 | self.assertIsNotNone(ext_details) |
| 61 | self.assertIn('updated', ext_details.keys()) |
| 62 | self.assertIn('name', ext_details.keys()) |
| 63 | self.assertIn('description', ext_details.keys()) |
| 64 | self.assertIn('namespace', ext_details.keys()) |
| 65 | self.assertIn('links', ext_details.keys()) |
| 66 | self.assertIn('alias', ext_details.keys()) |
| 67 | self.assertEqual(ext_details['name'], ext_name) |
| 68 | self.assertEqual(ext_details['alias'], ext_alias) |
| 69 | self.assertEqual(ext_details, ext) |
| 70 | # Verify if expected extensions are present in the actual list |
armando-migliaccio | 328d45d | 2013-12-13 13:46:20 -0800 | [diff] [blame] | 71 | # of extensions returned, but only for those that have been |
| 72 | # enabled via configuration |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 73 | for e in expected_alias: |
armando-migliaccio | 328d45d | 2013-12-13 13:46:20 -0800 | [diff] [blame] | 74 | if test.is_extension_enabled(e, 'network'): |
| 75 | self.assertIn(e, actual_alias) |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 76 | |
| 77 | |
| 78 | class ExtensionsTestXML(ExtensionsTestJSON): |
| 79 | _interface = 'xml' |