How to use update_limit_bandwidth_rule method in tempest

Best Python code snippet using tempest_python

test_qos.py

Source:test_qos.py Github

copy

Full Screen

...224 # As admin user update QoS rule225 rule_update_data = {226 'max_kbps': constants.LIMIT_KILO_BITS_PER_SECOND * 2,227 'max_burst_kbps': constants.LIMIT_KILO_BITS_PER_SECOND * 2}228 self.qos_bw_limit_rule_client.update_limit_bandwidth_rule(229 qos_policy_id=bw_limit_policy_id, rule_id=rule_id,230 **rule_update_data)231 # Check that actual BW while downloading file232 # is as expected (Update BW)233 utils.wait_until_true(lambda: self._check_bw(234 ssh_client,235 self.fip['floating_ip_address'],236 port=self.NC_PORT,237 expected_bw=QoSTest.LIMIT_BYTES_SEC * 2),238 timeout=self.CHECK_TIMEOUT,239 sleep=1,240 exception=RuntimeError(241 'Failed scenario: "Update QoS policy associated with'242 ' the network" Actual BW is not as expected!'))243 # Create a new QoS policy244 bw_limit_policy_id_new = self._create_qos_policy()245 # As admin user create a new QoS rule246 rule_data_new = {247 'max_kbps': constants.LIMIT_KILO_BITS_PER_SECOND,248 'max_burst_kbps': constants.LIMIT_KILO_BITS_PER_SECOND}249 rule_id_new = self._create_qos_bw_limit_rule(250 bw_limit_policy_id_new, rule_data_new)['id']251 # Associate a new QoS policy to Neutron port252 self.os_admin.network_client.update_port(253 self.port['id'], qos_policy_id=bw_limit_policy_id_new)254 # Check that actual BW while downloading file255 # is as expected (Original BW)256 utils.wait_until_true(lambda: self._check_bw(257 ssh_client,258 self.fip['floating_ip_address'],259 port=self.NC_PORT),260 timeout=self.CHECK_TIMEOUT,261 sleep=1,262 exception=RuntimeError(263 'Failed scenario: "Create a new QoS policy associated with'264 ' the VM port" Actual BW is not as expected!'))265 # As admin user update QoS rule266 rule_update_data = {267 'max_kbps': constants.LIMIT_KILO_BITS_PER_SECOND * 3,268 'max_burst_kbps': constants.LIMIT_KILO_BITS_PER_SECOND * 3}269 self.qos_bw_limit_rule_client.update_limit_bandwidth_rule(270 qos_policy_id=bw_limit_policy_id_new, rule_id=rule_id_new,271 **rule_update_data)272 # Check that actual BW while downloading file273 # is as expected (Update BW)274 utils.wait_until_true(lambda: self._check_bw(275 ssh_client,276 self.fip['floating_ip_address'],277 port=self.NC_PORT,278 expected_bw=QoSTest.LIMIT_BYTES_SEC * 3),279 timeout=self.CHECK_TIMEOUT,280 sleep=1,281 exception=RuntimeError(282 'Failed scenario: "Update QoS policy associated with'283 ' the VM port" Actual BW is not as expected!'))...

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

...22 uri = '/qos/policies/{}/bandwidth_limit_rules'.format(23 qos_policy_id)24 post_data = {'bandwidth_limit_rule': kwargs}25 return self.create_resource(uri, post_data)26 def update_limit_bandwidth_rule(self, qos_policy_id, rule_id, **kwargs):27 """Updates a limit bandwidth rule.28 For full list of available parameters, please refer to the official29 API reference:30 https://docs.openstack.org/api-ref/network/v2/index.html#update-bandwidth-limit-rule31 """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-details...

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