blob: 29d1d89e5df5c2cbb3733ca5b65056601ac65b4e [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
16from tempest.common.utils import data_utils
17from tempest import config
18from tempest import test
19from tempest_lib import exceptions as lib_exc
20
21CONF = config.CONF
22
23
24class SubnetPoolsTestJSON(base.BaseNetworkTest):
Ken'ichi Ohmichie03bea92015-11-19 07:45:58 +000025 """Tests the following operations in the subnetpools API:
piyush11078648e35d52015-09-24 12:56:43 +053026
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
33 v2.0 of the Neutron API is assumed. It is assumed that subnetpools
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()
43 if not test.is_extension_enabled('subnetpools', 'network'):
44 msg = "subnet pools extension not enabled."
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 Ohmichif3f8aba2015-12-15 08:11:00 +000053 body = self.subnetpools_client.create_subnetpools(name=subnetpool_name,
54 prefixes=prefix)
piyush11078648e35d52015-09-24 12:56:43 +053055 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 Ohmichif3f8aba2015-12-15 08:11:00 +000059 body = self.subnetpools_client.show_subnetpools(subnetpool_id)
piyush11078648e35d52015-09-24 12:56:43 +053060 self.assertEqual(subnetpool_name, body["subnetpool"]["name"])
61 # update the subnet pool
62 subnetpool_name = data_utils.rand_name('subnetpools_update')
Ken'ichi Ohmichif3f8aba2015-12-15 08:11:00 +000063 body = self.subnetpools_client.update_subnetpools(subnetpool_id,
64 name=subnetpool_name)
piyush11078648e35d52015-09-24 12:56:43 +053065 self.assertEqual(subnetpool_name, body["subnetpool"]["name"])
66 # delete subnet pool
Ken'ichi Ohmichif3f8aba2015-12-15 08:11:00 +000067 body = self.subnetpools_client.delete_subnetpools(subnetpool_id)
68 self.assertRaises(lib_exc.NotFound,
69 self.subnetpools_client.show_subnetpools,
piyush11078648e35d52015-09-24 12:56:43 +053070 subnetpool_id)
71
72 def _cleanup_subnetpools(self, subnetpool_id):
73 # this is used to cleanup the resources
74 try:
Ken'ichi Ohmichif3f8aba2015-12-15 08:11:00 +000075 self.subnetpools_client.delete_subnetpools(subnetpool_id)
piyush11078648e35d52015-09-24 12:56:43 +053076 except lib_exc.NotFound:
77 pass