How to use show_limit_bandwidth_rule method in tempest

Best Python code snippet using tempest_python

test_qos.py

Source:test_qos.py Github

copy

Full Screen

...427 policy['id'],428 {'max_kbps': 200, 'max_burst_kbps': 1337, 'direction': 'ingress'})429 # Test 'show rule'430 retrieved_rule = \431 self.qos_bw_limit_rule_client.show_limit_bandwidth_rule(432 policy['id'], rule['id'])433 retrieved_rule = retrieved_rule['bandwidth_limit_rule']434 self.assertEqual(rule['id'], retrieved_rule['id'])435 self.assertEqual(200, retrieved_rule['max_kbps'])436 self.assertEqual(1337, retrieved_rule['max_burst_kbps'])437 self.assertEqual('ingress', retrieved_rule['direction'])438 # Test 'list rules'439 rules = self.qos_bw_limit_rule_client.list_limit_bandwidth_rules(440 policy['id'])441 rules = rules['bandwidth_limit_rules']442 rules_ids = [r['id'] for r in rules]443 self.assertIn(rule['id'], rules_ids)444 # Test 'show policy'445 retrieved_policy = self.admin_client.show_qos_policy(policy['id'])446 policy_rules = retrieved_policy['policy']['rules']447 self.assertEqual(1, len(policy_rules))448 self.assertEqual(rule['id'], policy_rules[0]['id'])449 self.assertEqual(qos_consts.RULE_TYPE_BANDWIDTH_LIMIT,450 policy_rules[0]['type'])451 @decorators.idempotent_id('8a59b00b-ab01-4787-92f8-93a5cdf5e378')452 def test_rule_create_fail_for_the_same_type(self):453 policy = self.create_qos_policy(name=self.policy_name,454 description='test policy',455 shared=False)456 self._create_qos_bw_limit_rule(457 policy['id'], {'max_kbps': 200, 'max_burst_kbps': 1337})458 self.assertRaises(459 exceptions.Conflict,460 self._create_qos_bw_limit_rule,461 policy['id'],462 {'max_kbps': 201, 'max_burst_kbps': 1338})463 @decorators.idempotent_id('149a6988-2568-47d2-931e-2dbc858943b3')464 def test_rule_update(self):465 policy = self.create_qos_policy(name=self.policy_name,466 description='test policy',467 shared=False)468 rule = self._create_qos_bw_limit_rule(469 policy['id'], {'max_kbps': 1, 'max_burst_kbps': 1})470 if self.opposite_direction:471 self.qos_bw_limit_rule_client.update_limit_bandwidth_rule(472 policy['id'], rule['id'],473 **{'max_kbps': 200, 'max_burst_kbps': 1337,474 'direction': self.opposite_direction})475 else:476 self.qos_bw_limit_rule_client.update_limit_bandwidth_rule(477 policy['id'], rule['id'],478 **{'max_kbps': 200, 'max_burst_kbps': 1337})479 retrieved_policy = self.qos_bw_limit_rule_client.\480 show_limit_bandwidth_rule(policy['id'], rule['id'])481 retrieved_policy = retrieved_policy['bandwidth_limit_rule']482 self.assertEqual(200, retrieved_policy['max_kbps'])483 self.assertEqual(1337, retrieved_policy['max_burst_kbps'])484 if self.opposite_direction:485 self.assertEqual(self.opposite_direction,486 retrieved_policy['direction'])487 @decorators.idempotent_id('67ee6efd-7b33-4a68-927d-275b4f8ba958')488 def test_rule_delete(self):489 policy = self.create_qos_policy(name=self.policy_name,490 description='test policy',491 shared=False)492 rule = self._create_qos_bw_limit_rule(493 policy['id'], {'max_kbps': 200, 'max_burst_kbps': 1337})494 retrieved_policy = \495 self.qos_bw_limit_rule_client.show_limit_bandwidth_rule(496 policy['id'], rule['id'])497 retrieved_policy = retrieved_policy['bandwidth_limit_rule']498 self.assertEqual(rule['id'], retrieved_policy['id'])499 self.qos_bw_limit_rule_client.delete_limit_bandwidth_rule(500 policy['id'], rule['id'])501 self.assertRaises(502 exceptions.NotFound,503 self.qos_bw_limit_rule_client.show_limit_bandwidth_rule,504 policy['id'], rule['id'])505 @decorators.idempotent_id('f211222c-5808-46cb-a961-983bbab6b852')506 def test_rule_create_rule_nonexistent_policy(self):507 self.assertRaises(508 exceptions.NotFound,509 self._create_qos_bw_limit_rule,...

Full Screen

Full Screen

test_qos_limit_bandwidth_rules_client.py

Source:test_qos_limit_bandwidth_rules_client.py Github

copy

Full Screen

1# Copyright 2021 Red Hat.2#3# Licensed under the Apache License, Version 2.0 (the "License"); you may4# not use this file except in compliance with the License. You may obtain5# a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the12# License for the specific language governing permissions and limitations13# under the License.14import copy15from tempest.lib import decorators16from tempest.lib.services.network import qos_limit_bandwidth_rules_client17from tempest.tests.lib import fake_auth_provider18from tempest.tests.lib.services import base19from oslo_log import log as logging20LOG = logging.getLogger('tempest')21class TestQosLimitBandwidthRulesClient(base.BaseServiceTest):22 FAKE_QOS_POLICY_ID = "f1011b08-1297-11e9-a1e7-c7e6825a2616"23 FAKE_MAX_BW_RULE_ID = "e758c89e-1297-11e9-a6cf-cf46a71e6699"24 FAKE_MAX_BW_RULE_REQUEST = {25 'qos_policy_id': FAKE_QOS_POLICY_ID,26 'max_kbps': 1000,27 'max_burst_kbps': 0,28 'direction': 'ingress'29 }30 FAKE_MAX_BW_RULE_RESPONSE = {31 'bandwidth_limit_rule': {32 'id': FAKE_MAX_BW_RULE_ID,33 'max_kbps': 10000,34 'max_burst_kbps': 0,35 'direction': 'ingress'36 }37 }38 FAKE_MAX_BW_RULES = {39 'bandwidth_limit_rules': [40 FAKE_MAX_BW_RULE_RESPONSE['bandwidth_limit_rule']41 ]42 }43 def setUp(self):44 super(TestQosLimitBandwidthRulesClient, self).setUp()45 fake_auth = fake_auth_provider.FakeAuthProvider()46 self.qos_limit_bw_client = qos_limit_bandwidth_rules_client.\47 QosLimitBandwidthRulesClient(fake_auth, "network", "regionOne")48 @decorators.idempotent_id('cde981fa-e93b-11eb-aacb-74e5f9e2a801')49 def test_create_limit_bandwidth_rules(self, bytes_body=False):50 self.check_service_client_function(51 self.qos_limit_bw_client.create_limit_bandwidth_rule,52 "tempest.lib.common.rest_client.RestClient.post",53 self.FAKE_MAX_BW_RULE_RESPONSE,54 bytes_body,55 201,56 **self.FAKE_MAX_BW_RULE_REQUEST57 )58 @decorators.idempotent_id('86e6803a-e974-11eb-aacb-74e5f9e2a801')59 def test_update_limit_bandwidth_rules(self, bytes_body=False):60 update_kwargs = {61 "max_kbps": "20000"62 }63 resp_body = {64 "bandwidth_limit_rule": copy.deepcopy(65 self.FAKE_MAX_BW_RULE_RESPONSE['bandwidth_limit_rule']66 )67 }68 resp_body["bandwidth_limit_rule"].update(update_kwargs)69 self.check_service_client_function(70 self.qos_limit_bw_client.update_limit_bandwidth_rule,71 "tempest.lib.common.rest_client.RestClient.put",72 resp_body,73 bytes_body,74 200,75 qos_policy_id=self.FAKE_QOS_POLICY_ID,76 rule_id=self.FAKE_MAX_BW_RULE_ID,77 **update_kwargs)78 @decorators.idempotent_id('be60ae6e-e979-11eb-aacb-74e5f9e2a801')79 def test_show_limit_bandwidth_rules(self, bytes_body=False):80 self.check_service_client_function(81 self.qos_limit_bw_client.show_limit_bandwidth_rule,82 "tempest.lib.common.rest_client.RestClient.get",83 self.FAKE_MAX_BW_RULE_RESPONSE,84 bytes_body,85 200,86 qos_policy_id=self.FAKE_QOS_POLICY_ID,87 rule_id=self.FAKE_MAX_BW_RULE_ID88 )89 @decorators.idempotent_id('0a7c0964-e97b-11eb-aacb-74e5f9e2a801')90 def test_delete_limit_bandwidth_rule(self):91 self.check_service_client_function(92 self.qos_limit_bw_client.delete_limit_bandwidth_rule,93 "tempest.lib.common.rest_client.RestClient.delete",94 {},95 status=204,96 qos_policy_id=self.FAKE_QOS_POLICY_ID,97 rule_id=self.FAKE_MAX_BW_RULE_ID)98 @decorators.idempotent_id('08df88ae-e97d-11eb-aacb-74e5f9e2a801')99 def test_list_minimum_bandwidth_rules(self, bytes_body=False):100 self.check_service_client_function(101 self.qos_limit_bw_client.list_limit_bandwidth_rules,102 "tempest.lib.common.rest_client.RestClient.get",103 self.FAKE_MAX_BW_RULES,104 bytes_body,105 200,106 qos_policy_id=self.FAKE_QOS_POLICY_ID...

Full Screen

Full Screen

qos_limit_bandwidth_rules_client.py

Source:qos_limit_bandwidth_rules_client.py Github

copy

Full Screen

...32 uri = '/qos/policies/{}/bandwidth_limit_rules/{}'.format(33 qos_policy_id, rule_id)34 post_data = {'bandwidth_limit_rule': kwargs}35 return self.update_resource(uri, post_data)36 def show_limit_bandwidth_rule(self, qos_policy_id, rule_id, **fields):37 """Show details of a limit bandwidth rule.38 For full list of available parameters, please refer to the official39 API reference:40 https://docs.openstack.org/api-ref/network/v2/index.html#show-bandwidth-limit-rule-details41 """42 uri = '/qos/policies/{}/bandwidth_limit_rules/{}'.format(43 qos_policy_id, rule_id)44 return self.show_resource(uri, **fields)45 def delete_limit_bandwidth_rule(self, qos_policy_id, rule_id):46 """Deletes a limit bandwidth rule for a QoS policy.47 For full list of available parameters, please refer to the official48 API reference:49 https://docs.openstack.org/api-ref/network/v2/index.html#delete-bandwidth-limit-rule50 """...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful