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 |
| 16 | from tempest.common.utils import data_utils |
| 17 | from tempest import config |
Andrea Frittoli (andreaf) | db9672e | 2016-02-23 14:07:24 -0500 | [diff] [blame] | 18 | from tempest.lib import exceptions as lib_exc |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 19 | from tempest import test |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 20 | |
| 21 | CONF = config.CONF |
| 22 | |
| 23 | |
| 24 | class SubnetPoolsTestJSON(base.BaseNetworkTest): |
Ken'ichi Ohmichi | e03bea9 | 2015-11-19 07:45:58 +0000 | [diff] [blame] | 25 | """Tests the following operations in the subnetpools API: |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 26 | |
| 27 | Create a subnet pool. |
| 28 | Update a subnet pool. |
| 29 | Delete a subnet pool. |
| 30 | Lists subnet pool. |
| 31 | Show subnet pool details. |
| 32 | |
Russell Bryant | 2f7aaaa | 2016-03-04 13:35:37 -0500 | [diff] [blame^] | 33 | 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] | 34 | options mentioned in the [network-feature-enabled] section and |
| 35 | default_network option mentioned in the [network] section of |
| 36 | etc/tempest.conf: |
| 37 | |
| 38 | """ |
| 39 | |
| 40 | @classmethod |
| 41 | def skip_checks(cls): |
| 42 | super(SubnetPoolsTestJSON, cls).skip_checks() |
Russell Bryant | 2f7aaaa | 2016-03-04 13:35:37 -0500 | [diff] [blame^] | 43 | if not test.is_extension_enabled('subnet_allocation', 'network'): |
| 44 | msg = "subnet_allocation extension not enabled." |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 45 | raise cls.skipException(msg) |
| 46 | |
| 47 | @test.attr(type='smoke') |
| 48 | @test.idempotent_id('62595970-ab1c-4b7f-8fcc-fddfe55e9811') |
| 49 | def test_create_list_show_update_delete_subnetpools(self): |
| 50 | subnetpool_name = data_utils.rand_name('subnetpools') |
| 51 | # create subnet pool |
| 52 | prefix = CONF.network.default_network |
Ken'ichi Ohmichi | 3629591 | 2016-01-06 01:24:34 +0000 | [diff] [blame] | 53 | body = self.subnetpools_client.create_subnetpool(name=subnetpool_name, |
| 54 | prefixes=prefix) |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 55 | subnetpool_id = body["subnetpool"]["id"] |
| 56 | self.addCleanup(self._cleanup_subnetpools, subnetpool_id) |
| 57 | self.assertEqual(subnetpool_name, body["subnetpool"]["name"]) |
| 58 | # get detail about subnet pool |
Ken'ichi Ohmichi | 3629591 | 2016-01-06 01:24:34 +0000 | [diff] [blame] | 59 | body = self.subnetpools_client.show_subnetpool(subnetpool_id) |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 60 | self.assertEqual(subnetpool_name, body["subnetpool"]["name"]) |
| 61 | # update the subnet pool |
| 62 | subnetpool_name = data_utils.rand_name('subnetpools_update') |
Ken'ichi Ohmichi | 3629591 | 2016-01-06 01:24:34 +0000 | [diff] [blame] | 63 | body = self.subnetpools_client.update_subnetpool(subnetpool_id, |
| 64 | name=subnetpool_name) |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 65 | self.assertEqual(subnetpool_name, body["subnetpool"]["name"]) |
| 66 | # delete subnet pool |
Ken'ichi Ohmichi | 3629591 | 2016-01-06 01:24:34 +0000 | [diff] [blame] | 67 | body = self.subnetpools_client.delete_subnetpool(subnetpool_id) |
Ken'ichi Ohmichi | f3f8aba | 2015-12-15 08:11:00 +0000 | [diff] [blame] | 68 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | 3629591 | 2016-01-06 01:24:34 +0000 | [diff] [blame] | 69 | self.subnetpools_client.show_subnetpool, |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 70 | subnetpool_id) |
| 71 | |
| 72 | def _cleanup_subnetpools(self, subnetpool_id): |
| 73 | # this is used to cleanup the resources |
| 74 | try: |
Ken'ichi Ohmichi | 3629591 | 2016-01-06 01:24:34 +0000 | [diff] [blame] | 75 | self.subnetpools_client.delete_subnetpool(subnetpool_id) |
piyush110786 | 48e35d5 | 2015-09-24 12:56:43 +0530 | [diff] [blame] | 76 | except lib_exc.NotFound: |
| 77 | pass |