Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 1 | # 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.volume import base |
Fei Long Wang | d39431f | 2015-05-14 11:30:48 +1200 | [diff] [blame] | 16 | from tempest.common.utils import data_utils as utils |
lkuchlan | ec1ba4f | 2016-09-06 10:28:18 +0300 | [diff] [blame] | 17 | from tempest.common import waiters |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 18 | from tempest import test |
| 19 | |
| 20 | |
| 21 | class 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 Frittoli | 61a12e2 | 2014-09-15 13:14:54 +0100 | [diff] [blame] | 29 | def resource_setup(cls): |
| 30 | super(QosSpecsV2TestJSON, cls).resource_setup() |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 31 | # 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): |
zhufl | c6ce539 | 2016-08-17 14:34:37 +0800 | [diff] [blame] | 41 | name = utils.rand_name(self.__class__.__name__ + '-qos') |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 42 | 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 | |
bkopilov | 62d2175 | 2016-06-08 10:16:11 +0300 | [diff] [blame] | 47 | self.admin_volume_qos_client.delete_qos(body['id']) |
| 48 | self.admin_volume_qos_client.wait_for_resource_deletion(body['id']) |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 49 | |
| 50 | # validate the deletion |
bkopilov | 62d2175 | 2016-06-08 10:16:11 +0300 | [diff] [blame] | 51 | list_qos = self.admin_volume_qos_client.list_qos()['qos_specs'] |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 52 | self.assertNotIn(body, list_qos) |
| 53 | |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 54 | def _test_associate_qos(self, vol_type_id): |
bkopilov | 62d2175 | 2016-06-08 10:16:11 +0300 | [diff] [blame] | 55 | self.admin_volume_qos_client.associate_qos( |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 56 | self.created_qos['id'], vol_type_id) |
| 57 | |
| 58 | def _test_get_association_qos(self): |
bkopilov | 62d2175 | 2016-06-08 10:16:11 +0300 | [diff] [blame] | 59 | body = self.admin_volume_qos_client.show_association_qos( |
John Warren | 3836f3d | 2015-08-13 18:08:52 +0000 | [diff] [blame] | 60 | self.created_qos['id'])['qos_associations'] |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 61 | |
| 62 | associations = [] |
| 63 | for association in body: |
| 64 | associations.append(association['id']) |
| 65 | |
| 66 | return associations |
| 67 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 68 | @test.idempotent_id('7e15f883-4bef-49a9-95eb-f94209a1ced1') |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 69 | def test_create_delete_qos_with_front_end_consumer(self): |
| 70 | """Tests the creation and deletion of QoS specs |
| 71 | |
| 72 | With consumer as front end |
| 73 | """ |
| 74 | self._create_delete_test_qos_with_given_consumer('front-end') |
| 75 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 76 | @test.idempotent_id('b115cded-8f58-4ee4-aab5-9192cfada08f') |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 77 | def test_create_delete_qos_with_back_end_consumer(self): |
| 78 | """Tests the creation and deletion of QoS specs |
| 79 | |
| 80 | With consumer as back-end |
| 81 | """ |
| 82 | self._create_delete_test_qos_with_given_consumer('back-end') |
| 83 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 84 | @test.idempotent_id('f88d65eb-ea0d-487d-af8d-71f4011575a4') |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 85 | def test_create_delete_qos_with_both_consumer(self): |
| 86 | """Tests the creation and deletion of QoS specs |
| 87 | |
| 88 | With consumer as both front end and back end |
| 89 | """ |
| 90 | self._create_delete_test_qos_with_given_consumer('both') |
| 91 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 92 | @test.idempotent_id('7aa214cc-ac1a-4397-931f-3bb2e83bb0fd') |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 93 | def test_get_qos(self): |
| 94 | """Tests the detail of a given qos-specs""" |
bkopilov | 62d2175 | 2016-06-08 10:16:11 +0300 | [diff] [blame] | 95 | body = self.admin_volume_qos_client.show_qos( |
John Warren | 3836f3d | 2015-08-13 18:08:52 +0000 | [diff] [blame] | 96 | self.created_qos['id'])['qos_specs'] |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 97 | self.assertEqual(self.qos_name, body['name']) |
| 98 | self.assertEqual(self.qos_consumer, body['consumer']) |
| 99 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 100 | @test.idempotent_id('75e04226-bcf7-4595-a34b-fdf0736f38fc') |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 101 | def test_list_qos(self): |
| 102 | """Tests the list of all qos-specs""" |
bkopilov | 62d2175 | 2016-06-08 10:16:11 +0300 | [diff] [blame] | 103 | body = self.admin_volume_qos_client.list_qos()['qos_specs'] |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 104 | self.assertIn(self.created_qos, body) |
| 105 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 106 | @test.idempotent_id('ed00fd85-4494-45f2-8ceb-9e2048919aed') |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 107 | def test_set_unset_qos_key(self): |
| 108 | """Test the addition of a specs key to qos-specs""" |
| 109 | args = {'iops_bytes': '500'} |
bkopilov | 62d2175 | 2016-06-08 10:16:11 +0300 | [diff] [blame] | 110 | body = self.admin_volume_qos_client.set_qos_key( |
John Warren | 3836f3d | 2015-08-13 18:08:52 +0000 | [diff] [blame] | 111 | self.created_qos['id'], |
| 112 | iops_bytes='500')['qos_specs'] |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 113 | self.assertEqual(args, body) |
bkopilov | 62d2175 | 2016-06-08 10:16:11 +0300 | [diff] [blame] | 114 | body = self.admin_volume_qos_client.show_qos( |
John Warren | 3836f3d | 2015-08-13 18:08:52 +0000 | [diff] [blame] | 115 | self.created_qos['id'])['qos_specs'] |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 116 | self.assertEqual(args['iops_bytes'], body['specs']['iops_bytes']) |
| 117 | |
| 118 | # test the deletion of a specs key from qos-specs |
| 119 | keys = ['iops_bytes'] |
bkopilov | 62d2175 | 2016-06-08 10:16:11 +0300 | [diff] [blame] | 120 | self.admin_volume_qos_client.unset_qos_key(self.created_qos['id'], |
| 121 | keys) |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 122 | operation = 'qos-key-unset' |
lkuchlan | ec1ba4f | 2016-09-06 10:28:18 +0300 | [diff] [blame] | 123 | waiters.wait_for_qos_operations(self.admin_volume_qos_client, |
| 124 | self.created_qos['id'], |
| 125 | operation, keys) |
bkopilov | 62d2175 | 2016-06-08 10:16:11 +0300 | [diff] [blame] | 126 | body = self.admin_volume_qos_client.show_qos( |
John Warren | 3836f3d | 2015-08-13 18:08:52 +0000 | [diff] [blame] | 127 | self.created_qos['id'])['qos_specs'] |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 128 | self.assertNotIn(keys[0], body['specs']) |
| 129 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 130 | @test.idempotent_id('1dd93c76-6420-485d-a771-874044c416ac') |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 131 | def test_associate_disassociate_qos(self): |
| 132 | """Test the following operations : |
| 133 | |
| 134 | 1. associate_qos |
| 135 | 2. get_association_qos |
| 136 | 3. disassociate_qos |
| 137 | 4. disassociate_all_qos |
| 138 | """ |
| 139 | |
| 140 | # create a test volume-type |
| 141 | vol_type = [] |
| 142 | for _ in range(0, 3): |
lkuchlan | 7665057 | 2016-05-23 12:30:10 +0300 | [diff] [blame] | 143 | vol_type.append(self.create_volume_type()) |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 144 | |
| 145 | # associate the qos-specs with volume-types |
| 146 | for i in range(0, 3): |
| 147 | self._test_associate_qos(vol_type[i]['id']) |
| 148 | |
| 149 | # get the association of the qos-specs |
| 150 | associations = self._test_get_association_qos() |
| 151 | |
| 152 | for i in range(0, 3): |
| 153 | self.assertIn(vol_type[i]['id'], associations) |
| 154 | |
| 155 | # disassociate a volume-type with qos-specs |
bkopilov | 62d2175 | 2016-06-08 10:16:11 +0300 | [diff] [blame] | 156 | self.admin_volume_qos_client.disassociate_qos( |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 157 | self.created_qos['id'], vol_type[0]['id']) |
| 158 | operation = 'disassociate' |
lkuchlan | ec1ba4f | 2016-09-06 10:28:18 +0300 | [diff] [blame] | 159 | waiters.wait_for_qos_operations(self.admin_volume_qos_client, |
| 160 | self.created_qos['id'], operation, |
| 161 | vol_type[0]['id']) |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 162 | associations = self._test_get_association_qos() |
| 163 | self.assertNotIn(vol_type[0]['id'], associations) |
| 164 | |
| 165 | # disassociate all volume-types from qos-specs |
bkopilov | 62d2175 | 2016-06-08 10:16:11 +0300 | [diff] [blame] | 166 | self.admin_volume_qos_client.disassociate_all_qos( |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 167 | self.created_qos['id']) |
| 168 | operation = 'disassociate-all' |
lkuchlan | ec1ba4f | 2016-09-06 10:28:18 +0300 | [diff] [blame] | 169 | waiters.wait_for_qos_operations(self.admin_volume_qos_client, |
| 170 | self.created_qos['id'], operation) |
Swapnil Kulkarni | 7dba3e6 | 2014-08-14 09:05:07 +0000 | [diff] [blame] | 171 | associations = self._test_get_association_qos() |
| 172 | self.assertEmpty(associations) |
| 173 | |
| 174 | |
| 175 | class QosSpecsV1TestJSON(QosSpecsV2TestJSON): |
| 176 | _api_version = 1 |