Best Python code snippet using tempest_python
test_floatingip.py
Source:test_floatingip.py
...315 # As admin user create a new QoS rules316 rule_data = {'max_kbps': constants.LIMIT_KILO_BITS_PER_SECOND,317 'max_burst_kbps': constants.LIMIT_KILO_BYTES,318 'direction': lib_constants.INGRESS_DIRECTION}319 self.qos_bw_limit_rule_client.create_limit_bandwidth_rule(320 qos_policy_id=policy_id, **rule_data)321 rule_data = {'max_kbps': constants.LIMIT_KILO_BITS_PER_SECOND,322 'max_burst_kbps': constants.LIMIT_KILO_BYTES,323 'direction': lib_constants.EGRESS_DIRECTION}324 self.qos_bw_limit_rule_client.create_limit_bandwidth_rule(325 qos_policy_id=policy_id, **rule_data)326 rules = self.qos_bw_limit_rule_client.list_limit_bandwidth_rules(327 policy_id)328 self.assertEqual(2, len(rules['bandwidth_limit_rules']))329 fip = self.os_admin.network_client.get_floatingip(330 self.fip['id'])['floatingip']331 self.assertEqual(self.port['id'], fip['port_id'])332 # Associate QoS to the FIP333 self.os_admin.network_client.update_floatingip(334 self.fip['id'],335 qos_policy_id=policy_id)336 fip = self.os_admin.network_client.get_floatingip(337 self.fip['id'])['floatingip']338 self.assertEqual(policy_id, fip['qos_policy_id'])...
test_qos_limit_bandwidth_rules_client.py
Source:test_qos_limit_bandwidth_rules_client.py
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...
qos_limit_bandwidth_rules_client.py
Source:qos_limit_bandwidth_rules_client.py
...12# License for the specific language governing permissions and limitations13# under the License.14from tempest.lib.services.network import base15class QosLimitBandwidthRulesClient(base.BaseNetworkClient):16 def create_limit_bandwidth_rule(self, qos_policy_id, **kwargs):17 """Creates a limit bandwidth rule for a QoS policy.18 For full list of available parameters, please refer to the official19 API reference:20 https://docs.openstack.org/api-ref/network/v2/index.html#create-bandwidth-limit-rule21 """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-rule...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!