blob: e1cfb303d5fd0b4b3b7d8a2de7854cbf649d50b7 [file] [log] [blame]
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +00001# 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.volume import base
Fei Long Wangd39431f2015-05-14 11:30:48 +120016from tempest.common.utils import data_utils as utils
lkuchlanec1ba4f2016-09-06 10:28:18 +030017from tempest.common import waiters
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080018from tempest.lib import decorators
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000019
20
21class QosSpecsV2TestJSON(base.BaseVolumeAdminTest):
22 """Test the Cinder QoS-specs.
23
24 Tests for create, list, delete, show, associate,
25 disassociate, set/unset key V2 APIs.
26 """
27
28 @classmethod
Andrea Frittoli61a12e22014-09-15 13:14:54 +010029 def resource_setup(cls):
30 super(QosSpecsV2TestJSON, cls).resource_setup()
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000031 # Create admin qos client
32 # Create a test shared qos-specs for tests
33 cls.qos_name = utils.rand_name(cls.__name__ + '-QoS')
34 cls.qos_consumer = 'front-end'
35
36 cls.created_qos = cls.create_test_qos_specs(cls.qos_name,
37 cls.qos_consumer,
38 read_iops_sec='2000')
39
40 def _create_delete_test_qos_with_given_consumer(self, consumer):
zhuflc6ce5392016-08-17 14:34:37 +080041 name = utils.rand_name(self.__class__.__name__ + '-qos')
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000042 qos = {'name': name, 'consumer': consumer}
43 body = self.create_test_qos_specs(name, consumer)
44 for key in ['name', 'consumer']:
45 self.assertEqual(qos[key], body[key])
46
bkopilov62d21752016-06-08 10:16:11 +030047 self.admin_volume_qos_client.delete_qos(body['id'])
48 self.admin_volume_qos_client.wait_for_resource_deletion(body['id'])
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000049
50 # validate the deletion
bkopilov62d21752016-06-08 10:16:11 +030051 list_qos = self.admin_volume_qos_client.list_qos()['qos_specs']
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000052 self.assertNotIn(body, list_qos)
53
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000054 def _test_associate_qos(self, vol_type_id):
bkopilov62d21752016-06-08 10:16:11 +030055 self.admin_volume_qos_client.associate_qos(
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000056 self.created_qos['id'], vol_type_id)
57
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080058 @decorators.idempotent_id('7e15f883-4bef-49a9-95eb-f94209a1ced1')
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000059 def test_create_delete_qos_with_front_end_consumer(self):
60 """Tests the creation and deletion of QoS specs
61
62 With consumer as front end
63 """
64 self._create_delete_test_qos_with_given_consumer('front-end')
65
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080066 @decorators.idempotent_id('b115cded-8f58-4ee4-aab5-9192cfada08f')
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000067 def test_create_delete_qos_with_back_end_consumer(self):
68 """Tests the creation and deletion of QoS specs
69
70 With consumer as back-end
71 """
72 self._create_delete_test_qos_with_given_consumer('back-end')
73
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080074 @decorators.idempotent_id('f88d65eb-ea0d-487d-af8d-71f4011575a4')
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000075 def test_create_delete_qos_with_both_consumer(self):
76 """Tests the creation and deletion of QoS specs
77
78 With consumer as both front end and back end
79 """
80 self._create_delete_test_qos_with_given_consumer('both')
81
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080082 @decorators.idempotent_id('7aa214cc-ac1a-4397-931f-3bb2e83bb0fd')
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000083 def test_get_qos(self):
84 """Tests the detail of a given qos-specs"""
bkopilov62d21752016-06-08 10:16:11 +030085 body = self.admin_volume_qos_client.show_qos(
John Warren3836f3d2015-08-13 18:08:52 +000086 self.created_qos['id'])['qos_specs']
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000087 self.assertEqual(self.qos_name, body['name'])
88 self.assertEqual(self.qos_consumer, body['consumer'])
89
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080090 @decorators.idempotent_id('75e04226-bcf7-4595-a34b-fdf0736f38fc')
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000091 def test_list_qos(self):
92 """Tests the list of all qos-specs"""
bkopilov62d21752016-06-08 10:16:11 +030093 body = self.admin_volume_qos_client.list_qos()['qos_specs']
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000094 self.assertIn(self.created_qos, body)
95
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080096 @decorators.idempotent_id('ed00fd85-4494-45f2-8ceb-9e2048919aed')
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +000097 def test_set_unset_qos_key(self):
98 """Test the addition of a specs key to qos-specs"""
99 args = {'iops_bytes': '500'}
bkopilov62d21752016-06-08 10:16:11 +0300100 body = self.admin_volume_qos_client.set_qos_key(
John Warren3836f3d2015-08-13 18:08:52 +0000101 self.created_qos['id'],
102 iops_bytes='500')['qos_specs']
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +0000103 self.assertEqual(args, body)
bkopilov62d21752016-06-08 10:16:11 +0300104 body = self.admin_volume_qos_client.show_qos(
John Warren3836f3d2015-08-13 18:08:52 +0000105 self.created_qos['id'])['qos_specs']
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +0000106 self.assertEqual(args['iops_bytes'], body['specs']['iops_bytes'])
107
108 # test the deletion of a specs key from qos-specs
109 keys = ['iops_bytes']
bkopilov62d21752016-06-08 10:16:11 +0300110 self.admin_volume_qos_client.unset_qos_key(self.created_qos['id'],
111 keys)
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +0000112 operation = 'qos-key-unset'
lkuchlanec1ba4f2016-09-06 10:28:18 +0300113 waiters.wait_for_qos_operations(self.admin_volume_qos_client,
114 self.created_qos['id'],
115 operation, keys)
bkopilov62d21752016-06-08 10:16:11 +0300116 body = self.admin_volume_qos_client.show_qos(
John Warren3836f3d2015-08-13 18:08:52 +0000117 self.created_qos['id'])['qos_specs']
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +0000118 self.assertNotIn(keys[0], body['specs'])
119
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800120 @decorators.idempotent_id('1dd93c76-6420-485d-a771-874044c416ac')
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +0000121 def test_associate_disassociate_qos(self):
122 """Test the following operations :
123
124 1. associate_qos
125 2. get_association_qos
126 3. disassociate_qos
127 4. disassociate_all_qos
128 """
129
130 # create a test volume-type
131 vol_type = []
132 for _ in range(0, 3):
lkuchlan76650572016-05-23 12:30:10 +0300133 vol_type.append(self.create_volume_type())
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +0000134
135 # associate the qos-specs with volume-types
136 for i in range(0, 3):
137 self._test_associate_qos(vol_type[i]['id'])
138
139 # get the association of the qos-specs
zhufl5d1ceb32016-10-09 14:51:45 +0800140 body = self.admin_volume_qos_client.show_association_qos(
141 self.created_qos['id'])['qos_associations']
142 associations = [association['id'] for association in body]
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +0000143 for i in range(0, 3):
144 self.assertIn(vol_type[i]['id'], associations)
145
146 # disassociate a volume-type with qos-specs
bkopilov62d21752016-06-08 10:16:11 +0300147 self.admin_volume_qos_client.disassociate_qos(
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +0000148 self.created_qos['id'], vol_type[0]['id'])
149 operation = 'disassociate'
lkuchlanec1ba4f2016-09-06 10:28:18 +0300150 waiters.wait_for_qos_operations(self.admin_volume_qos_client,
151 self.created_qos['id'], operation,
152 vol_type[0]['id'])
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +0000153
154 # disassociate all volume-types from qos-specs
bkopilov62d21752016-06-08 10:16:11 +0300155 self.admin_volume_qos_client.disassociate_all_qos(
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +0000156 self.created_qos['id'])
157 operation = 'disassociate-all'
lkuchlanec1ba4f2016-09-06 10:28:18 +0300158 waiters.wait_for_qos_operations(self.admin_volume_qos_client,
159 self.created_qos['id'], operation)
Swapnil Kulkarni7dba3e62014-08-14 09:05:07 +0000160
161
162class QosSpecsV1TestJSON(QosSpecsV2TestJSON):
163 _api_version = 1