piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 1 | # Copyright 2015 GlobalLogic. All rights reserved. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | from tempest.api.network import base |
Andrea Frittoli | cd36841 | 2017-08-14 21:37:56 +0100 | [diff] [blame] | 16 | from tempest.common import utils |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 17 | from tempest import config |
Ken'ichi Ohmichi | f50e4df | 2017-03-10 10:52:53 -0800 | [diff] [blame] | 18 | from tempest.lib.common.utils import data_utils |
Jordan Pittier | 9e227c5 | 2016-02-09 14:35:18 +0100 | [diff] [blame] | 19 | from tempest.lib.common.utils import test_utils |
Ken'ichi Ohmichi | 53b9a63 | 2017-01-27 18:04:39 -0800 | [diff] [blame] | 20 | from tempest.lib import decorators |
Andrea Frittoli (andreaf) | db9672e | 2016-02-23 14:07:24 -0500 | [diff] [blame] | 21 | from tempest.lib import exceptions as lib_exc |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 22 | |
| 23 | CONF = config.CONF |
| 24 | |
| 25 | |
| 26 | class SubnetPoolsTestJSON(base.BaseNetworkTest): |
Ken'ichi Ohmichi | e03bea9 | 2015-11-19 07:45:58 +0000 | [diff] [blame] | 27 | """Tests the following operations in the subnetpools API: |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 28 | |
| 29 | Create a subnet pool. |
| 30 | Update a subnet pool. |
| 31 | Delete a subnet pool. |
| 32 | Lists subnet pool. |
| 33 | Show subnet pool details. |
| 34 | |
Russell Bryant | 2f7aaaa | 2016-03-04 13:35:37 -0500 | [diff] [blame] | 35 | v2.0 of the Neutron API is assumed. It is assumed that subnet_allocation |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 36 | options mentioned in the [network-feature-enabled] section and |
| 37 | default_network option mentioned in the [network] section of |
| 38 | etc/tempest.conf: |
| 39 | |
| 40 | """ |
| 41 | |
| 42 | @classmethod |
| 43 | def skip_checks(cls): |
| 44 | super(SubnetPoolsTestJSON, cls).skip_checks() |
Andrea Frittoli | cd36841 | 2017-08-14 21:37:56 +0100 | [diff] [blame] | 45 | if not utils.is_extension_enabled('subnet_allocation', 'network'): |
Russell Bryant | 2f7aaaa | 2016-03-04 13:35:37 -0500 | [diff] [blame] | 46 | msg = "subnet_allocation extension not enabled." |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 47 | raise cls.skipException(msg) |
| 48 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 49 | @decorators.attr(type='smoke') |
Ken'ichi Ohmichi | 53b9a63 | 2017-01-27 18:04:39 -0800 | [diff] [blame] | 50 | @decorators.idempotent_id('62595970-ab1c-4b7f-8fcc-fddfe55e9811') |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 51 | def test_create_list_show_update_delete_subnetpools(self): |
zhufl | 05fc4f7 | 2020-04-26 09:13:54 +0800 | [diff] [blame] | 52 | """Test create/list/show/update/delete of subnet pools""" |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 53 | subnetpool_name = data_utils.rand_name('subnetpools') |
| 54 | # create subnet pool |
| 55 | prefix = CONF.network.default_network |
Ken'ichi Ohmichi | 3629591 | 2016-01-06 01:24:34 +0000 | [diff] [blame] | 56 | body = self.subnetpools_client.create_subnetpool(name=subnetpool_name, |
| 57 | prefixes=prefix) |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 58 | subnetpool_id = body["subnetpool"]["id"] |
Jordan Pittier | 9e227c5 | 2016-02-09 14:35:18 +0100 | [diff] [blame] | 59 | self.addCleanup(test_utils.call_and_ignore_notfound_exc, |
| 60 | self.subnetpools_client.delete_subnetpool, |
| 61 | subnetpool_id) |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 62 | self.assertEqual(subnetpool_name, body["subnetpool"]["name"]) |
| 63 | # get detail about subnet pool |
Ken'ichi Ohmichi | 3629591 | 2016-01-06 01:24:34 +0000 | [diff] [blame] | 64 | body = self.subnetpools_client.show_subnetpool(subnetpool_id) |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 65 | self.assertEqual(subnetpool_name, body["subnetpool"]["name"]) |
| 66 | # update the subnet pool |
| 67 | subnetpool_name = data_utils.rand_name('subnetpools_update') |
Ken'ichi Ohmichi | 3629591 | 2016-01-06 01:24:34 +0000 | [diff] [blame] | 68 | body = self.subnetpools_client.update_subnetpool(subnetpool_id, |
| 69 | name=subnetpool_name) |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 70 | self.assertEqual(subnetpool_name, body["subnetpool"]["name"]) |
| 71 | # delete subnet pool |
Ken'ichi Ohmichi | 3629591 | 2016-01-06 01:24:34 +0000 | [diff] [blame] | 72 | body = self.subnetpools_client.delete_subnetpool(subnetpool_id) |
Ken'ichi Ohmichi | f3f8aba | 2015-12-15 08:11:00 +0000 | [diff] [blame] | 73 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | 3629591 | 2016-01-06 01:24:34 +0000 | [diff] [blame] | 74 | self.subnetpools_client.show_subnetpool, |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 75 | subnetpool_id) |