blob: 48603ed57013fc8cb7a8f79f0343527741e392e8 [file] [log] [blame]
piyush11078648e35d52015-09-24 12:56:43 +05301# 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
15from tempest.api.network import base
Andrea Frittolicd368412017-08-14 21:37:56 +010016from tempest.common import utils
piyush11078648e35d52015-09-24 12:56:43 +053017from tempest import config
Ken'ichi Ohmichif50e4df2017-03-10 10:52:53 -080018from tempest.lib.common.utils import data_utils
Jordan Pittier9e227c52016-02-09 14:35:18 +010019from tempest.lib.common.utils import test_utils
Ken'ichi Ohmichi53b9a632017-01-27 18:04:39 -080020from tempest.lib import decorators
Andrea Frittoli (andreaf)db9672e2016-02-23 14:07:24 -050021from tempest.lib import exceptions as lib_exc
piyush11078648e35d52015-09-24 12:56:43 +053022
23CONF = config.CONF
24
25
26class SubnetPoolsTestJSON(base.BaseNetworkTest):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +000027 """Tests the following operations in the subnetpools API:
piyush11078648e35d52015-09-24 12:56:43 +053028
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 Bryant2f7aaaa2016-03-04 13:35:37 -050035 v2.0 of the Neutron API is assumed. It is assumed that subnet_allocation
piyush11078648e35d52015-09-24 12:56:43 +053036 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 Frittolicd368412017-08-14 21:37:56 +010045 if not utils.is_extension_enabled('subnet_allocation', 'network'):
Russell Bryant2f7aaaa2016-03-04 13:35:37 -050046 msg = "subnet_allocation extension not enabled."
piyush11078648e35d52015-09-24 12:56:43 +053047 raise cls.skipException(msg)
48
Jordan Pittier3b46d272017-04-12 16:17:28 +020049 @decorators.attr(type='smoke')
Ken'ichi Ohmichi53b9a632017-01-27 18:04:39 -080050 @decorators.idempotent_id('62595970-ab1c-4b7f-8fcc-fddfe55e9811')
piyush11078648e35d52015-09-24 12:56:43 +053051 def test_create_list_show_update_delete_subnetpools(self):
zhufl05fc4f72020-04-26 09:13:54 +080052 """Test create/list/show/update/delete of subnet pools"""
piyush11078648e35d52015-09-24 12:56:43 +053053 subnetpool_name = data_utils.rand_name('subnetpools')
54 # create subnet pool
55 prefix = CONF.network.default_network
Ken'ichi Ohmichi36295912016-01-06 01:24:34 +000056 body = self.subnetpools_client.create_subnetpool(name=subnetpool_name,
57 prefixes=prefix)
piyush11078648e35d52015-09-24 12:56:43 +053058 subnetpool_id = body["subnetpool"]["id"]
Jordan Pittier9e227c52016-02-09 14:35:18 +010059 self.addCleanup(test_utils.call_and_ignore_notfound_exc,
60 self.subnetpools_client.delete_subnetpool,
61 subnetpool_id)
piyush11078648e35d52015-09-24 12:56:43 +053062 self.assertEqual(subnetpool_name, body["subnetpool"]["name"])
63 # get detail about subnet pool
Ken'ichi Ohmichi36295912016-01-06 01:24:34 +000064 body = self.subnetpools_client.show_subnetpool(subnetpool_id)
piyush11078648e35d52015-09-24 12:56:43 +053065 self.assertEqual(subnetpool_name, body["subnetpool"]["name"])
66 # update the subnet pool
67 subnetpool_name = data_utils.rand_name('subnetpools_update')
Ken'ichi Ohmichi36295912016-01-06 01:24:34 +000068 body = self.subnetpools_client.update_subnetpool(subnetpool_id,
69 name=subnetpool_name)
piyush11078648e35d52015-09-24 12:56:43 +053070 self.assertEqual(subnetpool_name, body["subnetpool"]["name"])
71 # delete subnet pool
Ken'ichi Ohmichi36295912016-01-06 01:24:34 +000072 body = self.subnetpools_client.delete_subnetpool(subnetpool_id)
Ken'ichi Ohmichif3f8aba2015-12-15 08:11:00 +000073 self.assertRaises(lib_exc.NotFound,
Ken'ichi Ohmichi36295912016-01-06 01:24:34 +000074 self.subnetpools_client.show_subnetpool,
piyush11078648e35d52015-09-24 12:56:43 +053075 subnetpool_id)