Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1 | # Copyright 2015 Red Hat, Inc. |
| 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 | |
Slawek Kaplonski | ec162e0 | 2024-03-06 12:21:24 +0100 | [diff] [blame] | 15 | |
| 16 | import ddt |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 17 | from neutron_lib.api.definitions import qos as qos_apidef |
nfridman | 23b44ad | 2019-09-05 09:46:50 -0400 | [diff] [blame] | 18 | from neutron_lib import constants as n_constants |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 19 | from neutron_lib.services.qos import constants as qos_consts |
| 20 | from tempest.common import utils |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 21 | from tempest.lib.common.utils import data_utils |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 22 | from tempest.lib.common.utils import test_utils |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 23 | from tempest.lib import decorators |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 24 | from tempest.lib import exceptions |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 25 | import testtools |
| 26 | |
Chandan Kumar | 667d3d3 | 2017-09-22 12:24:06 +0530 | [diff] [blame] | 27 | from neutron_tempest_plugin.api import base |
nfridman | 07f0e78 | 2019-11-04 09:12:58 -0500 | [diff] [blame] | 28 | from neutron_tempest_plugin import config |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 29 | |
nfridman | 07f0e78 | 2019-11-04 09:12:58 -0500 | [diff] [blame] | 30 | CONF = config.CONF |
Sławek Kapłoński | 153f345 | 2017-03-24 22:04:53 +0000 | [diff] [blame] | 31 | |
| 32 | |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 33 | class QosTestJSON(base.BaseAdminNetworkTest): |
Jakub Libosvar | 1982aa1 | 2017-05-30 11:15:33 +0000 | [diff] [blame] | 34 | |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 35 | required_extensions = [qos_apidef.ALIAS] |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 36 | |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 37 | @classmethod |
| 38 | def setup_clients(cls): |
| 39 | super(QosTestJSON, cls).setup_clients() |
| 40 | cls.qos_bw_limit_rule_client = \ |
| 41 | cls.os_admin.qos_limit_bandwidth_rules_client |
| 42 | |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 43 | def setUp(self): |
| 44 | super(QosTestJSON, self).setUp() |
| 45 | self.policy_name = data_utils.rand_name(name='test', prefix='policy') |
| 46 | |
Sławek Kapłoński | 7aa3a35 | 2017-06-19 06:35:25 +0000 | [diff] [blame] | 47 | @staticmethod |
| 48 | def _get_driver_details(rule_type_details, driver_name): |
| 49 | for driver in rule_type_details['drivers']: |
| 50 | if driver['name'] == driver_name: |
| 51 | return driver |
| 52 | |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 53 | def _create_qos_bw_limit_rule(self, policy_id, rule_data): |
| 54 | rule = self.qos_bw_limit_rule_client.create_limit_bandwidth_rule( |
| 55 | qos_policy_id=policy_id, |
| 56 | **rule_data)['bandwidth_limit_rule'] |
| 57 | self.addCleanup( |
| 58 | test_utils.call_and_ignore_notfound_exc, |
| 59 | self.qos_bw_limit_rule_client.delete_limit_bandwidth_rule, |
| 60 | policy_id, rule['id']) |
| 61 | return rule |
| 62 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 63 | @decorators.idempotent_id('108fbdf7-3463-4e47-9871-d07f3dcf5bbb') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 64 | def test_create_policy(self): |
| 65 | policy = self.create_qos_policy(name='test-policy', |
| 66 | description='test policy desc1', |
| 67 | shared=False) |
| 68 | |
| 69 | # Test 'show policy' |
| 70 | retrieved_policy = self.admin_client.show_qos_policy(policy['id']) |
| 71 | retrieved_policy = retrieved_policy['policy'] |
| 72 | self.assertEqual('test-policy', retrieved_policy['name']) |
| 73 | self.assertEqual('test policy desc1', retrieved_policy['description']) |
| 74 | self.assertFalse(retrieved_policy['shared']) |
| 75 | |
| 76 | # Test 'list policies' |
| 77 | policies = self.admin_client.list_qos_policies()['policies'] |
| 78 | policies_ids = [p['id'] for p in policies] |
| 79 | self.assertIn(policy['id'], policies_ids) |
| 80 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 81 | @decorators.idempotent_id('606a48e2-5403-4052-b40f-4d54b855af76') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 82 | @utils.requires_ext(extension="project-id", service="network") |
Henry Gessau | fa6c78d | 2016-10-09 19:56:09 -0400 | [diff] [blame] | 83 | def test_show_policy_has_project_id(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 84 | policy = self.create_qos_policy(name=self.policy_name, shared=False) |
Henry Gessau | fa6c78d | 2016-10-09 19:56:09 -0400 | [diff] [blame] | 85 | body = self.admin_client.show_qos_policy(policy['id']) |
| 86 | show_policy = body['policy'] |
| 87 | self.assertIn('project_id', show_policy) |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 88 | self.assertEqual(self.admin_client.project_id, |
Henry Gessau | fa6c78d | 2016-10-09 19:56:09 -0400 | [diff] [blame] | 89 | show_policy['project_id']) |
Henry Gessau | fa6c78d | 2016-10-09 19:56:09 -0400 | [diff] [blame] | 90 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 91 | @decorators.idempotent_id('f8d20e92-f06d-4805-b54f-230f77715815') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 92 | def test_list_policy_filter_by_name(self): |
yatinkarel | 65fa2c0 | 2022-01-28 13:44:19 +0530 | [diff] [blame] | 93 | policy1 = 'test' + data_utils.rand_name("policy") |
| 94 | policy2 = 'test' + data_utils.rand_name("policy") |
| 95 | self.create_qos_policy(name=policy1, description='test policy', |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 96 | shared=False) |
yatinkarel | 65fa2c0 | 2022-01-28 13:44:19 +0530 | [diff] [blame] | 97 | self.create_qos_policy(name=policy2, description='test policy', |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 98 | shared=False) |
| 99 | |
| 100 | policies = (self.admin_client. |
yatinkarel | 65fa2c0 | 2022-01-28 13:44:19 +0530 | [diff] [blame] | 101 | list_qos_policies(name=policy1)['policies']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 102 | self.assertEqual(1, len(policies)) |
| 103 | |
| 104 | retrieved_policy = policies[0] |
yatinkarel | 65fa2c0 | 2022-01-28 13:44:19 +0530 | [diff] [blame] | 105 | self.assertEqual(policy1, retrieved_policy['name']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 106 | |
likangkang01 | afd73f7 | 2020-06-01 16:53:59 +0800 | [diff] [blame] | 107 | @decorators.idempotent_id('dde0b449-a400-4a87-b5a5-4d1c413c917b') |
| 108 | def test_list_policy_sort_by_name(self): |
| 109 | policyA = 'A' + data_utils.rand_name("policy") |
| 110 | policyB = 'B' + data_utils.rand_name("policy") |
| 111 | self.create_qos_policy(name=policyA, description='test policy', |
| 112 | shared=False) |
| 113 | self.create_qos_policy(name=policyB, description='test policy', |
| 114 | shared=False) |
| 115 | |
| 116 | param = { |
| 117 | 'sort_key': 'name', |
| 118 | 'sort_dir': 'asc' |
| 119 | } |
| 120 | policies = (self.admin_client.list_qos_policies(**param)['policies']) |
| 121 | policy_names = [p['name'] for p in policies] |
| 122 | self.assertLess(policy_names.index(policyA), |
| 123 | policy_names.index(policyB)) |
| 124 | |
| 125 | param = { |
| 126 | 'sort_key': 'name', |
| 127 | 'sort_dir': 'desc' |
| 128 | } |
| 129 | policies = (self.admin_client.list_qos_policies(**param)['policies']) |
| 130 | policy_names = [p['name'] for p in policies] |
| 131 | self.assertLess(policy_names.index(policyB), |
| 132 | policy_names.index(policyA)) |
| 133 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 134 | @decorators.idempotent_id('8e88a54b-f0b2-4b7d-b061-a15d93c2c7d6') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 135 | def test_policy_update(self): |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 136 | policy = self.create_qos_policy( |
| 137 | name=self.policy_name, |
| 138 | description='', |
| 139 | shared=False, |
| 140 | project_id=self.admin_client.project_id) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 141 | self.admin_client.update_qos_policy(policy['id'], |
| 142 | description='test policy desc2', |
| 143 | shared=True) |
| 144 | |
| 145 | retrieved_policy = self.admin_client.show_qos_policy(policy['id']) |
| 146 | retrieved_policy = retrieved_policy['policy'] |
| 147 | self.assertEqual('test policy desc2', retrieved_policy['description']) |
| 148 | self.assertTrue(retrieved_policy['shared']) |
| 149 | self.assertEqual([], retrieved_policy['rules']) |
| 150 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 151 | @decorators.idempotent_id('6e880e0f-bbfc-4e54-87c6-680f90e1b618') |
Sławek Kapłoński | 0acecc6 | 2016-08-20 21:00:51 +0000 | [diff] [blame] | 152 | def test_policy_update_forbidden_for_regular_tenants_own_policy(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 153 | policy = self.create_qos_policy(name=self.policy_name, |
Sławek Kapłoński | 0acecc6 | 2016-08-20 21:00:51 +0000 | [diff] [blame] | 154 | description='', |
| 155 | shared=False, |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 156 | project_id=self.client.project_id) |
Sławek Kapłoński | 0acecc6 | 2016-08-20 21:00:51 +0000 | [diff] [blame] | 157 | self.assertRaises( |
| 158 | exceptions.Forbidden, |
| 159 | self.client.update_qos_policy, |
| 160 | policy['id'], description='test policy') |
| 161 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 162 | @decorators.idempotent_id('4ecfd7e7-47b6-4702-be38-be9235901a87') |
Sławek Kapłoński | 0acecc6 | 2016-08-20 21:00:51 +0000 | [diff] [blame] | 163 | def test_policy_update_forbidden_for_regular_tenants_foreign_policy(self): |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 164 | policy = self.create_qos_policy( |
| 165 | name=self.policy_name, |
| 166 | description='', |
| 167 | shared=False, |
| 168 | project_id=self.admin_client.project_id) |
Sławek Kapłoński | 0acecc6 | 2016-08-20 21:00:51 +0000 | [diff] [blame] | 169 | self.assertRaises( |
| 170 | exceptions.NotFound, |
| 171 | self.client.update_qos_policy, |
| 172 | policy['id'], description='test policy') |
| 173 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 174 | @decorators.idempotent_id('ee263db4-009a-4641-83e5-d0e83506ba4c') |
Sławek Kapłoński | 6bfcc75 | 2016-06-05 09:49:27 +0000 | [diff] [blame] | 175 | def test_shared_policy_update(self): |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 176 | policy = self.create_qos_policy( |
| 177 | name=self.policy_name, |
| 178 | description='', |
| 179 | shared=True, |
| 180 | project_id=self.admin_client.project_id) |
Sławek Kapłoński | 6bfcc75 | 2016-06-05 09:49:27 +0000 | [diff] [blame] | 181 | |
| 182 | self.admin_client.update_qos_policy(policy['id'], |
| 183 | description='test policy desc2') |
| 184 | retrieved_policy = self.admin_client.show_qos_policy(policy['id']) |
| 185 | retrieved_policy = retrieved_policy['policy'] |
| 186 | self.assertTrue(retrieved_policy['shared']) |
| 187 | |
| 188 | self.admin_client.update_qos_policy(policy['id'], |
| 189 | shared=False) |
| 190 | retrieved_policy = self.admin_client.show_qos_policy(policy['id']) |
| 191 | retrieved_policy = retrieved_policy['policy'] |
| 192 | self.assertFalse(retrieved_policy['shared']) |
| 193 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 194 | @decorators.idempotent_id('1cb42653-54bd-4a9a-b888-c55e18199201') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 195 | def test_delete_policy(self): |
| 196 | policy = self.admin_client.create_qos_policy( |
| 197 | 'test-policy', 'desc', True)['policy'] |
| 198 | |
| 199 | retrieved_policy = self.admin_client.show_qos_policy(policy['id']) |
| 200 | retrieved_policy = retrieved_policy['policy'] |
| 201 | self.assertEqual('test-policy', retrieved_policy['name']) |
| 202 | |
| 203 | self.admin_client.delete_qos_policy(policy['id']) |
| 204 | self.assertRaises(exceptions.NotFound, |
| 205 | self.admin_client.show_qos_policy, policy['id']) |
| 206 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 207 | @decorators.idempotent_id('cf776f77-8d3d-49f2-8572-12d6a1557224') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 208 | def test_list_admin_rule_types(self): |
| 209 | self._test_list_rule_types(self.admin_client) |
| 210 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 211 | @decorators.idempotent_id('49c8ea35-83a9-453a-bd23-239cf3b13929') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 212 | def test_list_regular_rule_types(self): |
| 213 | self._test_list_rule_types(self.client) |
| 214 | |
| 215 | def _test_list_rule_types(self, client): |
| 216 | # List supported rule types |
Sławek Kapłoński | 566ae69 | 2017-06-25 08:37:42 +0000 | [diff] [blame] | 217 | # Since returned rule types depends on loaded backend drivers this test |
| 218 | # is checking only if returned keys are same as expected keys |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 219 | # |
| 220 | # In theory, we could make the test conditional on which ml2 drivers |
| 221 | # are enabled in gate (or more specifically, on which supported qos |
| 222 | # rules are claimed by core plugin), but that option doesn't seem to be |
karimb | d4c68e7 | 2016-06-24 14:44:11 +0200 | [diff] [blame] | 223 | # available through tempest.lib framework |
Sławek Kapłoński | 566ae69 | 2017-06-25 08:37:42 +0000 | [diff] [blame] | 224 | expected_rule_keys = ['type'] |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 225 | |
| 226 | rule_types = client.list_qos_rule_types() |
| 227 | actual_list_rule_types = rule_types['rule_types'] |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 228 | |
| 229 | # Verify that only required fields present in rule details |
| 230 | for rule in actual_list_rule_types: |
Sławek Kapłoński | 566ae69 | 2017-06-25 08:37:42 +0000 | [diff] [blame] | 231 | self.assertEqual(tuple(expected_rule_keys), tuple(rule.keys())) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 232 | |
Sławek Kapłoński | 7aa3a35 | 2017-06-19 06:35:25 +0000 | [diff] [blame] | 233 | @decorators.idempotent_id('8ececa21-ef97-4904-a152-9f04c90f484d') |
| 234 | def test_show_rule_type_details_as_user(self): |
| 235 | self.assertRaises( |
| 236 | exceptions.Forbidden, |
| 237 | self.client.show_qos_rule_type, |
| 238 | qos_consts.RULE_TYPE_BANDWIDTH_LIMIT) |
| 239 | |
| 240 | @decorators.idempotent_id('d0a2460b-7325-481f-a531-050bd96ab25e') |
| 241 | def test_show_rule_type_details_as_admin(self): |
| 242 | # Since returned rule types depend on loaded backend drivers this test |
| 243 | # is checking only if returned keys are same as expected keys |
| 244 | |
| 245 | # In theory, we could make the test conditional on which ml2 drivers |
| 246 | # are enabled in gate, but that option doesn't seem to be |
| 247 | # available through tempest.lib framework |
| 248 | expected_rule_type_details_keys = ['type', 'drivers'] |
| 249 | |
| 250 | rule_type_details = self.admin_client.show_qos_rule_type( |
| 251 | qos_consts.RULE_TYPE_BANDWIDTH_LIMIT).get("rule_type") |
| 252 | |
| 253 | # Verify that only required fields present in rule details |
| 254 | self.assertEqual( |
| 255 | sorted(tuple(expected_rule_type_details_keys)), |
| 256 | sorted(tuple(rule_type_details.keys()))) |
| 257 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 258 | @decorators.idempotent_id('65b9ef75-1911-406a-bbdb-ca1d68d528b0') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 259 | def test_policy_association_with_admin_network(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 260 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 261 | description='test policy', |
| 262 | shared=False) |
Federico Ressi | 2d7db2c | 2018-07-06 08:11:20 +0200 | [diff] [blame] | 263 | network = self.create_network('test network', shared=True, |
| 264 | qos_policy_id=policy['id']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 265 | |
| 266 | retrieved_network = self.admin_client.show_network(network['id']) |
| 267 | self.assertEqual( |
| 268 | policy['id'], retrieved_network['network']['qos_policy_id']) |
| 269 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 270 | @decorators.idempotent_id('1738de5d-0476-4163-9022-5e1b548c208e') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 271 | def test_policy_association_with_tenant_network(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 272 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 273 | description='test policy', |
| 274 | shared=True) |
| 275 | network = self.create_network('test network', |
| 276 | qos_policy_id=policy['id']) |
| 277 | |
| 278 | retrieved_network = self.admin_client.show_network(network['id']) |
| 279 | self.assertEqual( |
| 280 | policy['id'], retrieved_network['network']['qos_policy_id']) |
| 281 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 282 | @decorators.idempotent_id('9efe63d0-836f-4cc2-b00c-468e63aa614e') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 283 | def test_policy_association_with_network_nonexistent_policy(self): |
| 284 | self.assertRaises( |
| 285 | exceptions.NotFound, |
| 286 | self.create_network, |
| 287 | 'test network', |
| 288 | qos_policy_id='9efe63d0-836f-4cc2-b00c-468e63aa614e') |
| 289 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 290 | @decorators.idempotent_id('1aa55a79-324f-47d9-a076-894a8fc2448b') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 291 | def test_policy_association_with_network_non_shared_policy(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 292 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 293 | description='test policy', |
| 294 | shared=False) |
| 295 | self.assertRaises( |
| 296 | exceptions.NotFound, |
| 297 | self.create_network, |
| 298 | 'test network', qos_policy_id=policy['id']) |
| 299 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 300 | @decorators.idempotent_id('09a9392c-1359-4cbb-989f-fb768e5834a8') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 301 | def test_policy_update_association_with_admin_network(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 302 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 303 | description='test policy', |
| 304 | shared=False) |
Federico Ressi | 2d7db2c | 2018-07-06 08:11:20 +0200 | [diff] [blame] | 305 | network = self.create_network('test network', shared=True) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 306 | retrieved_network = self.admin_client.show_network(network['id']) |
| 307 | self.assertIsNone(retrieved_network['network']['qos_policy_id']) |
| 308 | |
| 309 | self.admin_client.update_network(network['id'], |
| 310 | qos_policy_id=policy['id']) |
| 311 | retrieved_network = self.admin_client.show_network(network['id']) |
| 312 | self.assertEqual( |
| 313 | policy['id'], retrieved_network['network']['qos_policy_id']) |
| 314 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 315 | @decorators.idempotent_id('98fcd95e-84cf-4746-860e-44692e674f2e') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 316 | def test_policy_association_with_port_shared_policy(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 317 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 318 | description='test policy', |
| 319 | shared=True) |
Federico Ressi | 2d7db2c | 2018-07-06 08:11:20 +0200 | [diff] [blame] | 320 | network = self.create_network('test network', shared=True) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 321 | port = self.create_port(network, qos_policy_id=policy['id']) |
| 322 | |
| 323 | retrieved_port = self.admin_client.show_port(port['id']) |
| 324 | self.assertEqual( |
| 325 | policy['id'], retrieved_port['port']['qos_policy_id']) |
| 326 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 327 | @decorators.idempotent_id('49e02f5a-e1dd-41d5-9855-cfa37f2d195e') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 328 | def test_policy_association_with_port_nonexistent_policy(self): |
Federico Ressi | 2d7db2c | 2018-07-06 08:11:20 +0200 | [diff] [blame] | 329 | network = self.create_network('test network', shared=True) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 330 | self.assertRaises( |
| 331 | exceptions.NotFound, |
| 332 | self.create_port, |
| 333 | network, |
| 334 | qos_policy_id='49e02f5a-e1dd-41d5-9855-cfa37f2d195e') |
| 335 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 336 | @decorators.idempotent_id('f53d961c-9fe5-4422-8b66-7add972c6031') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 337 | def test_policy_association_with_port_non_shared_policy(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 338 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 339 | description='test policy', |
| 340 | shared=False) |
Federico Ressi | 2d7db2c | 2018-07-06 08:11:20 +0200 | [diff] [blame] | 341 | network = self.create_network('test network', shared=True) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 342 | self.assertRaises( |
| 343 | exceptions.NotFound, |
| 344 | self.create_port, |
| 345 | network, qos_policy_id=policy['id']) |
| 346 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 347 | @decorators.idempotent_id('f8163237-fba9-4db5-9526-bad6d2343c76') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 348 | def test_policy_update_association_with_port_shared_policy(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 349 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 350 | description='test policy', |
| 351 | shared=True) |
Federico Ressi | 2d7db2c | 2018-07-06 08:11:20 +0200 | [diff] [blame] | 352 | network = self.create_network('test network', shared=True) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 353 | port = self.create_port(network) |
| 354 | retrieved_port = self.admin_client.show_port(port['id']) |
| 355 | self.assertIsNone(retrieved_port['port']['qos_policy_id']) |
| 356 | |
| 357 | self.client.update_port(port['id'], qos_policy_id=policy['id']) |
| 358 | retrieved_port = self.admin_client.show_port(port['id']) |
| 359 | self.assertEqual( |
| 360 | policy['id'], retrieved_port['port']['qos_policy_id']) |
| 361 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 362 | @decorators.idempotent_id('18163237-8ba9-4db5-9525-bad6d2343c75') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 363 | def test_delete_not_allowed_if_policy_in_use_by_network(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 364 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 365 | description='test policy', |
| 366 | shared=True) |
Federico Ressi | 2d7db2c | 2018-07-06 08:11:20 +0200 | [diff] [blame] | 367 | self.create_network('test network', qos_policy_id=policy['id'], |
| 368 | shared=True) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 369 | self.assertRaises( |
| 370 | exceptions.Conflict, |
| 371 | self.admin_client.delete_qos_policy, policy['id']) |
| 372 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 373 | @decorators.idempotent_id('24153230-84a9-4dd5-9525-bad6d2343c75') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 374 | def test_delete_not_allowed_if_policy_in_use_by_port(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 375 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 376 | description='test policy', |
| 377 | shared=True) |
Federico Ressi | 2d7db2c | 2018-07-06 08:11:20 +0200 | [diff] [blame] | 378 | network = self.create_network('test network', shared=True) |
Sławek Kapłoński | e100c4d | 2017-08-23 21:18:34 +0000 | [diff] [blame] | 379 | self.create_port(network, qos_policy_id=policy['id']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 380 | self.assertRaises( |
| 381 | exceptions.Conflict, |
| 382 | self.admin_client.delete_qos_policy, policy['id']) |
| 383 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 384 | @decorators.idempotent_id('a2a5849b-dd06-4b18-9664-0b6828a1fc27') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 385 | def test_qos_policy_delete_with_rules(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 386 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 387 | description='test policy', |
| 388 | shared=False) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 389 | self._create_qos_bw_limit_rule( |
| 390 | policy['id'], {'max_kbps': 200, 'max_burst_kbps': 1337}) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 391 | self.admin_client.delete_qos_policy(policy['id']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 392 | with testtools.ExpectedException(exceptions.NotFound): |
| 393 | self.admin_client.show_qos_policy(policy['id']) |
| 394 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 395 | @decorators.idempotent_id('fb384bde-a973-41c3-a542-6f77a092155f') |
Jakub Libosvar | ab42ca8 | 2016-06-07 07:56:13 +0000 | [diff] [blame] | 396 | def test_get_policy_that_is_shared(self): |
| 397 | policy = self.create_qos_policy( |
| 398 | name='test-policy-shared', |
| 399 | description='shared policy', |
| 400 | shared=True, |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 401 | project_id=self.admin_client.project_id) |
Jakub Libosvar | ab42ca8 | 2016-06-07 07:56:13 +0000 | [diff] [blame] | 402 | obtained_policy = self.client.show_qos_policy(policy['id'])['policy'] |
| 403 | self.assertEqual(obtained_policy, policy) |
| 404 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 405 | @decorators.idempotent_id('aed8e2a6-22da-421b-89b9-935a2c1a1b50') |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 406 | def test_policy_create_forbidden_for_regular_tenants(self): |
| 407 | self.assertRaises( |
| 408 | exceptions.Forbidden, |
| 409 | self.client.create_qos_policy, |
| 410 | 'test-policy', 'test policy', False) |
| 411 | |
Hirofumi Ichihara | 39a6ee1 | 2017-08-23 13:55:12 +0900 | [diff] [blame] | 412 | @decorators.idempotent_id('18d94f22-b9d5-4390-af12-d30a0cfc4cd3') |
| 413 | def test_default_policy_creating_network_without_policy(self): |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 414 | project_id = self.create_project()['id'] |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 415 | policy = self.create_qos_policy(name=self.policy_name, |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 416 | project_id=project_id, |
Hirofumi Ichihara | 39a6ee1 | 2017-08-23 13:55:12 +0900 | [diff] [blame] | 417 | is_default=True) |
| 418 | network = self.create_network('test network', client=self.admin_client, |
| 419 | project_id=project_id) |
Hirofumi Ichihara | 39a6ee1 | 2017-08-23 13:55:12 +0900 | [diff] [blame] | 420 | retrieved_network = self.admin_client.show_network(network['id']) |
| 421 | self.assertEqual( |
| 422 | policy['id'], retrieved_network['network']['qos_policy_id']) |
| 423 | |
| 424 | @decorators.idempotent_id('807cce45-38e5-482d-94db-36e1796aba73') |
| 425 | def test_default_policy_creating_network_with_policy(self): |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 426 | project_id = self.create_project()['id'] |
Hirofumi Ichihara | 39a6ee1 | 2017-08-23 13:55:12 +0900 | [diff] [blame] | 427 | self.create_qos_policy(name='test-policy', |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 428 | project_id=project_id, |
Hirofumi Ichihara | 39a6ee1 | 2017-08-23 13:55:12 +0900 | [diff] [blame] | 429 | is_default=True) |
| 430 | policy = self.create_qos_policy(name='test-policy', |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 431 | project_id=project_id) |
Hirofumi Ichihara | 39a6ee1 | 2017-08-23 13:55:12 +0900 | [diff] [blame] | 432 | network = self.create_network('test network', client=self.admin_client, |
| 433 | project_id=project_id, |
| 434 | qos_policy_id=policy['id']) |
Hirofumi Ichihara | 39a6ee1 | 2017-08-23 13:55:12 +0900 | [diff] [blame] | 435 | retrieved_network = self.admin_client.show_network(network['id']) |
| 436 | self.assertEqual( |
| 437 | policy['id'], retrieved_network['network']['qos_policy_id']) |
| 438 | |
Sławek Kapłoński | 508dd29 | 2018-02-22 13:41:01 +0100 | [diff] [blame] | 439 | @decorators.idempotent_id('06060880-2956-4c16-9a63-f284c3879229') |
| 440 | def test_user_create_port_with_admin_qos_policy(self): |
| 441 | qos_policy = self.create_qos_policy( |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 442 | name=self.policy_name, |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 443 | project_id=self.admin_client.project_id, |
Sławek Kapłoński | 508dd29 | 2018-02-22 13:41:01 +0100 | [diff] [blame] | 444 | shared=False) |
| 445 | network = self.create_network( |
| 446 | 'test network', client=self.admin_client, |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 447 | project_id=self.client.project_id, |
Sławek Kapłoński | 508dd29 | 2018-02-22 13:41:01 +0100 | [diff] [blame] | 448 | qos_policy_id=qos_policy['id']) |
| 449 | port = self.create_port(network) |
| 450 | self.assertEqual(network['id'], port['network_id']) |
| 451 | |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 452 | |
| 453 | class QosBandwidthLimitRuleTestJSON(base.BaseAdminNetworkTest): |
Sławek Kapłoński | 153f345 | 2017-03-24 22:04:53 +0000 | [diff] [blame] | 454 | |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 455 | credentials = ['primary', 'admin'] |
Sławek Kapłoński | 153f345 | 2017-03-24 22:04:53 +0000 | [diff] [blame] | 456 | direction = None |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 457 | required_extensions = [qos_apidef.ALIAS] |
Sławek Kapłoński | 153f345 | 2017-03-24 22:04:53 +0000 | [diff] [blame] | 458 | |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 459 | @classmethod |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 460 | def setup_clients(cls): |
| 461 | super(QosBandwidthLimitRuleTestJSON, cls).setup_clients() |
| 462 | cls.qos_bw_limit_rule_client = \ |
| 463 | cls.os_admin.qos_limit_bandwidth_rules_client |
| 464 | cls.qos_bw_limit_rule_client_primary = \ |
| 465 | cls.os_primary.qos_limit_bandwidth_rules_client |
| 466 | |
| 467 | @classmethod |
YAMAMOTO Takashi | 3bd3d0f | 2016-12-12 11:14:58 +0900 | [diff] [blame] | 468 | @base.require_qos_rule_type(qos_consts.RULE_TYPE_BANDWIDTH_LIMIT) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 469 | def resource_setup(cls): |
| 470 | super(QosBandwidthLimitRuleTestJSON, cls).resource_setup() |
| 471 | |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 472 | def setUp(self): |
| 473 | super(QosBandwidthLimitRuleTestJSON, self).setUp() |
| 474 | self.policy_name = data_utils.rand_name(name='test', prefix='policy') |
| 475 | |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 476 | def _create_qos_bw_limit_rule(self, policy_id, rule_data): |
| 477 | rule = self.qos_bw_limit_rule_client.create_limit_bandwidth_rule( |
| 478 | qos_policy_id=policy_id, |
| 479 | **rule_data)['bandwidth_limit_rule'] |
| 480 | self.addCleanup( |
| 481 | test_utils.call_and_ignore_notfound_exc, |
| 482 | self.qos_bw_limit_rule_client.delete_limit_bandwidth_rule, |
| 483 | policy_id, rule['id']) |
| 484 | return rule |
| 485 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 486 | @decorators.idempotent_id('8a59b00b-3e9c-4787-92f8-93a5cdf5e378') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 487 | def test_rule_create(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 488 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 489 | description='test policy', |
| 490 | shared=False) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 491 | rule = self._create_qos_bw_limit_rule( |
| 492 | policy['id'], |
| 493 | {'max_kbps': 200, 'max_burst_kbps': 1337, 'direction': 'ingress'}) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 494 | |
| 495 | # Test 'show rule' |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 496 | retrieved_rule = \ |
| 497 | self.qos_bw_limit_rule_client.show_limit_bandwidth_rule( |
| 498 | policy['id'], rule['id']) |
| 499 | |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 500 | retrieved_rule = retrieved_rule['bandwidth_limit_rule'] |
| 501 | self.assertEqual(rule['id'], retrieved_rule['id']) |
| 502 | self.assertEqual(200, retrieved_rule['max_kbps']) |
| 503 | self.assertEqual(1337, retrieved_rule['max_burst_kbps']) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 504 | self.assertEqual('ingress', retrieved_rule['direction']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 505 | |
| 506 | # Test 'list rules' |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 507 | rules = self.qos_bw_limit_rule_client.list_limit_bandwidth_rules( |
| 508 | policy['id']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 509 | rules = rules['bandwidth_limit_rules'] |
| 510 | rules_ids = [r['id'] for r in rules] |
| 511 | self.assertIn(rule['id'], rules_ids) |
| 512 | |
| 513 | # Test 'show policy' |
| 514 | retrieved_policy = self.admin_client.show_qos_policy(policy['id']) |
| 515 | policy_rules = retrieved_policy['policy']['rules'] |
| 516 | self.assertEqual(1, len(policy_rules)) |
| 517 | self.assertEqual(rule['id'], policy_rules[0]['id']) |
| 518 | self.assertEqual(qos_consts.RULE_TYPE_BANDWIDTH_LIMIT, |
| 519 | policy_rules[0]['type']) |
| 520 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 521 | @decorators.idempotent_id('8a59b00b-ab01-4787-92f8-93a5cdf5e378') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 522 | def test_rule_create_fail_for_the_same_type(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 523 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 524 | description='test policy', |
| 525 | shared=False) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 526 | self._create_qos_bw_limit_rule( |
| 527 | policy['id'], {'max_kbps': 200, 'max_burst_kbps': 1337}) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 528 | |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 529 | self.assertRaises( |
| 530 | exceptions.Conflict, |
| 531 | self._create_qos_bw_limit_rule, |
| 532 | policy['id'], |
| 533 | {'max_kbps': 201, 'max_burst_kbps': 1338}) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 534 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 535 | @decorators.idempotent_id('149a6988-2568-47d2-931e-2dbc858943b3') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 536 | def test_rule_update(self): |
Slawek Kaplonski | ec162e0 | 2024-03-06 12:21:24 +0100 | [diff] [blame] | 537 | self._test_rule_update(opposite_direction=None) |
| 538 | |
| 539 | def _test_rule_update(self, opposite_direction=None): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 540 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 541 | description='test policy', |
| 542 | shared=False) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 543 | rule = self._create_qos_bw_limit_rule( |
| 544 | policy['id'], {'max_kbps': 1, 'max_burst_kbps': 1}) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 545 | |
Slawek Kaplonski | ec162e0 | 2024-03-06 12:21:24 +0100 | [diff] [blame] | 546 | if opposite_direction: |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 547 | self.qos_bw_limit_rule_client.update_limit_bandwidth_rule( |
| 548 | policy['id'], rule['id'], |
| 549 | **{'max_kbps': 200, 'max_burst_kbps': 1337, |
Slawek Kaplonski | ec162e0 | 2024-03-06 12:21:24 +0100 | [diff] [blame] | 550 | 'direction': opposite_direction}) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 551 | else: |
| 552 | self.qos_bw_limit_rule_client.update_limit_bandwidth_rule( |
| 553 | policy['id'], rule['id'], |
| 554 | **{'max_kbps': 200, 'max_burst_kbps': 1337}) |
| 555 | retrieved_policy = self.qos_bw_limit_rule_client.\ |
| 556 | show_limit_bandwidth_rule(policy['id'], rule['id']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 557 | retrieved_policy = retrieved_policy['bandwidth_limit_rule'] |
| 558 | self.assertEqual(200, retrieved_policy['max_kbps']) |
| 559 | self.assertEqual(1337, retrieved_policy['max_burst_kbps']) |
Slawek Kaplonski | ec162e0 | 2024-03-06 12:21:24 +0100 | [diff] [blame] | 560 | if opposite_direction: |
| 561 | self.assertEqual(opposite_direction, |
Sławek Kapłoński | 153f345 | 2017-03-24 22:04:53 +0000 | [diff] [blame] | 562 | retrieved_policy['direction']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 563 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 564 | @decorators.idempotent_id('67ee6efd-7b33-4a68-927d-275b4f8ba958') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 565 | def test_rule_delete(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 566 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 567 | description='test policy', |
| 568 | shared=False) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 569 | rule = self._create_qos_bw_limit_rule( |
| 570 | policy['id'], {'max_kbps': 200, 'max_burst_kbps': 1337}) |
| 571 | retrieved_policy = \ |
| 572 | self.qos_bw_limit_rule_client.show_limit_bandwidth_rule( |
| 573 | policy['id'], rule['id']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 574 | retrieved_policy = retrieved_policy['bandwidth_limit_rule'] |
| 575 | self.assertEqual(rule['id'], retrieved_policy['id']) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 576 | self.qos_bw_limit_rule_client.delete_limit_bandwidth_rule( |
| 577 | policy['id'], rule['id']) |
| 578 | self.assertRaises( |
| 579 | exceptions.NotFound, |
| 580 | self.qos_bw_limit_rule_client.show_limit_bandwidth_rule, |
| 581 | policy['id'], rule['id']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 582 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 583 | @decorators.idempotent_id('f211222c-5808-46cb-a961-983bbab6b852') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 584 | def test_rule_create_rule_nonexistent_policy(self): |
| 585 | self.assertRaises( |
| 586 | exceptions.NotFound, |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 587 | self._create_qos_bw_limit_rule, |
| 588 | 'policy', {'max_kbps': 200, 'max_burst_kbps': 1337}) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 589 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 590 | @decorators.idempotent_id('a4a2e7ad-786f-4927-a85a-e545a93bd274') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 591 | def test_rule_create_forbidden_for_regular_tenants(self): |
| 592 | self.assertRaises( |
| 593 | exceptions.Forbidden, |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 594 | self.qos_bw_limit_rule_client_primary.create_limit_bandwidth_rule, |
| 595 | 'policy', **{'max_kbps': 1, 'max_burst_kbps': 2}) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 596 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 597 | @decorators.idempotent_id('1bfc55d9-6fd8-4293-ab3a-b1d69bf7cd2e') |
Sławek Kapłoński | 0acecc6 | 2016-08-20 21:00:51 +0000 | [diff] [blame] | 598 | def test_rule_update_forbidden_for_regular_tenants_own_policy(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 599 | policy = self.create_qos_policy(name=self.policy_name, |
Sławek Kapłoński | 0acecc6 | 2016-08-20 21:00:51 +0000 | [diff] [blame] | 600 | description='test policy', |
| 601 | shared=False, |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 602 | project_id=self.client.project_id) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 603 | rule = self._create_qos_bw_limit_rule( |
| 604 | policy['id'], |
| 605 | {'max_kbps': 1, 'max_burst_kbps': 1}) |
Sławek Kapłoński | 0acecc6 | 2016-08-20 21:00:51 +0000 | [diff] [blame] | 606 | self.assertRaises( |
Matthew Edmonds | c13d350 | 2017-04-14 08:22:43 -0400 | [diff] [blame] | 607 | exceptions.Forbidden, |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 608 | self.qos_bw_limit_rule_client_primary.update_limit_bandwidth_rule, |
| 609 | policy['id'], rule['id'], **{'max_kbps': 2, 'max_burst_kbps': 4}) |
Sławek Kapłoński | 0acecc6 | 2016-08-20 21:00:51 +0000 | [diff] [blame] | 610 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 611 | @decorators.idempotent_id('9a607936-4b6f-4c2f-ad21-bd5b3d4fc91f') |
Sławek Kapłoński | 0acecc6 | 2016-08-20 21:00:51 +0000 | [diff] [blame] | 612 | def test_rule_update_forbidden_for_regular_tenants_foreign_policy(self): |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 613 | policy = self.create_qos_policy( |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 614 | name=self.policy_name, |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 615 | description='test policy', |
| 616 | shared=False, |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 617 | project_id=self.admin_client.project_id) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 618 | rule = self._create_qos_bw_limit_rule( |
| 619 | policy['id'], {'max_kbps': 1, 'max_burst_kbps': 1}) |
Sławek Kapłoński | 0acecc6 | 2016-08-20 21:00:51 +0000 | [diff] [blame] | 620 | self.assertRaises( |
| 621 | exceptions.NotFound, |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 622 | self.qos_bw_limit_rule_client_primary.update_limit_bandwidth_rule, |
| 623 | policy['id'], rule['id'], **{'max_kbps': 2, 'max_burst_kbps': 4}) |
Sławek Kapłoński | 0acecc6 | 2016-08-20 21:00:51 +0000 | [diff] [blame] | 624 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 625 | @decorators.idempotent_id('ce0bd0c2-54d9-4e29-85f1-cfb36ac3ebe2') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 626 | def test_get_rules_by_policy(self): |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 627 | policy1 = self.create_qos_policy( |
| 628 | name='test-policy1', |
| 629 | description='test policy1', |
| 630 | shared=False) |
| 631 | rule1 = self._create_qos_bw_limit_rule( |
| 632 | policy1['id'], {'max_kbps': 200, 'max_burst_kbps': 1337}) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 633 | |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 634 | policy2 = self.create_qos_policy( |
| 635 | name='test-policy2', |
| 636 | description='test policy2', |
| 637 | shared=False) |
| 638 | rule2 = self._create_qos_bw_limit_rule( |
| 639 | policy2['id'], {'max_kbps': 5000, 'max_burst_kbps': 2523}) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 640 | |
| 641 | # Test 'list rules' |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 642 | rules = self.qos_bw_limit_rule_client.list_limit_bandwidth_rules( |
| 643 | policy1['id']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 644 | rules = rules['bandwidth_limit_rules'] |
| 645 | rules_ids = [r['id'] for r in rules] |
| 646 | self.assertIn(rule1['id'], rules_ids) |
| 647 | self.assertNotIn(rule2['id'], rules_ids) |
| 648 | |
nfridman | 07f0e78 | 2019-11-04 09:12:58 -0500 | [diff] [blame] | 649 | @testtools.skipUnless( |
| 650 | CONF.neutron_plugin_options.create_shared_resources, |
| 651 | """Creation of shared resources should be allowed, |
| 652 | setting the create_shared_resources option as 'True' is needed""") |
| 653 | @decorators.idempotent_id('d911707e-fa2c-11e9-9553-5076af30bbf5') |
| 654 | def test_attach_and_detach_a_policy_by_a_tenant(self): |
| 655 | # As an admin create an non shared QoS policy,add a rule |
| 656 | # and associate it with a network |
| 657 | self.network = self.create_network() |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 658 | policy = self.create_qos_policy(name=self.policy_name, |
nfridman | 07f0e78 | 2019-11-04 09:12:58 -0500 | [diff] [blame] | 659 | description='test policy for attach', |
| 660 | shared=False) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 661 | self._create_qos_bw_limit_rule( |
| 662 | policy['id'], {'max_kbps': 1024, 'max_burst_kbps': 1024}) |
nfridman | 07f0e78 | 2019-11-04 09:12:58 -0500 | [diff] [blame] | 663 | |
| 664 | self.admin_client.update_network( |
| 665 | self.network['id'], qos_policy_id=policy['id']) |
| 666 | |
| 667 | # As a tenant, try to detach the policy from the network |
| 668 | # The operation should be forbidden |
| 669 | self.assertRaises( |
| 670 | exceptions.Forbidden, |
| 671 | self.client.update_network, |
| 672 | self.network['id'], qos_policy_id=None) |
| 673 | |
| 674 | # As an admin, make the policy shared |
| 675 | self.admin_client.update_qos_policy(policy['id'], shared=True) |
| 676 | |
| 677 | # As a tenant, try to detach the policy from the network |
| 678 | # The operation should be allowed |
| 679 | self.client.update_network(self.network['id'], |
| 680 | qos_policy_id=None) |
| 681 | |
| 682 | retrieved_network = self.admin_client.show_network(self.network['id']) |
| 683 | self.assertIsNone(retrieved_network['network']['qos_policy_id']) |
| 684 | |
| 685 | # As a tenant, try to delete the policy from the network |
| 686 | # should be forbidden |
| 687 | self.assertRaises( |
| 688 | exceptions.Forbidden, |
| 689 | self.client.delete_qos_policy, |
| 690 | policy['id']) |
| 691 | |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 692 | |
Slawek Kaplonski | ec162e0 | 2024-03-06 12:21:24 +0100 | [diff] [blame] | 693 | @ddt.ddt |
Sławek Kapłoński | 153f345 | 2017-03-24 22:04:53 +0000 | [diff] [blame] | 694 | class QosBandwidthLimitRuleWithDirectionTestJSON( |
Brian Haley | 6767cec | 2018-04-10 15:30:23 -0400 | [diff] [blame] | 695 | QosBandwidthLimitRuleTestJSON): |
Jakub Libosvar | 1982aa1 | 2017-05-30 11:15:33 +0000 | [diff] [blame] | 696 | required_extensions = ( |
| 697 | QosBandwidthLimitRuleTestJSON.required_extensions + |
| 698 | ['qos-bw-limit-direction'] |
| 699 | ) |
Sławek Kapłoński | 153f345 | 2017-03-24 22:04:53 +0000 | [diff] [blame] | 700 | |
nfridman | 7717d9c | 2019-11-25 08:58:04 -0500 | [diff] [blame] | 701 | @classmethod |
| 702 | @base.require_qos_rule_type(qos_consts.RULE_TYPE_BANDWIDTH_LIMIT) |
| 703 | def resource_setup(cls): |
| 704 | super(QosBandwidthLimitRuleWithDirectionTestJSON, cls).resource_setup() |
| 705 | |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 706 | def setUp(self): |
| 707 | super(QosBandwidthLimitRuleWithDirectionTestJSON, self).setUp() |
| 708 | self.policy_name = data_utils.rand_name(name='test', prefix='policy') |
| 709 | |
nfridman | 7717d9c | 2019-11-25 08:58:04 -0500 | [diff] [blame] | 710 | @decorators.idempotent_id('c8cbe502-0f7e-11ea-8d71-362b9e155667') |
| 711 | def test_create_policy_with_multiple_rules(self): |
| 712 | # Create a policy with multiple rules |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 713 | policy = self.create_qos_policy(name=self.policy_name, |
nfridman | 7717d9c | 2019-11-25 08:58:04 -0500 | [diff] [blame] | 714 | description='test policy1', |
| 715 | shared=False) |
| 716 | |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 717 | rule1 = self._create_qos_bw_limit_rule( |
| 718 | policy['id'], {'max_kbps': 1024, 'max_burst_kbps': 1024, |
| 719 | 'direction': n_constants.EGRESS_DIRECTION}) |
| 720 | rule2 = self._create_qos_bw_limit_rule( |
| 721 | policy['id'], {'max_kbps': 1024, 'max_burst_kbps': 1024, |
| 722 | 'direction': n_constants.INGRESS_DIRECTION}) |
nfridman | 7717d9c | 2019-11-25 08:58:04 -0500 | [diff] [blame] | 723 | # Check that the rules were added to the policy |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 724 | rules = self.qos_bw_limit_rule_client.list_limit_bandwidth_rules( |
nfridman | 7717d9c | 2019-11-25 08:58:04 -0500 | [diff] [blame] | 725 | policy['id'])['bandwidth_limit_rules'] |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 726 | |
nfridman | 7717d9c | 2019-11-25 08:58:04 -0500 | [diff] [blame] | 727 | rules_ids = [rule['id'] for rule in rules] |
| 728 | self.assertIn(rule1['id'], rules_ids) |
| 729 | self.assertIn(rule2['id'], rules_ids) |
| 730 | |
| 731 | # Check that the rules creation fails for the same rule types |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 732 | self.assertRaises( |
| 733 | exceptions.Conflict, |
| 734 | self._create_qos_bw_limit_rule, |
| 735 | policy['id'], |
| 736 | {'max_kbps': 1025, 'max_burst_kbps': 1025, |
| 737 | 'direction': n_constants.EGRESS_DIRECTION}) |
nfridman | 7717d9c | 2019-11-25 08:58:04 -0500 | [diff] [blame] | 738 | |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 739 | self.assertRaises( |
| 740 | exceptions.Conflict, |
| 741 | self._create_qos_bw_limit_rule, |
| 742 | policy['id'], |
| 743 | {'max_kbps': 1025, 'max_burst_kbps': 1025, |
| 744 | 'direction': n_constants.INGRESS_DIRECTION}) |
nfridman | 7717d9c | 2019-11-25 08:58:04 -0500 | [diff] [blame] | 745 | |
Slawek Kaplonski | ec162e0 | 2024-03-06 12:21:24 +0100 | [diff] [blame] | 746 | @decorators.idempotent_id('7ca7c83b-0555-4a0f-a422-4338f77f79e5') |
| 747 | @ddt.unpack |
| 748 | @ddt.data({'opposite_direction': 'ingress'}, |
| 749 | {'opposite_direction': 'egress'}) |
| 750 | def test_rule_update(self, opposite_direction): |
| 751 | self._test_rule_update(opposite_direction=opposite_direction) |
| 752 | |
Sławek Kapłoński | 153f345 | 2017-03-24 22:04:53 +0000 | [diff] [blame] | 753 | |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 754 | class RbacSharedQosPoliciesTest(base.BaseAdminNetworkTest): |
| 755 | |
| 756 | force_tenant_isolation = True |
| 757 | credentials = ['primary', 'alt', 'admin'] |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 758 | required_extensions = [qos_apidef.ALIAS] |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 759 | |
| 760 | @classmethod |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 761 | def resource_setup(cls): |
| 762 | super(RbacSharedQosPoliciesTest, cls).resource_setup() |
rajat29 | 4495c04 | 2017-06-28 15:37:16 +0530 | [diff] [blame] | 763 | cls.client2 = cls.os_alt.network_client |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 764 | |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 765 | def _create_qos_policy(self, project_id=None): |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 766 | args = {'name': data_utils.rand_name('test-policy'), |
| 767 | 'description': 'test policy', |
| 768 | 'shared': False, |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 769 | 'project_id': project_id} |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 770 | qos_policy = self.admin_client.create_qos_policy(**args)['policy'] |
| 771 | self.addCleanup(self.admin_client.delete_qos_policy, qos_policy['id']) |
| 772 | |
| 773 | return qos_policy |
| 774 | |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 775 | def _make_admin_policy_shared_to_project_id(self, project_id): |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 776 | policy = self._create_qos_policy() |
| 777 | rbac_policy = self.admin_client.create_rbac_policy( |
| 778 | object_type='qos_policy', |
| 779 | object_id=policy['id'], |
| 780 | action='access_as_shared', |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 781 | target_tenant=project_id, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 782 | )['rbac_policy'] |
| 783 | |
| 784 | return {'policy': policy, 'rbac_policy': rbac_policy} |
| 785 | |
| 786 | def _create_network(self, qos_policy_id, client, should_cleanup=True): |
| 787 | net = client.create_network( |
| 788 | name=data_utils.rand_name('test-network'), |
| 789 | qos_policy_id=qos_policy_id)['network'] |
| 790 | if should_cleanup: |
| 791 | self.addCleanup(client.delete_network, net['id']) |
| 792 | |
| 793 | return net |
| 794 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 795 | @decorators.idempotent_id('b9dcf582-d3b3-11e5-950a-54ee756c66df') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 796 | def test_policy_sharing_with_wildcard(self): |
| 797 | qos_pol = self.create_qos_policy( |
| 798 | name=data_utils.rand_name('test-policy'), |
Rodolfo Alonso Hernandez | 1e9d1fe | 2017-02-01 15:15:16 +0000 | [diff] [blame] | 799 | description='test-shared-policy', shared=False, |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 800 | project_id=self.admin_client.project_id) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 801 | self.assertNotIn(qos_pol, self.client2.list_qos_policies()['policies']) |
| 802 | |
| 803 | # test update shared False -> True |
| 804 | self.admin_client.update_qos_policy(qos_pol['id'], shared=True) |
| 805 | qos_pol['shared'] = True |
| 806 | self.client2.show_qos_policy(qos_pol['id']) |
| 807 | rbac_pol = {'target_tenant': '*', |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 808 | 'tenant_id': self.admin_client.project_id, |
| 809 | 'project_id': self.admin_client.project_id, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 810 | 'object_type': 'qos_policy', |
| 811 | 'object_id': qos_pol['id'], |
| 812 | 'action': 'access_as_shared'} |
| 813 | |
| 814 | rbac_policies = self.admin_client.list_rbac_policies()['rbac_policies'] |
| 815 | rbac_policies = [r for r in rbac_policies if r.pop('id')] |
| 816 | self.assertIn(rbac_pol, rbac_policies) |
| 817 | |
| 818 | # update shared True -> False should fail because the policy is bound |
| 819 | # to a network |
| 820 | net = self._create_network(qos_pol['id'], self.admin_client, False) |
| 821 | with testtools.ExpectedException(exceptions.Conflict): |
| 822 | self.admin_client.update_qos_policy(qos_pol['id'], shared=False) |
| 823 | |
| 824 | # delete the network, and update shared True -> False should pass now |
| 825 | self.admin_client.delete_network(net['id']) |
| 826 | self.admin_client.update_qos_policy(qos_pol['id'], shared=False) |
| 827 | qos_pol['shared'] = False |
| 828 | self.assertNotIn(qos_pol, self.client2.list_qos_policies()['policies']) |
| 829 | |
| 830 | def _create_net_bound_qos_rbacs(self): |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 831 | res = self._make_admin_policy_shared_to_project_id( |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 832 | self.client.project_id) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 833 | qos_policy, rbac_for_client_tenant = res['policy'], res['rbac_policy'] |
| 834 | |
| 835 | # add a wildcard rbac rule - now the policy globally shared |
| 836 | rbac_wildcard = self.admin_client.create_rbac_policy( |
| 837 | object_type='qos_policy', |
| 838 | object_id=qos_policy['id'], |
| 839 | action='access_as_shared', |
| 840 | target_tenant='*', |
| 841 | )['rbac_policy'] |
| 842 | |
| 843 | # tenant1 now uses qos policy for net |
| 844 | self._create_network(qos_policy['id'], self.client) |
| 845 | |
| 846 | return rbac_for_client_tenant, rbac_wildcard |
| 847 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 848 | @decorators.idempotent_id('328b1f70-d424-11e5-a57f-54ee756c66df') |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 849 | def test_net_bound_shared_policy_wildcard_and_project_id_wild_remove(self): |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 850 | client_rbac, wildcard_rbac = self._create_net_bound_qos_rbacs() |
| 851 | # globally unshare the qos-policy, the specific share should remain |
| 852 | self.admin_client.delete_rbac_policy(wildcard_rbac['id']) |
| 853 | self.client.list_rbac_policies(id=client_rbac['id']) |
| 854 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 855 | @decorators.idempotent_id('1997b00c-0c75-4e43-8ce2-999f9fa555ee') |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 856 | def test_net_bound_shared_policy_wildcard_and_projectid_wild_remains(self): |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 857 | client_rbac, wildcard_rbac = self._create_net_bound_qos_rbacs() |
| 858 | # remove client_rbac policy the wildcard share should remain |
| 859 | self.admin_client.delete_rbac_policy(client_rbac['id']) |
| 860 | self.client.list_rbac_policies(id=wildcard_rbac['id']) |
| 861 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 862 | @decorators.idempotent_id('2ace9adc-da6e-11e5-aafe-54ee756c66df') |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 863 | def test_policy_sharing_with_wildcard_and_project_id(self): |
| 864 | res = self._make_admin_policy_shared_to_project_id( |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 865 | self.client.project_id) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 866 | qos_policy, rbac = res['policy'], res['rbac_policy'] |
| 867 | qos_pol = self.client.show_qos_policy(qos_policy['id'])['policy'] |
| 868 | self.assertTrue(qos_pol['shared']) |
| 869 | with testtools.ExpectedException(exceptions.NotFound): |
| 870 | self.client2.show_qos_policy(qos_policy['id']) |
| 871 | |
| 872 | # make the qos-policy globally shared |
| 873 | self.admin_client.update_qos_policy(qos_policy['id'], shared=True) |
| 874 | qos_pol = self.client2.show_qos_policy(qos_policy['id'])['policy'] |
| 875 | self.assertTrue(qos_pol['shared']) |
| 876 | |
| 877 | # globally unshare the qos-policy, the specific share should remain |
| 878 | self.admin_client.update_qos_policy(qos_policy['id'], shared=False) |
| 879 | self.client.show_qos_policy(qos_policy['id']) |
| 880 | with testtools.ExpectedException(exceptions.NotFound): |
| 881 | self.client2.show_qos_policy(qos_policy['id']) |
| 882 | self.assertIn(rbac, |
| 883 | self.admin_client.list_rbac_policies()['rbac_policies']) |
| 884 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 885 | @decorators.idempotent_id('9f85c76a-a350-11e5-8ae5-54ee756c66df') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 886 | def test_policy_target_update(self): |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 887 | res = self._make_admin_policy_shared_to_project_id( |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 888 | self.client.project_id) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 889 | # change to client2 |
| 890 | update_res = self.admin_client.update_rbac_policy( |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 891 | res['rbac_policy']['id'], target_tenant=self.client2.project_id) |
| 892 | self.assertEqual(self.client2.project_id, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 893 | update_res['rbac_policy']['target_tenant']) |
| 894 | # make sure everything else stayed the same |
| 895 | res['rbac_policy'].pop('target_tenant') |
| 896 | update_res['rbac_policy'].pop('target_tenant') |
| 897 | self.assertEqual(res['rbac_policy'], update_res['rbac_policy']) |
| 898 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 899 | @decorators.idempotent_id('a9b39f46-a350-11e5-97c7-54ee756c66df') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 900 | def test_network_presence_prevents_policy_rbac_policy_deletion(self): |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 901 | res = self._make_admin_policy_shared_to_project_id( |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 902 | self.client2.project_id) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 903 | qos_policy_id = res['policy']['id'] |
| 904 | self._create_network(qos_policy_id, self.client2) |
| 905 | # a network with shared qos-policy should prevent the deletion of an |
| 906 | # rbac-policy required for it to be shared |
| 907 | with testtools.ExpectedException(exceptions.Conflict): |
| 908 | self.admin_client.delete_rbac_policy(res['rbac_policy']['id']) |
| 909 | |
| 910 | # a wildcard policy should allow the specific policy to be deleted |
| 911 | # since it allows the remaining port |
| 912 | wild = self.admin_client.create_rbac_policy( |
| 913 | object_type='qos_policy', object_id=res['policy']['id'], |
| 914 | action='access_as_shared', target_tenant='*')['rbac_policy'] |
| 915 | self.admin_client.delete_rbac_policy(res['rbac_policy']['id']) |
| 916 | |
| 917 | # now that wildcard is the only remaining, it should be subjected to |
| 918 | # the same restriction |
| 919 | with testtools.ExpectedException(exceptions.Conflict): |
| 920 | self.admin_client.delete_rbac_policy(wild['id']) |
| 921 | |
| 922 | # we can't update the policy to a different tenant |
| 923 | with testtools.ExpectedException(exceptions.Conflict): |
| 924 | self.admin_client.update_rbac_policy( |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 925 | wild['id'], target_tenant=self.client2.project_id) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 926 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 927 | @decorators.idempotent_id('b0fe87e8-a350-11e5-9f08-54ee756c66df') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 928 | def test_regular_client_shares_to_another_regular_client(self): |
| 929 | # owned by self.admin_client |
| 930 | policy = self._create_qos_policy() |
| 931 | with testtools.ExpectedException(exceptions.NotFound): |
| 932 | self.client.show_qos_policy(policy['id']) |
| 933 | rbac_policy = self.admin_client.create_rbac_policy( |
| 934 | object_type='qos_policy', object_id=policy['id'], |
| 935 | action='access_as_shared', |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 936 | target_tenant=self.client.project_id)['rbac_policy'] |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 937 | self.client.show_qos_policy(policy['id']) |
| 938 | |
| 939 | self.assertIn(rbac_policy, |
| 940 | self.admin_client.list_rbac_policies()['rbac_policies']) |
| 941 | # ensure that 'client2' can't see the rbac-policy sharing the |
| 942 | # qos-policy to it because the rbac-policy belongs to 'client' |
| 943 | self.assertNotIn(rbac_policy['id'], [p['id'] for p in |
| 944 | self.client2.list_rbac_policies()['rbac_policies']]) |
| 945 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 946 | @decorators.idempotent_id('ba88d0ca-a350-11e5-a06f-54ee756c66df') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 947 | def test_filter_fields(self): |
| 948 | policy = self._create_qos_policy() |
| 949 | self.admin_client.create_rbac_policy( |
| 950 | object_type='qos_policy', object_id=policy['id'], |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 951 | action='access_as_shared', target_tenant=self.client2.project_id) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 952 | field_args = (('id',), ('id', 'action'), ('object_type', 'object_id'), |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 953 | ('project_id', 'target_tenant')) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 954 | for fields in field_args: |
| 955 | res = self.admin_client.list_rbac_policies(fields=fields) |
| 956 | self.assertEqual(set(fields), set(res['rbac_policies'][0].keys())) |
| 957 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 958 | @decorators.idempotent_id('c10d993a-a350-11e5-9c7a-54ee756c66df') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 959 | def test_rbac_policy_show(self): |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 960 | res = self._make_admin_policy_shared_to_project_id( |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 961 | self.client.project_id) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 962 | p1 = res['rbac_policy'] |
| 963 | p2 = self.admin_client.create_rbac_policy( |
| 964 | object_type='qos_policy', object_id=res['policy']['id'], |
| 965 | action='access_as_shared', |
| 966 | target_tenant='*')['rbac_policy'] |
| 967 | |
| 968 | self.assertEqual( |
| 969 | p1, self.admin_client.show_rbac_policy(p1['id'])['rbac_policy']) |
| 970 | self.assertEqual( |
| 971 | p2, self.admin_client.show_rbac_policy(p2['id'])['rbac_policy']) |
| 972 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 973 | @decorators.idempotent_id('c7496f86-a350-11e5-b380-54ee756c66df') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 974 | def test_filter_rbac_policies(self): |
| 975 | policy = self._create_qos_policy() |
| 976 | rbac_pol1 = self.admin_client.create_rbac_policy( |
| 977 | object_type='qos_policy', object_id=policy['id'], |
| 978 | action='access_as_shared', |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 979 | target_tenant=self.client2.project_id)['rbac_policy'] |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 980 | rbac_pol2 = self.admin_client.create_rbac_policy( |
| 981 | object_type='qos_policy', object_id=policy['id'], |
| 982 | action='access_as_shared', |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 983 | target_tenant=self.admin_client.project_id)['rbac_policy'] |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 984 | res1 = self.admin_client.list_rbac_policies(id=rbac_pol1['id'])[ |
| 985 | 'rbac_policies'] |
| 986 | res2 = self.admin_client.list_rbac_policies(id=rbac_pol2['id'])[ |
| 987 | 'rbac_policies'] |
| 988 | self.assertEqual(1, len(res1)) |
| 989 | self.assertEqual(1, len(res2)) |
| 990 | self.assertEqual(rbac_pol1['id'], res1[0]['id']) |
| 991 | self.assertEqual(rbac_pol2['id'], res2[0]['id']) |
| 992 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 993 | @decorators.idempotent_id('cd7d755a-a350-11e5-a344-54ee756c66df') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 994 | def test_regular_client_blocked_from_sharing_anothers_policy(self): |
Rodolfo Alonso Hernandez | e2d062f | 2020-01-14 17:11:42 +0000 | [diff] [blame] | 995 | qos_policy = self._make_admin_policy_shared_to_project_id( |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 996 | self.client.project_id)['policy'] |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 997 | with testtools.ExpectedException(exceptions.BadRequest): |
| 998 | self.client.create_rbac_policy( |
| 999 | object_type='qos_policy', object_id=qos_policy['id'], |
| 1000 | action='access_as_shared', |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 1001 | target_tenant=self.client2.project_id) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1002 | |
| 1003 | # make sure the rbac-policy is invisible to the tenant for which it's |
| 1004 | # being shared |
| 1005 | self.assertFalse(self.client.list_rbac_policies()['rbac_policies']) |
| 1006 | |
| 1007 | |
| 1008 | class QosDscpMarkingRuleTestJSON(base.BaseAdminNetworkTest): |
| 1009 | VALID_DSCP_MARK1 = 56 |
| 1010 | VALID_DSCP_MARK2 = 48 |
| 1011 | |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 1012 | required_extensions = [qos_apidef.ALIAS] |
Jakub Libosvar | 1982aa1 | 2017-05-30 11:15:33 +0000 | [diff] [blame] | 1013 | |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1014 | @classmethod |
YAMAMOTO Takashi | 3bd3d0f | 2016-12-12 11:14:58 +0900 | [diff] [blame] | 1015 | @base.require_qos_rule_type(qos_consts.RULE_TYPE_DSCP_MARKING) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1016 | def resource_setup(cls): |
| 1017 | super(QosDscpMarkingRuleTestJSON, cls).resource_setup() |
| 1018 | |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1019 | def setUp(self): |
| 1020 | super(QosDscpMarkingRuleTestJSON, self).setUp() |
| 1021 | self.policy_name = data_utils.rand_name(name='test', prefix='policy') |
| 1022 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1023 | @decorators.idempotent_id('f5cbaceb-5829-497c-9c60-ad70969e9a08') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1024 | def test_rule_create(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1025 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1026 | description='test policy', |
| 1027 | shared=False) |
| 1028 | rule = self.admin_client.create_dscp_marking_rule( |
| 1029 | policy['id'], self.VALID_DSCP_MARK1)['dscp_marking_rule'] |
| 1030 | |
| 1031 | # Test 'show rule' |
| 1032 | retrieved_rule = self.admin_client.show_dscp_marking_rule( |
| 1033 | policy['id'], rule['id']) |
| 1034 | retrieved_rule = retrieved_rule['dscp_marking_rule'] |
| 1035 | self.assertEqual(rule['id'], retrieved_rule['id']) |
| 1036 | self.assertEqual(self.VALID_DSCP_MARK1, retrieved_rule['dscp_mark']) |
| 1037 | |
| 1038 | # Test 'list rules' |
| 1039 | rules = self.admin_client.list_dscp_marking_rules(policy['id']) |
| 1040 | rules = rules['dscp_marking_rules'] |
| 1041 | rules_ids = [r['id'] for r in rules] |
| 1042 | self.assertIn(rule['id'], rules_ids) |
| 1043 | |
| 1044 | # Test 'show policy' |
| 1045 | retrieved_policy = self.admin_client.show_qos_policy(policy['id']) |
| 1046 | policy_rules = retrieved_policy['policy']['rules'] |
| 1047 | self.assertEqual(1, len(policy_rules)) |
| 1048 | self.assertEqual(rule['id'], policy_rules[0]['id']) |
David Shaughnessy | dbf2482 | 2016-03-14 16:27:54 +0000 | [diff] [blame] | 1049 | self.assertEqual(qos_consts.RULE_TYPE_DSCP_MARKING, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1050 | policy_rules[0]['type']) |
| 1051 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1052 | @decorators.idempotent_id('08553ffe-030f-4037-b486-7e0b8fb9385a') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1053 | def test_rule_create_fail_for_the_same_type(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1054 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1055 | description='test policy', |
| 1056 | shared=False) |
| 1057 | self.admin_client.create_dscp_marking_rule( |
| 1058 | policy['id'], self.VALID_DSCP_MARK1)['dscp_marking_rule'] |
| 1059 | |
| 1060 | self.assertRaises(exceptions.Conflict, |
| 1061 | self.admin_client.create_dscp_marking_rule, |
| 1062 | policy_id=policy['id'], |
| 1063 | dscp_mark=self.VALID_DSCP_MARK2) |
| 1064 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1065 | @decorators.idempotent_id('76f632e5-3175-4408-9a32-3625e599c8a2') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1066 | def test_rule_update(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1067 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1068 | description='test policy', |
| 1069 | shared=False) |
| 1070 | rule = self.admin_client.create_dscp_marking_rule( |
| 1071 | policy['id'], self.VALID_DSCP_MARK1)['dscp_marking_rule'] |
| 1072 | |
| 1073 | self.admin_client.update_dscp_marking_rule( |
| 1074 | policy['id'], rule['id'], dscp_mark=self.VALID_DSCP_MARK2) |
| 1075 | |
| 1076 | retrieved_policy = self.admin_client.show_dscp_marking_rule( |
| 1077 | policy['id'], rule['id']) |
| 1078 | retrieved_policy = retrieved_policy['dscp_marking_rule'] |
| 1079 | self.assertEqual(self.VALID_DSCP_MARK2, retrieved_policy['dscp_mark']) |
| 1080 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1081 | @decorators.idempotent_id('74f81904-c35f-48a3-adae-1f5424cb3c18') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1082 | def test_rule_delete(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1083 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1084 | description='test policy', |
| 1085 | shared=False) |
| 1086 | rule = self.admin_client.create_dscp_marking_rule( |
| 1087 | policy['id'], self.VALID_DSCP_MARK1)['dscp_marking_rule'] |
| 1088 | |
| 1089 | retrieved_policy = self.admin_client.show_dscp_marking_rule( |
| 1090 | policy['id'], rule['id']) |
| 1091 | retrieved_policy = retrieved_policy['dscp_marking_rule'] |
| 1092 | self.assertEqual(rule['id'], retrieved_policy['id']) |
| 1093 | |
| 1094 | self.admin_client.delete_dscp_marking_rule(policy['id'], rule['id']) |
| 1095 | self.assertRaises(exceptions.NotFound, |
| 1096 | self.admin_client.show_dscp_marking_rule, |
| 1097 | policy['id'], rule['id']) |
| 1098 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1099 | @decorators.idempotent_id('9cb8ef5c-96fc-4978-9ee0-e3b02bab628a') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1100 | def test_rule_create_rule_nonexistent_policy(self): |
| 1101 | self.assertRaises( |
| 1102 | exceptions.NotFound, |
| 1103 | self.admin_client.create_dscp_marking_rule, |
| 1104 | 'policy', self.VALID_DSCP_MARK1) |
| 1105 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1106 | @decorators.idempotent_id('bf6002ea-29de-486f-b65d-08aea6d4c4e2') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1107 | def test_rule_create_forbidden_for_regular_tenants(self): |
| 1108 | self.assertRaises( |
| 1109 | exceptions.Forbidden, |
| 1110 | self.client.create_dscp_marking_rule, |
| 1111 | 'policy', self.VALID_DSCP_MARK1) |
| 1112 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1113 | @decorators.idempotent_id('33646b08-4f05-4493-a48a-bde768a18533') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1114 | def test_invalid_rule_create(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1115 | policy = self.create_qos_policy(name=self.policy_name, |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1116 | description='test policy', |
| 1117 | shared=False) |
| 1118 | self.assertRaises( |
| 1119 | exceptions.BadRequest, |
| 1120 | self.admin_client.create_dscp_marking_rule, |
| 1121 | policy['id'], 58) |
| 1122 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1123 | @decorators.idempotent_id('c565131d-4c80-4231-b0f3-9ae2be4de129') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1124 | def test_get_rules_by_policy(self): |
| 1125 | policy1 = self.create_qos_policy(name='test-policy1', |
| 1126 | description='test policy1', |
| 1127 | shared=False) |
| 1128 | rule1 = self.admin_client.create_dscp_marking_rule( |
| 1129 | policy1['id'], self.VALID_DSCP_MARK1)['dscp_marking_rule'] |
| 1130 | |
| 1131 | policy2 = self.create_qos_policy(name='test-policy2', |
| 1132 | description='test policy2', |
| 1133 | shared=False) |
| 1134 | rule2 = self.admin_client.create_dscp_marking_rule( |
| 1135 | policy2['id'], self.VALID_DSCP_MARK2)['dscp_marking_rule'] |
| 1136 | |
| 1137 | # Test 'list rules' |
| 1138 | rules = self.admin_client.list_dscp_marking_rules(policy1['id']) |
| 1139 | rules = rules['dscp_marking_rules'] |
| 1140 | rules_ids = [r['id'] for r in rules] |
| 1141 | self.assertIn(rule1['id'], rules_ids) |
| 1142 | self.assertNotIn(rule2['id'], rules_ids) |
Ihar Hrachyshka | b7940d9 | 2016-06-10 13:44:22 +0200 | [diff] [blame] | 1143 | |
nfridman | 23b44ad | 2019-09-05 09:46:50 -0400 | [diff] [blame] | 1144 | @decorators.idempotent_id('19ed2286-ccb1-11e9-87d7-525400d6f522') |
| 1145 | def test_qos_dscp_create_and_update(self): |
| 1146 | """This test covers: |
| 1147 | |
| 1148 | 1.Creating a basic QoS policy with DSCP marking rule. |
| 1149 | 2.Updating QoS policy: |
| 1150 | Administrator should have the ability to update existing QoS policy. |
| 1151 | This test should verify that: |
| 1152 | It's possible to update the existing DSCP marking rule with all of |
| 1153 | the valid marks between 0-56, except of the invalid marks: |
| 1154 | 2-6, 42, 44, and 50-54 (which should be forbidden) |
| 1155 | """ |
| 1156 | |
Rodolfo Alonso Hernandez | 3de3cd9 | 2022-08-23 21:41:02 +0200 | [diff] [blame] | 1157 | def _test_update_dscp_mark_values(self, dscp_policy_id, rule_id, |
| 1158 | valid_dscp_marks): |
| 1159 | for mark in range(valid_dscp_marks[1], self.VALID_DSCP_MARK1 + 1): |
| 1160 | if mark in valid_dscp_marks: |
nfridman | 23b44ad | 2019-09-05 09:46:50 -0400 | [diff] [blame] | 1161 | self.admin_client.update_dscp_marking_rule( |
| 1162 | dscp_policy_id, rule_id, dscp_mark=mark) |
| 1163 | |
| 1164 | retrieved_rule = self.admin_client.show_dscp_marking_rule( |
| 1165 | dscp_policy_id, rule_id)['dscp_marking_rule'] |
| 1166 | self.assertEqual(mark, retrieved_rule['dscp_mark'], |
| 1167 | """current DSCP mark is incorrect: |
| 1168 | expected value {0} actual value {1} |
| 1169 | """.format(mark, |
| 1170 | retrieved_rule['dscp_mark'])) |
| 1171 | |
| 1172 | else: |
| 1173 | self.assertRaises(exceptions.BadRequest, |
| 1174 | self.admin_client.create_dscp_marking_rule, |
| 1175 | dscp_policy_id, |
| 1176 | mark) |
Rodolfo Alonso Hernandez | 3de3cd9 | 2022-08-23 21:41:02 +0200 | [diff] [blame] | 1177 | |
| 1178 | # Retrieve the valid range of DSCP marks from the API. |
| 1179 | rule_type_details = self.admin_client.show_qos_rule_type( |
| 1180 | qos_consts.RULE_TYPE_DSCP_MARKING).get('rule_type') |
| 1181 | # There should be at least one driver supporting the DSCP marking rule. |
| 1182 | dscp_driver = rule_type_details['drivers'][0] |
| 1183 | for parameter in dscp_driver['supported_parameters']: |
| 1184 | if parameter['parameter_name'] == qos_consts.DSCP_MARK: |
| 1185 | valid_dscp_marks = parameter['parameter_values'] |
| 1186 | break |
| 1187 | else: |
| 1188 | self.fail('The DSCP marking rule does not have the %s parameter' % |
| 1189 | qos_consts.DSCP_MARK) |
| 1190 | |
nfridman | 23b44ad | 2019-09-05 09:46:50 -0400 | [diff] [blame] | 1191 | # Setup network |
| 1192 | self.network = self.create_network() |
| 1193 | |
| 1194 | # Create QoS policy |
| 1195 | dscp_policy_id = self.create_qos_policy( |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1196 | name=self.policy_name, |
nfridman | 23b44ad | 2019-09-05 09:46:50 -0400 | [diff] [blame] | 1197 | description='test-qos-policy', |
Slawek Kaplonski | fdfb474 | 2023-05-10 12:48:49 +0200 | [diff] [blame] | 1198 | project_id=self.client.project_id, |
nfridman | 23b44ad | 2019-09-05 09:46:50 -0400 | [diff] [blame] | 1199 | shared=True)['id'] |
| 1200 | |
| 1201 | # Associate QoS to the network |
| 1202 | self.admin_client.update_network( |
| 1203 | self.network['id'], qos_policy_id=dscp_policy_id) |
| 1204 | |
| 1205 | # Set a new DSCP rule with the first mark in range |
| 1206 | rule_id = self.admin_client.create_dscp_marking_rule( |
| 1207 | dscp_policy_id, |
| 1208 | n_constants.VALID_DSCP_MARKS[0])[ |
| 1209 | 'dscp_marking_rule']['id'] |
| 1210 | |
| 1211 | # Validate that the rule was set up properly |
| 1212 | retrieved_rule = self.client.show_dscp_marking_rule( |
| 1213 | dscp_policy_id, rule_id)['dscp_marking_rule'] |
| 1214 | self.assertEqual(n_constants.VALID_DSCP_MARKS[0], |
| 1215 | retrieved_rule['dscp_mark'], |
| 1216 | """current DSCP mark is incorrect: |
| 1217 | expected value {0} actual value {1} |
| 1218 | """.format(n_constants.VALID_DSCP_MARKS[0], |
| 1219 | retrieved_rule['dscp_mark'])) |
| 1220 | |
| 1221 | # Try to set marks in range 8:56 (invalid marks should raise an error) |
Rodolfo Alonso Hernandez | 3de3cd9 | 2022-08-23 21:41:02 +0200 | [diff] [blame] | 1222 | _test_update_dscp_mark_values(self, dscp_policy_id, rule_id, |
| 1223 | valid_dscp_marks) |
nfridman | 23b44ad | 2019-09-05 09:46:50 -0400 | [diff] [blame] | 1224 | |
Ihar Hrachyshka | b7940d9 | 2016-06-10 13:44:22 +0200 | [diff] [blame] | 1225 | |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1226 | class QosMinimumBandwidthRuleTestJSON(base.BaseAdminNetworkTest): |
| 1227 | DIRECTION_EGRESS = "egress" |
| 1228 | DIRECTION_INGRESS = "ingress" |
| 1229 | RULE_NAME = qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH + "_rule" |
| 1230 | RULES_NAME = RULE_NAME + "s" |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 1231 | required_extensions = [qos_apidef.ALIAS] |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1232 | |
| 1233 | @classmethod |
YAMAMOTO Takashi | 3bd3d0f | 2016-12-12 11:14:58 +0900 | [diff] [blame] | 1234 | @base.require_qos_rule_type(qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH) |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1235 | def resource_setup(cls): |
| 1236 | super(QosMinimumBandwidthRuleTestJSON, cls).resource_setup() |
| 1237 | |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1238 | @classmethod |
| 1239 | def setup_clients(cls): |
| 1240 | super(QosMinimumBandwidthRuleTestJSON, cls).setup_clients() |
| 1241 | cls.qos_min_bw_rules_client = \ |
| 1242 | cls.os_admin.qos_minimum_bandwidth_rules_client |
| 1243 | cls.qos_min_bw_rules_client_primary = \ |
| 1244 | cls.os_primary.qos_minimum_bandwidth_rules_client |
| 1245 | |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1246 | def setUp(self): |
| 1247 | super(QosMinimumBandwidthRuleTestJSON, self).setUp() |
| 1248 | self.policy_name = data_utils.rand_name(name='test', prefix='policy') |
| 1249 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1250 | @decorators.idempotent_id('aa59b00b-3e9c-4787-92f8-93a5cdf5e378') |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1251 | def test_rule_create(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1252 | policy = self.create_qos_policy(name=self.policy_name, |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1253 | description='test policy', |
| 1254 | shared=False) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1255 | rule = self.qos_min_bw_rules_client.create_minimum_bandwidth_rule( |
| 1256 | qos_policy_id=policy['id'], |
| 1257 | **{'direction': self.DIRECTION_EGRESS, |
| 1258 | 'min_kbps': 1138})[self.RULE_NAME] |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1259 | |
| 1260 | # Test 'show rule' |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1261 | retrieved_rule = \ |
| 1262 | self.qos_min_bw_rules_client.show_minimum_bandwidth_rule( |
| 1263 | policy['id'], rule['id']) |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1264 | retrieved_rule = retrieved_rule[self.RULE_NAME] |
| 1265 | self.assertEqual(rule['id'], retrieved_rule['id']) |
| 1266 | self.assertEqual(1138, retrieved_rule['min_kbps']) |
| 1267 | self.assertEqual(self.DIRECTION_EGRESS, retrieved_rule['direction']) |
| 1268 | |
| 1269 | # Test 'list rules' |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1270 | rules = self.qos_min_bw_rules_client.list_minimum_bandwidth_rules( |
| 1271 | policy['id']) |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1272 | rules = rules[self.RULES_NAME] |
| 1273 | rules_ids = [r['id'] for r in rules] |
| 1274 | self.assertIn(rule['id'], rules_ids) |
| 1275 | |
| 1276 | # Test 'show policy' |
| 1277 | retrieved_policy = self.admin_client.show_qos_policy(policy['id']) |
| 1278 | policy_rules = retrieved_policy['policy']['rules'] |
| 1279 | self.assertEqual(1, len(policy_rules)) |
| 1280 | self.assertEqual(rule['id'], policy_rules[0]['id']) |
| 1281 | self.assertEqual(qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH, |
| 1282 | policy_rules[0]['type']) |
| 1283 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1284 | @decorators.idempotent_id('266d9b87-e51c-48bd-9aa7-8269573621be') |
Ihar Hrachyshka | 33034bf | 2016-08-31 18:48:14 +0000 | [diff] [blame] | 1285 | def test_rule_create_fail_for_missing_min_kbps(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1286 | policy = self.create_qos_policy(name=self.policy_name, |
Ihar Hrachyshka | 33034bf | 2016-08-31 18:48:14 +0000 | [diff] [blame] | 1287 | description='test policy', |
| 1288 | shared=False) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1289 | self.assertRaises( |
| 1290 | exceptions.BadRequest, |
| 1291 | self.qos_min_bw_rules_client.create_minimum_bandwidth_rule, |
| 1292 | qos_policy_id=policy['id'], |
| 1293 | **{'direction': self.DIRECTION_EGRESS}) |
Ihar Hrachyshka | 33034bf | 2016-08-31 18:48:14 +0000 | [diff] [blame] | 1294 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1295 | @decorators.idempotent_id('aa59b00b-ab01-4787-92f8-93a5cdf5e378') |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1296 | def test_rule_create_fail_for_the_same_type(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1297 | policy = self.create_qos_policy(name=self.policy_name, |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1298 | description='test policy', |
| 1299 | shared=False) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1300 | self.qos_min_bw_rules_client.create_minimum_bandwidth_rule( |
| 1301 | qos_policy_id=policy['id'], |
| 1302 | **{'direction': self.DIRECTION_EGRESS, |
| 1303 | 'min_kbps': 200}) |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1304 | |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1305 | self.assertRaises( |
| 1306 | exceptions.Conflict, |
| 1307 | self.qos_min_bw_rules_client.create_minimum_bandwidth_rule, |
| 1308 | qos_policy_id=policy['id'], |
| 1309 | **{'direction': self.DIRECTION_EGRESS, |
| 1310 | 'min_kbps': 201}) |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1311 | |
Lajos Katona | dc9c6d6 | 2018-08-27 16:08:51 +0200 | [diff] [blame] | 1312 | @decorators.idempotent_id('35baf998-ae65-495c-9902-35a0d11e8936') |
| 1313 | @utils.requires_ext(extension="qos-bw-minimum-ingress", |
| 1314 | service="network") |
| 1315 | def test_rule_create_pass_for_direction_ingress(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1316 | policy = self.create_qos_policy(name=self.policy_name, |
Lajos Katona | dc9c6d6 | 2018-08-27 16:08:51 +0200 | [diff] [blame] | 1317 | description='test policy', |
| 1318 | shared=False) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1319 | self.qos_min_bw_rules_client.create_minimum_bandwidth_rule( |
| 1320 | qos_policy_id=policy['id'], |
| 1321 | **{'direction': self.DIRECTION_INGRESS, |
| 1322 | 'min_kbps': 201}) |
Lajos Katona | dc9c6d6 | 2018-08-27 16:08:51 +0200 | [diff] [blame] | 1323 | |
| 1324 | retrieved_policy = self.admin_client.show_qos_policy(policy['id']) |
| 1325 | policy_rules = retrieved_policy['policy']['rules'] |
| 1326 | self.assertEqual(1, len(policy_rules)) |
| 1327 | self.assertEqual(qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH, |
| 1328 | policy_rules[0]['type']) |
| 1329 | self.assertEqual(self.DIRECTION_INGRESS, policy_rules[0]['direction']) |
| 1330 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1331 | @decorators.idempotent_id('a49a6988-2568-47d2-931e-2dbc858943b3') |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1332 | def test_rule_update(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1333 | policy = self.create_qos_policy(name=self.policy_name, |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1334 | description='test policy', |
| 1335 | shared=False) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1336 | rule = self.qos_min_bw_rules_client.create_minimum_bandwidth_rule( |
| 1337 | qos_policy_id=policy['id'], |
| 1338 | **{'direction': self.DIRECTION_EGRESS, |
| 1339 | 'min_kbps': 300})[self.RULE_NAME] |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1340 | |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1341 | self.qos_min_bw_rules_client.update_minimum_bandwidth_rule( |
| 1342 | policy['id'], rule['id'], |
| 1343 | **{'min_kbps': 350, 'direction': self.DIRECTION_EGRESS}) |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1344 | |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1345 | retrieved_policy = \ |
| 1346 | self.qos_min_bw_rules_client.show_minimum_bandwidth_rule( |
| 1347 | policy['id'], rule['id']) |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1348 | retrieved_policy = retrieved_policy[self.RULE_NAME] |
| 1349 | self.assertEqual(350, retrieved_policy['min_kbps']) |
| 1350 | self.assertEqual(self.DIRECTION_EGRESS, retrieved_policy['direction']) |
| 1351 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1352 | @decorators.idempotent_id('a7ee6efd-7b33-4a68-927d-275b4f8ba958') |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1353 | def test_rule_delete(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1354 | policy = self.create_qos_policy(name=self.policy_name, |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1355 | description='test policy', |
| 1356 | shared=False) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1357 | rule = self.qos_min_bw_rules_client.create_minimum_bandwidth_rule( |
| 1358 | policy['id'], |
| 1359 | **{'direction': self.DIRECTION_EGRESS, |
| 1360 | 'min_kbps': 200})[self.RULE_NAME] |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1361 | |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1362 | retrieved_policy = \ |
| 1363 | self.qos_min_bw_rules_client.show_minimum_bandwidth_rule( |
| 1364 | policy['id'], rule['id']) |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1365 | retrieved_policy = retrieved_policy[self.RULE_NAME] |
| 1366 | self.assertEqual(rule['id'], retrieved_policy['id']) |
| 1367 | |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1368 | self.qos_min_bw_rules_client.delete_minimum_bandwidth_rule( |
| 1369 | policy['id'], rule['id']) |
| 1370 | self.assertRaises( |
| 1371 | exceptions.NotFound, |
| 1372 | self.qos_min_bw_rules_client.show_minimum_bandwidth_rule, |
| 1373 | policy['id'], rule['id']) |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1374 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1375 | @decorators.idempotent_id('a211222c-5808-46cb-a961-983bbab6b852') |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1376 | def test_rule_create_rule_nonexistent_policy(self): |
| 1377 | self.assertRaises( |
| 1378 | exceptions.NotFound, |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1379 | self.qos_min_bw_rules_client.create_minimum_bandwidth_rule, |
| 1380 | 'policy', |
| 1381 | **{'direction': self.DIRECTION_EGRESS, 'min_kbps': 200}) |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1382 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1383 | @decorators.idempotent_id('b4a2e7ad-786f-4927-a85a-e545a93bd274') |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1384 | def test_rule_create_forbidden_for_regular_tenants(self): |
| 1385 | self.assertRaises( |
| 1386 | exceptions.Forbidden, |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1387 | self.qos_min_bw_rules_client_primary.create_minimum_bandwidth_rule, |
| 1388 | 'policy', **{'direction': self.DIRECTION_EGRESS, 'min_kbps': 300}) |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1389 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1390 | @decorators.idempotent_id('de0bd0c2-54d9-4e29-85f1-cfb36ac3ebe2') |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1391 | def test_get_rules_by_policy(self): |
| 1392 | policy1 = self.create_qos_policy(name='test-policy1', |
| 1393 | description='test policy1', |
| 1394 | shared=False) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1395 | rule1 = self.qos_min_bw_rules_client.create_minimum_bandwidth_rule( |
| 1396 | qos_policy_id=policy1['id'], |
| 1397 | **{'direction': self.DIRECTION_EGRESS, |
| 1398 | 'min_kbps': 200})[self.RULE_NAME] |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1399 | |
| 1400 | policy2 = self.create_qos_policy(name='test-policy2', |
| 1401 | description='test policy2', |
| 1402 | shared=False) |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1403 | rule2 = self.qos_min_bw_rules_client.create_minimum_bandwidth_rule( |
| 1404 | qos_policy_id=policy2['id'], |
| 1405 | **{'direction': self.DIRECTION_EGRESS, |
| 1406 | 'min_kbps': 5000})[self.RULE_NAME] |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1407 | |
| 1408 | # Test 'list rules' |
zahlabut | 7ebb66e | 2021-09-01 22:39:49 +0300 | [diff] [blame] | 1409 | rules = self.qos_min_bw_rules_client.list_minimum_bandwidth_rules( |
| 1410 | policy1['id']) |
Rodolfo Alonso Hernandez | e4c099f | 2016-07-18 11:52:12 +0100 | [diff] [blame] | 1411 | rules = rules[self.RULES_NAME] |
| 1412 | rules_ids = [r['id'] for r in rules] |
| 1413 | self.assertIn(rule1['id'], rules_ids) |
| 1414 | self.assertNotIn(rule2['id'], rules_ids) |
| 1415 | |
| 1416 | |
elajkat | 4a1357b | 2021-08-31 10:16:25 +0200 | [diff] [blame] | 1417 | class QosMinimumPpsRuleTestJSON(base.BaseAdminNetworkTest): |
elajkat | 4a1357b | 2021-08-31 10:16:25 +0200 | [diff] [blame] | 1418 | required_extensions = [qos_apidef.ALIAS] |
| 1419 | |
| 1420 | @classmethod |
| 1421 | @utils.requires_ext(service='network', |
| 1422 | extension='port-resource-request-groups') |
| 1423 | def resource_setup(cls): |
| 1424 | super(QosMinimumPpsRuleTestJSON, cls).resource_setup() |
| 1425 | |
| 1426 | @classmethod |
| 1427 | def setup_clients(cls): |
| 1428 | super(QosMinimumPpsRuleTestJSON, cls).setup_clients() |
| 1429 | cls.min_pps_client = cls.os_admin.qos_minimum_packet_rate_rules_client |
| 1430 | cls.min_pps_client_primary = \ |
| 1431 | cls.os_primary.qos_minimum_packet_rate_rules_client |
| 1432 | |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1433 | def setUp(self): |
| 1434 | super(QosMinimumPpsRuleTestJSON, self).setUp() |
| 1435 | self.policy_name = data_utils.rand_name(name='test', prefix='policy') |
Chandan Kumar (raukadah) | 255586c | 2022-03-10 09:43:37 +0530 | [diff] [blame] | 1436 | self.RULE_NAME = qos_consts.RULE_TYPE_MINIMUM_PACKET_RATE + "_rule" |
| 1437 | self.RULES_NAME = self.RULE_NAME + "s" |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1438 | |
elajkat | 4a1357b | 2021-08-31 10:16:25 +0200 | [diff] [blame] | 1439 | def _create_qos_min_pps_rule(self, policy_id, rule_data): |
| 1440 | rule = self.min_pps_client.create_minimum_packet_rate_rule( |
| 1441 | policy_id, **rule_data)['minimum_packet_rate_rule'] |
| 1442 | self.addCleanup( |
| 1443 | test_utils.call_and_ignore_notfound_exc, |
| 1444 | self.min_pps_client.delete_minimum_packet_rate_rule, |
| 1445 | policy_id, rule['id']) |
| 1446 | return rule |
| 1447 | |
| 1448 | @decorators.idempotent_id('66a5b9b4-d4f9-4af8-b238-9e1881b78487') |
| 1449 | def test_rule_create(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1450 | policy = self.create_qos_policy(name=self.policy_name, |
elajkat | 4a1357b | 2021-08-31 10:16:25 +0200 | [diff] [blame] | 1451 | description='test policy', |
| 1452 | shared=False) |
| 1453 | rule = self._create_qos_min_pps_rule( |
| 1454 | policy['id'], |
| 1455 | {qos_consts.DIRECTION: n_constants.EGRESS_DIRECTION, |
| 1456 | qos_consts.MIN_KPPS: 1138}) |
| 1457 | |
| 1458 | # Test 'show rule' |
| 1459 | retrieved_rule = self.min_pps_client.show_minimum_packet_rate_rule( |
| 1460 | policy['id'], rule['id'])[self.RULE_NAME] |
| 1461 | self.assertEqual(rule['id'], retrieved_rule['id']) |
| 1462 | self.assertEqual(1138, retrieved_rule[qos_consts.MIN_KPPS]) |
| 1463 | self.assertEqual(n_constants.EGRESS_DIRECTION, |
| 1464 | retrieved_rule[qos_consts.DIRECTION]) |
| 1465 | |
| 1466 | # Test 'list rules' |
| 1467 | rules = self.min_pps_client.list_minimum_packet_rate_rules( |
| 1468 | policy['id']) |
| 1469 | rules = rules[self.RULES_NAME] |
| 1470 | rules_ids = [r['id'] for r in rules] |
| 1471 | self.assertIn(rule['id'], rules_ids) |
| 1472 | |
| 1473 | # Test 'show policy' |
| 1474 | retrieved_policy = self.admin_client.show_qos_policy(policy['id']) |
| 1475 | policy_rules = retrieved_policy['policy']['rules'] |
| 1476 | self.assertEqual(1, len(policy_rules)) |
| 1477 | self.assertEqual(rule['id'], policy_rules[0]['id']) |
| 1478 | self.assertEqual('minimum_packet_rate', |
| 1479 | policy_rules[0]['type']) |
| 1480 | |
| 1481 | @decorators.idempotent_id('6b656b57-d2bf-47f9-89a9-1baad1bd5418') |
| 1482 | def test_rule_create_fail_for_missing_min_kpps(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1483 | policy = self.create_qos_policy(name=self.policy_name, |
elajkat | 4a1357b | 2021-08-31 10:16:25 +0200 | [diff] [blame] | 1484 | description='test policy', |
| 1485 | shared=False) |
| 1486 | self.assertRaises(exceptions.BadRequest, |
| 1487 | self._create_qos_min_pps_rule, |
| 1488 | policy['id'], |
| 1489 | {qos_consts.DIRECTION: n_constants.EGRESS_DIRECTION}) |
| 1490 | |
| 1491 | @decorators.idempotent_id('f41213e5-2ab8-4916-b106-38d2cac5e18c') |
| 1492 | def test_rule_create_fail_for_the_same_type(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1493 | policy = self.create_qos_policy(name=self.policy_name, |
elajkat | 4a1357b | 2021-08-31 10:16:25 +0200 | [diff] [blame] | 1494 | description='test policy', |
| 1495 | shared=False) |
| 1496 | self._create_qos_min_pps_rule(policy['id'], |
| 1497 | {qos_consts.DIRECTION: n_constants.EGRESS_DIRECTION, |
| 1498 | qos_consts.MIN_KPPS: 200}) |
| 1499 | |
| 1500 | self.assertRaises(exceptions.Conflict, |
| 1501 | self._create_qos_min_pps_rule, |
| 1502 | policy['id'], |
| 1503 | {qos_consts.DIRECTION: n_constants.EGRESS_DIRECTION, |
| 1504 | qos_consts.MIN_KPPS: 201}) |
| 1505 | |
| 1506 | @decorators.idempotent_id('ceb8e41e-3d72-11ec-a446-d7faae6daec2') |
| 1507 | def test_rule_create_any_direction_when_egress_direction_exists(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1508 | policy = self.create_qos_policy(name=self.policy_name, |
elajkat | 4a1357b | 2021-08-31 10:16:25 +0200 | [diff] [blame] | 1509 | description='test policy', |
| 1510 | shared=False) |
| 1511 | self._create_qos_min_pps_rule(policy['id'], |
| 1512 | {qos_consts.DIRECTION: n_constants.EGRESS_DIRECTION, |
| 1513 | qos_consts.MIN_KPPS: 200}) |
| 1514 | |
| 1515 | self.assertRaises(exceptions.Conflict, |
| 1516 | self._create_qos_min_pps_rule, |
| 1517 | policy['id'], |
| 1518 | {qos_consts.DIRECTION: n_constants.ANY_DIRECTION, |
| 1519 | qos_consts.MIN_KPPS: 201}) |
| 1520 | |
| 1521 | @decorators.idempotent_id('a147a71e-3d7b-11ec-8097-278b1afd5fa2') |
| 1522 | def test_rule_create_egress_direction_when_any_direction_exists(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1523 | policy = self.create_qos_policy(name=self.policy_name, |
elajkat | 4a1357b | 2021-08-31 10:16:25 +0200 | [diff] [blame] | 1524 | description='test policy', |
| 1525 | shared=False) |
| 1526 | self._create_qos_min_pps_rule(policy['id'], |
| 1527 | {qos_consts.DIRECTION: n_constants.ANY_DIRECTION, |
| 1528 | qos_consts.MIN_KPPS: 200}) |
| 1529 | |
| 1530 | self.assertRaises(exceptions.Conflict, |
| 1531 | self._create_qos_min_pps_rule, |
| 1532 | policy['id'], |
| 1533 | {qos_consts.DIRECTION: n_constants.EGRESS_DIRECTION, |
| 1534 | qos_consts.MIN_KPPS: 201}) |
| 1535 | |
| 1536 | @decorators.idempotent_id('522ed09a-1d7f-4c1b-9195-61f19caf916f') |
| 1537 | def test_rule_update(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1538 | policy = self.create_qos_policy(name=self.policy_name, |
elajkat | 4a1357b | 2021-08-31 10:16:25 +0200 | [diff] [blame] | 1539 | description='test policy', |
| 1540 | shared=False) |
| 1541 | rule = self._create_qos_min_pps_rule( |
| 1542 | policy['id'], |
| 1543 | {qos_consts.DIRECTION: n_constants.EGRESS_DIRECTION, |
| 1544 | qos_consts.MIN_KPPS: 300}) |
| 1545 | |
| 1546 | self.min_pps_client.update_minimum_packet_rate_rule( |
| 1547 | policy['id'], rule['id'], |
| 1548 | **{qos_consts.MIN_KPPS: 350, |
| 1549 | qos_consts.DIRECTION: n_constants.ANY_DIRECTION}) |
| 1550 | |
| 1551 | retrieved_rule = self.min_pps_client.show_minimum_packet_rate_rule( |
| 1552 | policy['id'], rule['id'])[self.RULE_NAME] |
| 1553 | self.assertEqual(350, retrieved_rule[qos_consts.MIN_KPPS]) |
| 1554 | self.assertEqual(n_constants.ANY_DIRECTION, |
| 1555 | retrieved_rule[qos_consts.DIRECTION]) |
| 1556 | |
| 1557 | @decorators.idempotent_id('a020e186-3d60-11ec-88ca-d7f5eec22764') |
| 1558 | def test_rule_update_direction_conflict(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1559 | policy = self.create_qos_policy(name=self.policy_name, |
elajkat | 4a1357b | 2021-08-31 10:16:25 +0200 | [diff] [blame] | 1560 | description='test policy', |
| 1561 | shared=False) |
| 1562 | rule1 = self._create_qos_min_pps_rule( |
| 1563 | policy['id'], |
| 1564 | {qos_consts.DIRECTION: n_constants.EGRESS_DIRECTION, |
| 1565 | qos_consts.MIN_KPPS: 300}) |
| 1566 | |
| 1567 | rule2 = self._create_qos_min_pps_rule( |
| 1568 | policy['id'], |
| 1569 | {qos_consts.DIRECTION: n_constants.INGRESS_DIRECTION, |
| 1570 | qos_consts.MIN_KPPS: 300}) |
| 1571 | |
| 1572 | retrieved_rule1 = self.min_pps_client.show_minimum_packet_rate_rule( |
| 1573 | policy['id'], rule1['id'])[self.RULE_NAME] |
| 1574 | self.assertEqual(n_constants.EGRESS_DIRECTION, |
| 1575 | retrieved_rule1[qos_consts.DIRECTION]) |
| 1576 | retrieved_rule2 = self.min_pps_client.show_minimum_packet_rate_rule( |
| 1577 | policy['id'], rule2['id'])[self.RULE_NAME] |
| 1578 | self.assertEqual(n_constants.INGRESS_DIRECTION, |
| 1579 | retrieved_rule2[qos_consts.DIRECTION]) |
| 1580 | |
| 1581 | self.assertRaises(exceptions.Conflict, |
| 1582 | self.min_pps_client.update_minimum_packet_rate_rule, |
| 1583 | policy['id'], rule2['id'], |
| 1584 | **{qos_consts.DIRECTION: n_constants.ANY_DIRECTION}) |
| 1585 | |
| 1586 | @decorators.idempotent_id('c49018b6-d358-49a1-a94b-d53224165045') |
| 1587 | def test_rule_delete(self): |
elajkat | 757f3f1 | 2022-01-28 11:17:55 +0100 | [diff] [blame] | 1588 | policy = self.create_qos_policy(name=self.policy_name, |
elajkat | 4a1357b | 2021-08-31 10:16:25 +0200 | [diff] [blame] | 1589 | description='test policy', |
| 1590 | shared=False) |
| 1591 | rule = self._create_qos_min_pps_rule( |
| 1592 | policy['id'], |
| 1593 | {qos_consts.DIRECTION: n_constants.EGRESS_DIRECTION, |
| 1594 | qos_consts.MIN_KPPS: 200}) |
| 1595 | |
| 1596 | retrieved_rule = self.min_pps_client.show_minimum_packet_rate_rule( |
| 1597 | policy['id'], rule['id'])[self.RULE_NAME] |
| 1598 | self.assertEqual(rule['id'], retrieved_rule['id']) |
| 1599 | |
| 1600 | self.min_pps_client.delete_minimum_packet_rate_rule(policy['id'], |
| 1601 | rule['id']) |
| 1602 | self.assertRaises(exceptions.NotFound, |
| 1603 | self.min_pps_client.show_minimum_packet_rate_rule, |
| 1604 | policy['id'], rule['id']) |
| 1605 | |
| 1606 | @decorators.idempotent_id('1a6b6128-3d3e-11ec-bf49-57b326d417c0') |
| 1607 | def test_rule_create_forbidden_for_regular_tenants(self): |
| 1608 | self.assertRaises( |
| 1609 | exceptions.Forbidden, |
| 1610 | self.min_pps_client_primary.create_minimum_packet_rate_rule, |
| 1611 | 'policy', **{qos_consts.DIRECTION: n_constants.EGRESS_DIRECTION, |
| 1612 | qos_consts.MIN_KPPS: 300}) |
| 1613 | |
| 1614 | @decorators.idempotent_id('1b94f4e2-3d3e-11ec-bb21-6f98e4044b8b') |
| 1615 | def test_get_rules_by_policy(self): |
| 1616 | policy1 = self.create_qos_policy(name='test-policy1', |
| 1617 | description='test policy1', |
| 1618 | shared=False) |
| 1619 | rule1 = self._create_qos_min_pps_rule( |
| 1620 | policy1['id'], |
| 1621 | {qos_consts.DIRECTION: n_constants.EGRESS_DIRECTION, |
| 1622 | qos_consts.MIN_KPPS: 200}) |
| 1623 | |
| 1624 | policy2 = self.create_qos_policy(name='test-policy2', |
| 1625 | description='test policy2', |
| 1626 | shared=False) |
| 1627 | rule2 = self._create_qos_min_pps_rule( |
| 1628 | policy2['id'], |
| 1629 | {qos_consts.DIRECTION: n_constants.EGRESS_DIRECTION, |
| 1630 | qos_consts.MIN_KPPS: 5000}) |
| 1631 | |
| 1632 | # Test 'list rules' |
| 1633 | rules = self.min_pps_client.list_minimum_packet_rate_rules( |
| 1634 | policy1['id']) |
| 1635 | rules = rules[self.RULES_NAME] |
| 1636 | rules_ids = [r['id'] for r in rules] |
| 1637 | self.assertIn(rule1['id'], rules_ids) |
| 1638 | self.assertNotIn(rule2['id'], rules_ids) |
| 1639 | |
| 1640 | |
Ihar Hrachyshka | b7940d9 | 2016-06-10 13:44:22 +0200 | [diff] [blame] | 1641 | class QosSearchCriteriaTest(base.BaseSearchCriteriaTest, |
| 1642 | base.BaseAdminNetworkTest): |
| 1643 | |
| 1644 | resource = 'policy' |
| 1645 | plural_name = 'policies' |
| 1646 | |
| 1647 | # Use unique description to isolate the tests from other QoS tests |
| 1648 | list_kwargs = {'description': 'search-criteria-test'} |
| 1649 | list_as_admin = True |
| 1650 | |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 1651 | required_extensions = [qos_apidef.ALIAS] |
Jakub Libosvar | 1982aa1 | 2017-05-30 11:15:33 +0000 | [diff] [blame] | 1652 | |
Ihar Hrachyshka | b7940d9 | 2016-06-10 13:44:22 +0200 | [diff] [blame] | 1653 | @classmethod |
Ihar Hrachyshka | b7940d9 | 2016-06-10 13:44:22 +0200 | [diff] [blame] | 1654 | def resource_setup(cls): |
| 1655 | super(QosSearchCriteriaTest, cls).resource_setup() |
| 1656 | for name in cls.resource_names: |
| 1657 | cls.create_qos_policy( |
| 1658 | name=name, description='search-criteria-test') |
| 1659 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1660 | @decorators.idempotent_id('55fc0103-fdc1-4d34-ab62-c579bb739a91') |
Ihar Hrachyshka | b7940d9 | 2016-06-10 13:44:22 +0200 | [diff] [blame] | 1661 | def test_list_sorts_asc(self): |
| 1662 | self._test_list_sorts_asc() |
| 1663 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1664 | @decorators.idempotent_id('13e08ac3-bfed-426b-892a-b3b158560c23') |
Ihar Hrachyshka | b7940d9 | 2016-06-10 13:44:22 +0200 | [diff] [blame] | 1665 | def test_list_sorts_desc(self): |
| 1666 | self._test_list_sorts_desc() |
| 1667 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1668 | @decorators.idempotent_id('719e61cc-e33c-4918-aa4d-1a791e6e0e86') |
Ihar Hrachyshka | b7940d9 | 2016-06-10 13:44:22 +0200 | [diff] [blame] | 1669 | def test_list_pagination(self): |
| 1670 | self._test_list_pagination() |
| 1671 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1672 | @decorators.idempotent_id('3bd8fb58-c0f8-4954-87fb-f286e1eb096a') |
Ihar Hrachyshka | b7940d9 | 2016-06-10 13:44:22 +0200 | [diff] [blame] | 1673 | def test_list_pagination_with_marker(self): |
| 1674 | self._test_list_pagination_with_marker() |
| 1675 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1676 | @decorators.idempotent_id('3bad0747-8082-46e9-be4d-c428a842db41') |
Ihar Hrachyshka | b7940d9 | 2016-06-10 13:44:22 +0200 | [diff] [blame] | 1677 | def test_list_pagination_with_href_links(self): |
| 1678 | self._test_list_pagination_with_href_links() |
| 1679 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1680 | @decorators.idempotent_id('d6a8bacd-d5e8-4ef3-bc55-23ca6998d208') |
Ihar Hrachyshka | b7940d9 | 2016-06-10 13:44:22 +0200 | [diff] [blame] | 1681 | def test_list_pagination_page_reverse_asc(self): |
| 1682 | self._test_list_pagination_page_reverse_asc() |
| 1683 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1684 | @decorators.idempotent_id('0b9aecdc-2b27-421b-b104-53d24e905ae8') |
Ihar Hrachyshka | b7940d9 | 2016-06-10 13:44:22 +0200 | [diff] [blame] | 1685 | def test_list_pagination_page_reverse_desc(self): |
| 1686 | self._test_list_pagination_page_reverse_desc() |
| 1687 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1688 | @decorators.idempotent_id('1a3dc257-dafd-4870-8c71-639ae7ddc6ea') |
Ihar Hrachyshka | b7940d9 | 2016-06-10 13:44:22 +0200 | [diff] [blame] | 1689 | def test_list_pagination_page_reverse_with_href_links(self): |
| 1690 | self._test_list_pagination_page_reverse_with_href_links() |
| 1691 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 1692 | @decorators.idempotent_id('40e09b53-4eb8-4526-9181-d438c8005a20') |
Ihar Hrachyshka | b7940d9 | 2016-06-10 13:44:22 +0200 | [diff] [blame] | 1693 | def test_list_no_pagination_limit_0(self): |
| 1694 | self._test_list_no_pagination_limit_0() |