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 |
Ken'ichi Ohmichi | 53b9a63 | 2017-01-27 18:04:39 -0800 | [diff] [blame] | 18 | from tempest.lib import decorators |
armando-migliaccio | 328d45d | 2013-12-13 13:46:20 -0800 | [diff] [blame] | 19 | from tempest import test |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 20 | |
| 21 | |
| 22 | class ExtensionsTestJSON(base.BaseNetworkTest): |
Ken'ichi Ohmichi | e03bea9 | 2015-11-19 07:45:58 +0000 | [diff] [blame] | 23 | """Tests the following operations in the Neutron API: |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 24 | |
| 25 | List all available extensions |
| 26 | |
Tianbiao Qi | 9f1e8d4 | 2016-09-29 11:08:21 +0800 | [diff] [blame] | 27 | v2.0 of the Neutron API is assumed. It is also assumed that api-extensions |
| 28 | option is defined in the [network-feature-enabled] section of |
| 29 | etc/tempest.conf. |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 30 | """ |
| 31 | |
armando-migliaccio | 328d45d | 2013-12-13 13:46:20 -0800 | [diff] [blame] | 32 | @test.attr(type='smoke') |
Ken'ichi Ohmichi | 53b9a63 | 2017-01-27 18:04:39 -0800 | [diff] [blame] | 33 | @decorators.idempotent_id('ef28c7e6-e646-4979-9d67-deb207bc5564') |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 34 | def test_list_show_extensions(self): |
Sean Dague | ed6e586 | 2016-04-04 10:49:13 -0400 | [diff] [blame] | 35 | # List available extensions for the project |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 36 | expected_alias = ['security-group', 'l3_agent_scheduler', |
| 37 | 'ext-gw-mode', 'binding', 'quotas', |
| 38 | 'agent', 'dhcp_agent_scheduler', 'provider', |
| 39 | 'router', 'extraroute', 'external-net', |
Takeaki Matsumoto | abeb07f | 2015-08-11 20:52:53 +0900 | [diff] [blame] | 40 | 'allowed-address-pairs', 'extra_dhcp_opt', |
Sean Dague | 42b9e87 | 2015-09-02 06:31:54 -0400 | [diff] [blame] | 41 | 'metering', 'dvr'] |
Yoshihiro Kaneko | 0567026 | 2014-01-18 19:22:44 +0900 | [diff] [blame] | 42 | expected_alias = [ext for ext in expected_alias if |
| 43 | test.is_extension_enabled(ext, 'network')] |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 44 | actual_alias = list() |
Ken'ichi Ohmichi | 52bb812 | 2016-01-26 01:43:06 +0000 | [diff] [blame] | 45 | extensions = self.network_extensions_client.list_extensions() |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 46 | list_extensions = extensions['extensions'] |
| 47 | # Show and verify the details of the available extensions |
| 48 | for ext in list_extensions: |
| 49 | ext_name = ext['name'] |
| 50 | ext_alias = ext['alias'] |
| 51 | actual_alias.append(ext['alias']) |
Ken'ichi Ohmichi | 52bb812 | 2016-01-26 01:43:06 +0000 | [diff] [blame] | 52 | ext_details = self.network_extensions_client.show_extension( |
| 53 | ext_alias) |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 54 | ext_details = ext_details['extension'] |
| 55 | |
| 56 | self.assertIsNotNone(ext_details) |
| 57 | self.assertIn('updated', ext_details.keys()) |
| 58 | self.assertIn('name', ext_details.keys()) |
| 59 | self.assertIn('description', ext_details.keys()) |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 60 | self.assertIn('links', ext_details.keys()) |
| 61 | self.assertIn('alias', ext_details.keys()) |
| 62 | self.assertEqual(ext_details['name'], ext_name) |
| 63 | self.assertEqual(ext_details['alias'], ext_alias) |
| 64 | self.assertEqual(ext_details, ext) |
| 65 | # Verify if expected extensions are present in the actual list |
armando-migliaccio | 328d45d | 2013-12-13 13:46:20 -0800 | [diff] [blame] | 66 | # of extensions returned, but only for those that have been |
| 67 | # enabled via configuration |
Nayna Patel | d0b02ae | 2013-09-04 10:09:08 +0000 | [diff] [blame] | 68 | for e in expected_alias: |
armando-migliaccio | 328d45d | 2013-12-13 13:46:20 -0800 | [diff] [blame] | 69 | if test.is_extension_enabled(e, 'network'): |
| 70 | self.assertIn(e, actual_alias) |