Add missing tempest client for "QoS Limit Bandwidth" APIs + testing
"QoS Limit Bandwidth" APIs must be used in Octavia-Tempest-Plugin to add missing QoS based tests. Note: this patch fixes the "expected status" code for Update Minimum Bandwidth, that was set to default 200 instead of 202. Change-Id: I30d9d823c972e560a0a48e24e44fb16bcc353c5a
This commit is contained in:
parent
2eb82f1cbc
commit
ca3e513565
@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add "QoS bandwidth limit rules" APIs to:
|
||||||
|
"tempest/tests/lib/services/network/test_qos_limit_bandwidth_rules_client.py" module.
|
||||||
|
|
||||||
|
* List bandwidth limit rules for QoS policy
|
||||||
|
* Create bandwidth limit rule
|
||||||
|
* Show bandwidth limit rule details
|
||||||
|
* Update bandwidth limit rule
|
||||||
|
* Delete bandwidth limit rule
|
@ -0,0 +1,74 @@
|
|||||||
|
# Copyright 2021 Red Hat.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from tempest.lib.services.network import base
|
||||||
|
|
||||||
|
|
||||||
|
class QosLimitBandwidthRulesClient(base.BaseNetworkClient):
|
||||||
|
|
||||||
|
def create_limit_bandwidth_rule(self, qos_policy_id, **kwargs):
|
||||||
|
"""Creates a limit bandwidth rule for a QoS policy.
|
||||||
|
|
||||||
|
For full list of available parameters, please refer to the official
|
||||||
|
API reference:
|
||||||
|
https://docs.openstack.org/api-ref/network/v2/index.html#create-bandwidth-limit-rule
|
||||||
|
"""
|
||||||
|
uri = '/qos/policies/{}/bandwidth_limit_rules'.format(
|
||||||
|
qos_policy_id)
|
||||||
|
post_data = {'bandwidth_limit_rule': kwargs}
|
||||||
|
return self.create_resource(uri, post_data)
|
||||||
|
|
||||||
|
def update_limit_bandwidth_rule(self, qos_policy_id, rule_id, **kwargs):
|
||||||
|
"""Updates a limit bandwidth rule.
|
||||||
|
|
||||||
|
For full list of available parameters, please refer to the official
|
||||||
|
API reference:
|
||||||
|
https://docs.openstack.org/api-ref/network/v2/index.html#update-bandwidth-limit-rule
|
||||||
|
"""
|
||||||
|
uri = '/qos/policies/{}/bandwidth_limit_rules{}/'.format(
|
||||||
|
qos_policy_id, rule_id)
|
||||||
|
post_data = {'bandwidth_limit_rule': kwargs}
|
||||||
|
return self.update_resource(uri, post_data, expect_response_code=202)
|
||||||
|
|
||||||
|
def show_limit_bandwidth_rule(self, qos_policy_id, rule_id, **fields):
|
||||||
|
"""Show details of a limit bandwidth rule.
|
||||||
|
|
||||||
|
For full list of available parameters, please refer to the official
|
||||||
|
API reference:
|
||||||
|
https://docs.openstack.org/api-ref/network/v2/index.html#show-bandwidth-limit-rule-details
|
||||||
|
"""
|
||||||
|
uri = '/qos/policies/{}/bandwidth_limit_rules/{}'.format(
|
||||||
|
qos_policy_id, rule_id)
|
||||||
|
return self.show_resource(uri, **fields)
|
||||||
|
|
||||||
|
def delete_limit_bandwidth_rule(self, qos_policy_id, rule_id):
|
||||||
|
"""Deletes a limit bandwidth rule for a QoS policy.
|
||||||
|
|
||||||
|
For full list of available parameters, please refer to the official
|
||||||
|
API reference:
|
||||||
|
https://docs.openstack.org/api-ref/network/v2/index.html#delete-bandwidth-limit-rule
|
||||||
|
"""
|
||||||
|
uri = '/qos/policies/{}/bandwidth_limit_rules/{}'.format(
|
||||||
|
qos_policy_id, rule_id)
|
||||||
|
return self.delete_resource(uri)
|
||||||
|
|
||||||
|
def list_limit_bandwidth_rules(self, qos_policy_id, **filters):
|
||||||
|
"""Lists all limit bandwidth rules for a QoS policy.
|
||||||
|
|
||||||
|
For full list of available parameters, please refer to the official
|
||||||
|
API reference:
|
||||||
|
https://docs.openstack.org/api-ref/network/v2/index.html#list-bandwidth-limit-rules-for-qos-policy
|
||||||
|
"""
|
||||||
|
uri = '/qos/policies/%s/bandwidth_limit_rules'.format(qos_policy_id)
|
||||||
|
return self.list_resources(uri, **filters)
|
@ -38,7 +38,7 @@ class QosMinimumBandwidthRulesClient(base.BaseNetworkClient):
|
|||||||
uri = '/qos/policies/%s/minimum_bandwidth_rules/%s' % (
|
uri = '/qos/policies/%s/minimum_bandwidth_rules/%s' % (
|
||||||
qos_policy_id, rule_id)
|
qos_policy_id, rule_id)
|
||||||
post_data = {'minimum_bandwidth_rule': kwargs}
|
post_data = {'minimum_bandwidth_rule': kwargs}
|
||||||
return self.update_resource(uri, post_data)
|
return self.update_resource(uri, post_data, expect_response_code=202)
|
||||||
|
|
||||||
def show_minimum_bandwidth_rule(self, qos_policy_id, rule_id, **fields):
|
def show_minimum_bandwidth_rule(self, qos_policy_id, rule_id, **fields):
|
||||||
"""Show details of a minimum bandwidth rule.
|
"""Show details of a minimum bandwidth rule.
|
||||||
|
@ -0,0 +1,124 @@
|
|||||||
|
# Copyright 2021 Red Hat.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
import copy
|
||||||
|
|
||||||
|
from tempest.lib import decorators
|
||||||
|
|
||||||
|
from tempest.lib.services.network import qos_limit_bandwidth_rules_client
|
||||||
|
from tempest.tests.lib import fake_auth_provider
|
||||||
|
from tempest.tests.lib.services import base
|
||||||
|
|
||||||
|
from oslo_log import log as logging
|
||||||
|
LOG = logging.getLogger('tempest')
|
||||||
|
|
||||||
|
|
||||||
|
class TestQosLimitBandwidthRulesClient(base.BaseServiceTest):
|
||||||
|
|
||||||
|
FAKE_QOS_POLICY_ID = "f1011b08-1297-11e9-a1e7-c7e6825a2616"
|
||||||
|
FAKE_MAX_BW_RULE_ID = "e758c89e-1297-11e9-a6cf-cf46a71e6699"
|
||||||
|
|
||||||
|
FAKE_MAX_BW_RULE_REQUEST = {
|
||||||
|
'qos_policy_id': FAKE_QOS_POLICY_ID,
|
||||||
|
'max_kbps': 1000,
|
||||||
|
'max_burst_kbps': 0,
|
||||||
|
'direction': 'ingress'
|
||||||
|
}
|
||||||
|
|
||||||
|
FAKE_MAX_BW_RULE_RESPONSE = {
|
||||||
|
'bandwidth_limit_rule': {
|
||||||
|
'id': FAKE_MAX_BW_RULE_ID,
|
||||||
|
'max_kbps': 10000,
|
||||||
|
'max_burst_kbps': 0,
|
||||||
|
'direction': 'ingress'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FAKE_MAX_BW_RULES = {
|
||||||
|
'bandwidth_limit_rules': [
|
||||||
|
FAKE_MAX_BW_RULE_RESPONSE['bandwidth_limit_rule']
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestQosLimitBandwidthRulesClient, self).setUp()
|
||||||
|
fake_auth = fake_auth_provider.FakeAuthProvider()
|
||||||
|
self.qos_limit_bw_client = qos_limit_bandwidth_rules_client.\
|
||||||
|
QosLimitBandwidthRulesClient(fake_auth, "network", "regionOne")
|
||||||
|
|
||||||
|
@decorators.idempotent_id('cde981fa-e93b-11eb-aacb-74e5f9e2a801')
|
||||||
|
def test_create_limit_bandwidth_rules(self, bytes_body=False):
|
||||||
|
self.check_service_client_function(
|
||||||
|
self.qos_limit_bw_client.create_limit_bandwidth_rule,
|
||||||
|
"tempest.lib.common.rest_client.RestClient.post",
|
||||||
|
self.FAKE_MAX_BW_RULE_RESPONSE,
|
||||||
|
bytes_body,
|
||||||
|
201,
|
||||||
|
**self.FAKE_MAX_BW_RULE_REQUEST
|
||||||
|
)
|
||||||
|
|
||||||
|
@decorators.idempotent_id('86e6803a-e974-11eb-aacb-74e5f9e2a801')
|
||||||
|
def test_update_limit_bandwidth_rules(self, bytes_body=False):
|
||||||
|
update_kwargs = {
|
||||||
|
"max_kbps": "20000"
|
||||||
|
}
|
||||||
|
|
||||||
|
resp_body = {
|
||||||
|
"bandwidth_limit_rule": copy.deepcopy(
|
||||||
|
self.FAKE_MAX_BW_RULE_RESPONSE['bandwidth_limit_rule']
|
||||||
|
)
|
||||||
|
}
|
||||||
|
resp_body["bandwidth_limit_rule"].update(update_kwargs)
|
||||||
|
|
||||||
|
self.check_service_client_function(
|
||||||
|
self.qos_limit_bw_client.update_limit_bandwidth_rule,
|
||||||
|
"tempest.lib.common.rest_client.RestClient.put",
|
||||||
|
resp_body,
|
||||||
|
bytes_body,
|
||||||
|
202,
|
||||||
|
qos_policy_id=self.FAKE_QOS_POLICY_ID,
|
||||||
|
rule_id=self.FAKE_MAX_BW_RULE_ID,
|
||||||
|
**update_kwargs)
|
||||||
|
|
||||||
|
@decorators.idempotent_id('be60ae6e-e979-11eb-aacb-74e5f9e2a801')
|
||||||
|
def test_show_limit_bandwidth_rules(self, bytes_body=False):
|
||||||
|
self.check_service_client_function(
|
||||||
|
self.qos_limit_bw_client.show_limit_bandwidth_rule,
|
||||||
|
"tempest.lib.common.rest_client.RestClient.get",
|
||||||
|
self.FAKE_MAX_BW_RULE_RESPONSE,
|
||||||
|
bytes_body,
|
||||||
|
200,
|
||||||
|
qos_policy_id=self.FAKE_QOS_POLICY_ID,
|
||||||
|
rule_id=self.FAKE_MAX_BW_RULE_ID
|
||||||
|
)
|
||||||
|
|
||||||
|
@decorators.idempotent_id('0a7c0964-e97b-11eb-aacb-74e5f9e2a801')
|
||||||
|
def test_delete_limit_bandwidth_rule(self):
|
||||||
|
self.check_service_client_function(
|
||||||
|
self.qos_limit_bw_client.delete_limit_bandwidth_rule,
|
||||||
|
"tempest.lib.common.rest_client.RestClient.delete",
|
||||||
|
{},
|
||||||
|
status=204,
|
||||||
|
qos_policy_id=self.FAKE_QOS_POLICY_ID,
|
||||||
|
rule_id=self.FAKE_MAX_BW_RULE_ID)
|
||||||
|
|
||||||
|
@decorators.idempotent_id('08df88ae-e97d-11eb-aacb-74e5f9e2a801')
|
||||||
|
def test_list_minimum_bandwidth_rules(self, bytes_body=False):
|
||||||
|
self.check_service_client_function(
|
||||||
|
self.qos_limit_bw_client.list_limit_bandwidth_rules,
|
||||||
|
"tempest.lib.common.rest_client.RestClient.get",
|
||||||
|
self.FAKE_MAX_BW_RULES,
|
||||||
|
bytes_body,
|
||||||
|
200,
|
||||||
|
qos_policy_id=self.FAKE_QOS_POLICY_ID
|
||||||
|
)
|
@ -98,7 +98,7 @@ class TestQosMinimumBandwidthRulesClient(base.BaseServiceTest):
|
|||||||
"tempest.lib.common.rest_client.RestClient.put",
|
"tempest.lib.common.rest_client.RestClient.put",
|
||||||
resp_body,
|
resp_body,
|
||||||
bytes_body,
|
bytes_body,
|
||||||
200,
|
202,
|
||||||
qos_policy_id=self.FAKE_QOS_POLICY_ID,
|
qos_policy_id=self.FAKE_QOS_POLICY_ID,
|
||||||
rule_id=self.FAKE_MIN_BW_RULE_ID,
|
rule_id=self.FAKE_MIN_BW_RULE_ID,
|
||||||
**update_kwargs)
|
**update_kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user