blob: be6bffc34f8783a2e1d2c788735dc7ef7980d231 [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
piyush11078648e35d52015-09-24 12:56:43 +053016from tempest import config
Ken'ichi Ohmichif50e4df2017-03-10 10:52:53 -080017from tempest.lib.common.utils import data_utils
Jordan Pittier9e227c52016-02-09 14:35:18 +010018from tempest.lib.common.utils import test_utils
Ken'ichi Ohmichi53b9a632017-01-27 18:04:39 -080019from tempest.lib import decorators
Andrea Frittoli (andreaf)db9672e2016-02-23 14:07:24 -050020from tempest.lib import exceptions as lib_exc
piyush11078648e35d52015-09-24 12:56:43 +053021from tempest import test
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()
Russell Bryant2f7aaaa2016-03-04 13:35:37 -050045 if not test.is_extension_enabled('subnet_allocation', 'network'):
46 msg = "subnet_allocation extension not enabled."
piyush11078648e35d52015-09-24 12:56:43 +053047 raise cls.skipException(msg)
48
49 @test.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):
52 subnetpool_name = data_utils.rand_name('subnetpools')
53 # create subnet pool
54 prefix = CONF.network.default_network
Ken'ichi Ohmichi36295912016-01-06 01:24:34 +000055 body = self.subnetpools_client.create_subnetpool(name=subnetpool_name,
56 prefixes=prefix)
piyush11078648e35d52015-09-24 12:56:43 +053057 subnetpool_id = body["subnetpool"]["id"]
Jordan Pittier9e227c52016-02-09 14:35:18 +010058 self.addCleanup(test_utils.call_and_ignore_notfound_exc,
59 self.subnetpools_client.delete_subnetpool,
60 subnetpool_id)
piyush11078648e35d52015-09-24 12:56:43 +053061 self.assertEqual(subnetpool_name, body["subnetpool"]["name"])
62 # get detail about subnet pool
Ken'ichi Ohmichi36295912016-01-06 01:24:34 +000063 body = self.subnetpools_client.show_subnetpool(subnetpool_id)
piyush11078648e35d52015-09-24 12:56:43 +053064 self.assertEqual(subnetpool_name, body["subnetpool"]["name"])
65 # update the subnet pool
66 subnetpool_name = data_utils.rand_name('subnetpools_update')
Ken'ichi Ohmichi36295912016-01-06 01:24:34 +000067 body = self.subnetpools_client.update_subnetpool(subnetpool_id,
68 name=subnetpool_name)
piyush11078648e35d52015-09-24 12:56:43 +053069 self.assertEqual(subnetpool_name, body["subnetpool"]["name"])
70 # delete subnet pool
Ken'ichi Ohmichi36295912016-01-06 01:24:34 +000071 body = self.subnetpools_client.delete_subnetpool(subnetpool_id)
Ken'ichi Ohmichif3f8aba2015-12-15 08:11:00 +000072 self.assertRaises(lib_exc.NotFound,
Ken'ichi Ohmichi36295912016-01-06 01:24:34 +000073 self.subnetpools_client.show_subnetpool,
piyush11078648e35d52015-09-24 12:56:43 +053074 subnetpool_id)