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