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