Add QoS policies and minimum bandwidth rule client

The goal of the QoS policies and QoS minimum bandwidth rules client for
tempest is to make possible the end-to-end testing of the placement
based bandwidth feature.

Change-Id: I417574e3ef24e658b6cd2ce290f897180fed5300
Partial-Bug: #1578989
See-Also: https://review.openstack.org/502306 (nova spec)
See-Also: https://review.openstack.org/508149 (neutron spec)
This commit is contained in:
Lajos Katona 2019-01-04 14:49:34 +01:00 committed by elajkat
parent 09c4eb99ce
commit e8a5e5c824
7 changed files with 453 additions and 3 deletions

View File

@ -0,0 +1,25 @@
---
features:
- |
Add ``qos-policies`` and ``qos-minimum-bandwidth-rule`` clients
to Tempest to make possible the testing of the placement based
bandwidth allocation feature.
The following API calls are available for tempest from now:
``QoS policies`` client:
* GET /qos/policies
* POST /qos/policies
* GET /qos/policies/{policy_id}
* PUT /qos/policies/{policy_id}
* DELETE /qos/policies/{policy_id}
``QoS minimum bandwidth rules`` client:
* GET qos/policies/{policy_id}/minimum_bandwidth_rules
* POST /qos/policies/{policy_id}/minimum_bandwidth_rules
* GET qos/policies/{policy_id}/minimum_bandwidth_rules/{rule_id}
* PUT qos/policies/{policy_id}/minimum_bandwidth_rules/{rule_id}
* DELETE /qos/policies/{policy_id}/minimum_bandwidth_rules/{rule_id}

View File

@ -69,6 +69,8 @@ class Manager(clients.ServiceClients):
self.network_versions_client = self.network.NetworkVersionsClient()
self.service_providers_client = self.network.ServiceProvidersClient()
self.tags_client = self.network.TagsClient()
self.qos_client = self.network.QosClient()
self.qos_min_bw_client = self.network.QosMinimumBandwidthRulesClient()
def _set_image_clients(self):
if CONF.service_available.glance:

View File

@ -21,6 +21,9 @@ from tempest.lib.services.network.metering_labels_client import \
MeteringLabelsClient
from tempest.lib.services.network.networks_client import NetworksClient
from tempest.lib.services.network.ports_client import PortsClient
from tempest.lib.services.network.qos_client import QosClient
from tempest.lib.services.network.qos_minimum_bandwidth_rules_client import \
QosMinimumBandwidthRulesClient
from tempest.lib.services.network.quotas_client import QuotasClient
from tempest.lib.services.network.routers_client import RoutersClient
from tempest.lib.services.network.security_group_rules_client import \
@ -37,6 +40,7 @@ from tempest.lib.services.network.versions_client import NetworkVersionsClient
__all__ = ['AgentsClient', 'ExtensionsClient', 'FloatingIPsClient',
'MeteringLabelRulesClient', 'MeteringLabelsClient',
'NetworksClient', 'NetworkVersionsClient', 'PortsClient',
'QuotasClient', 'RoutersClient', 'SecurityGroupRulesClient',
'SecurityGroupsClient', 'ServiceProvidersClient',
'SubnetpoolsClient', 'SubnetsClient', 'TagsClient']
'QosClient', 'QosMinimumBandwidthRulesClient', 'QuotasClient',
'RoutersClient', 'SecurityGroupRulesClient', 'SecurityGroupsClient',
'ServiceProvidersClient', 'SubnetpoolsClient', 'SubnetsClient',
'TagsClient']

View File

@ -0,0 +1,70 @@
# Copyright (c) 2019 Ericsson
#
# 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 QosClient(base.BaseNetworkClient):
def create_qos_policy(self, **kwargs):
"""Creates a QoS policy.
For full list of available parameters, please refer to the official
API reference:
https://developer.openstack.org/api-ref/network/v2/index.html#create-qos-policy
"""
uri = '/qos/policies'
post_data = {'policy': kwargs}
return self.create_resource(uri, post_data)
def update_qos_policy(self, qos_policy_id, **kwargs):
"""Updates a QoS policy.
For full list of available parameters, please refer to the official
API reference:
https://developer.openstack.org/api-ref/network/v2/index.html#update-qos-policy
"""
uri = '/qos/policies/%s' % qos_policy_id
post_data = {'policy': kwargs}
return self.update_resource(uri, post_data)
def show_qos_policy(self, qos_policy_id, **fields):
"""Show details of a QoS policy.
For full list of available parameters, please refer to the official
API reference:
https://developer.openstack.org/api-ref/network/v2/index.html#show-qos-policy-details
"""
uri = '/qos/policies/%s' % qos_policy_id
return self.show_resource(uri, **fields)
def delete_qos_policy(self, qos_policy_id):
"""Deletes a QoS policy.
For full list of available parameters, please refer to the official
API reference:
https://developer.openstack.org/api-ref/network/v2/index.html#delete-qos-policy
"""
uri = '/qos/policies/%s' % qos_policy_id
return self.delete_resource(uri)
def list_qos_policies(self, **filters):
"""Lists QoS policies.
For full list of available parameters, please refer to the official
API reference:
https://developer.openstack.org/api-ref/network/v2/index.html#list-qos-policies
"""
uri = '/qos/policies'
return self.list_resources(uri, **filters)

View File

@ -0,0 +1,73 @@
# Copyright (c) 2019 Ericsson
#
# 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 QosMinimumBandwidthRulesClient(base.BaseNetworkClient):
def create_minimum_bandwidth_rule(self, qos_policy_id, **kwargs):
"""Creates a minimum bandwidth rule for a QoS policy.
For full list of available parameters, please refer to the official
API reference:
https://developer.openstack.org/api-ref/network/v2/index.html#create-minimum-bandwidth-rule
"""
uri = '/qos/policies/%s/minimum_bandwidth_rules' % qos_policy_id
post_data = {'minimum_bandwidth_rule': kwargs}
return self.create_resource(uri, post_data)
def update_minimum_bandwidth_rule(self, qos_policy_id, rule_id, **kwargs):
"""Updates a minimum bandwidth rule.
For full list of available parameters, please refer to the official
API reference:
https://developer.openstack.org/api-ref/network/v2/index.html#update-minimum-bandwidth-rule
"""
uri = '/qos/policies/%s/minimum_bandwidth_rules/%s' % (
qos_policy_id, rule_id)
post_data = {'minimum_bandwidth_rule': kwargs}
return self.update_resource(uri, post_data)
def show_minimum_bandwidth_rule(self, qos_policy_id, rule_id, **fields):
"""Show details of a minimum bandwidth rule.
For full list of available parameters, please refer to the official
API reference:
https://developer.openstack.org/api-ref/network/v2/index.html#show-minimum-bandwidth-rule-details
"""
uri = '/qos/policies/%s/minimum_bandwidth_rules/%s' % (
qos_policy_id, rule_id)
return self.show_resource(uri, **fields)
def delete_minimum_bandwidth_rule(self, qos_policy_id, rule_id):
"""Deletes a minimum bandwidth rule for a QoS policy.
For full list of available parameters, please refer to the official
API reference:
https://developer.openstack.org/api-ref/network/v2/index.html#delete-minimum-bandwidth-rule
"""
uri = '/qos/policies/%s/minimum_bandwidth_rules/%s' % (
qos_policy_id, rule_id)
return self.delete_resource(uri)
def list_minimum_bandwidth_rules(self, qos_policy_id, **filters):
"""Lists all minimum bandwidth rules for a QoS policy.
For full list of available parameters, please refer to the official
API reference:
https://developer.openstack.org/api-ref/network/v2/index.html#list-minimum-bandwidth-rules-for-qos-policy
"""
uri = '/qos/policies/%s/minimum_bandwidth_rules' % qos_policy_id
return self.list_resources(uri, **filters)

View File

@ -0,0 +1,139 @@
# Copyright (c) 2019 Ericsson
#
# 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.services.network import qos_client
from tempest.tests.lib import fake_auth_provider
from tempest.tests.lib.services import base
class TestQosClient(base.BaseServiceTest):
FAKE_QOS_POLICY_ID = "f1011b08-1297-11e9-a1e7-c7e6825a2616"
FAKE_QOS_POLICY_REQUEST = {
'name': 'foo',
'shared': True
}
FAKE_QOS_POLICY_RESPONSE = {
'policy': {
"name": "10Mbit",
"description": "This policy limits the ports to 10Mbit max.",
"rules": [],
"id": FAKE_QOS_POLICY_ID,
"is_default": False,
"project_id": "8d4c70a21fed4aeba121a1a429ba0d04",
"revision_number": 1,
"tenant_id": "8d4c70a21fed4aeba121a1a429ba0d04",
"created_at": "2018-04-03T21:26:39Z",
"updated_at": "2018-04-03T21:26:39Z",
"shared": False,
"tags": ["tag1,tag2"]
}
}
FAKE_QOS_POLICIES = {
'policies': [
FAKE_QOS_POLICY_RESPONSE['policy']
]
}
def setUp(self):
super(TestQosClient, self).setUp()
fake_auth = fake_auth_provider.FakeAuthProvider()
self.qos_client = qos_client.QosClient(
fake_auth, "network", "regionOne")
def _test_create_qos_policy(self, bytes_body=False):
self.check_service_client_function(
self.qos_client.create_qos_policy,
"tempest.lib.common.rest_client.RestClient.post",
self.FAKE_QOS_POLICY_RESPONSE,
bytes_body,
201,
**self.FAKE_QOS_POLICY_REQUEST)
def _test_list_qos_policies(self, bytes_body=False):
self.check_service_client_function(
self.qos_client.list_qos_policies,
"tempest.lib.common.rest_client.RestClient.get",
self.FAKE_QOS_POLICIES,
bytes_body,
200)
def _test_show_qos_policy(self, bytes_body=False):
self.check_service_client_function(
self.qos_client.show_qos_policy,
"tempest.lib.common.rest_client.RestClient.get",
self.FAKE_QOS_POLICY_RESPONSE,
bytes_body,
200,
qos_policy_id=self.FAKE_QOS_POLICY_ID)
def _test_update_qos_polcy(self, bytes_body=False):
update_kwargs = {
"name": "100Mbit",
"description": "This policy limits the ports to 100Mbit max.",
"shared": True
}
resp_body = {
"policy": copy.deepcopy(
self.FAKE_QOS_POLICY_RESPONSE['policy']
)
}
resp_body["policy"].update(update_kwargs)
self.check_service_client_function(
self.qos_client.update_qos_policy,
"tempest.lib.common.rest_client.RestClient.put",
resp_body,
bytes_body,
200,
qos_policy_id=self.FAKE_QOS_POLICY_ID,
**update_kwargs)
def test_create_qos_policy_with_str_body(self):
self._test_create_qos_policy()
def test_create_qos_policy_with_bytes_body(self):
self._test_create_qos_policy(bytes_body=True)
def test_update_qos_policy_with_str_body(self):
self._test_update_qos_polcy()
def test_update_qos_policy_with_bytes_body(self):
self._test_update_qos_polcy(bytes_body=True)
def test_show_qos_policy_with_str_body(self):
self._test_show_qos_policy()
def test_show_qos_policy_with_bytes_body(self):
self._test_show_qos_policy(bytes_body=True)
def test_delete_qos_policy(self):
self.check_service_client_function(
self.qos_client.delete_qos_policy,
"tempest.lib.common.rest_client.RestClient.delete",
{},
status=204,
qos_policy_id=self.FAKE_QOS_POLICY_ID)
def test_list_qos_policies_with_str_body(self):
self._test_list_qos_policies()
def test_list_qos_policies_with_bytes_body(self):
self._test_list_qos_policies(bytes_body=True)

View File

@ -0,0 +1,137 @@
# Copyright (c) 2019 Ericsson
#
# 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.services.network import qos_minimum_bandwidth_rules_client
from tempest.tests.lib import fake_auth_provider
from tempest.tests.lib.services import base
class TestQosMinimumBandwidthRulesClient(base.BaseServiceTest):
FAKE_QOS_POLICY_ID = "f1011b08-1297-11e9-a1e7-c7e6825a2616"
FAKE_MIN_BW_RULE_ID = "e758c89e-1297-11e9-a6cf-cf46a71e6699"
FAKE_MIN_BW_RULE_REQUEST = {
'qos_policy_id': FAKE_QOS_POLICY_ID,
'min_kbps': 1000,
'direction': 'ingress'
}
FAKE_MIN_BW_RULE_RESPONSE = {
'minimum_bandwidth_rule': {
'id': FAKE_MIN_BW_RULE_ID,
'min_kbps': 10000,
'direction': 'egress'
}
}
FAKE_MIN_BW_RULES = {
'bandwidth_limit_rules': [
FAKE_MIN_BW_RULE_RESPONSE['minimum_bandwidth_rule']
]
}
def setUp(self):
super(TestQosMinimumBandwidthRulesClient, self).setUp()
fake_auth = fake_auth_provider.FakeAuthProvider()
self.qos_min_bw_client = qos_minimum_bandwidth_rules_client.\
QosMinimumBandwidthRulesClient(fake_auth, "network", "regionOne")
def _test_create_minimum_bandwidth_rule(self, bytes_body=False):
self.check_service_client_function(
self.qos_min_bw_client.create_minimum_bandwidth_rule,
"tempest.lib.common.rest_client.RestClient.post",
self.FAKE_MIN_BW_RULE_RESPONSE,
bytes_body,
201,
**self.FAKE_MIN_BW_RULE_REQUEST
)
def _test_list_minimum_bandwidth_rules(self, bytes_body=False):
self.check_service_client_function(
self.qos_min_bw_client.list_minimum_bandwidth_rules,
"tempest.lib.common.rest_client.RestClient.get",
self.FAKE_MIN_BW_RULES,
bytes_body,
200,
qos_policy_id=self.FAKE_QOS_POLICY_ID
)
def _test_show_minimum_bandwidth_rule(self, bytes_body=False):
self.check_service_client_function(
self.qos_min_bw_client.show_minimum_bandwidth_rule,
"tempest.lib.common.rest_client.RestClient.get",
self.FAKE_MIN_BW_RULE_RESPONSE,
bytes_body,
200,
qos_policy_id=self.FAKE_QOS_POLICY_ID,
rule_id=self.FAKE_MIN_BW_RULE_ID
)
def _test_update_qos_polcy(self, bytes_body=False):
update_kwargs = {
"min_kbps": "20000"
}
resp_body = {
"minimum_bandwidth_rule": copy.deepcopy(
self.FAKE_MIN_BW_RULE_RESPONSE['minimum_bandwidth_rule']
)
}
resp_body["minimum_bandwidth_rule"].update(update_kwargs)
self.check_service_client_function(
self.qos_min_bw_client.update_minimum_bandwidth_rule,
"tempest.lib.common.rest_client.RestClient.put",
resp_body,
bytes_body,
200,
qos_policy_id=self.FAKE_QOS_POLICY_ID,
rule_id=self.FAKE_MIN_BW_RULE_ID,
**update_kwargs)
def test_create_minimum_bandwidth_rule_with_str_body(self):
self._test_create_minimum_bandwidth_rule()
def test_create_minimum_bandwidth_rule_with_bytes_body(self):
self._test_create_minimum_bandwidth_rule(bytes_body=True)
def test_update_minimum_bandwidth_rule_with_str_body(self):
self._test_update_qos_polcy()
def test_update_minimum_bandwidth_rule_with_bytes_body(self):
self._test_update_qos_polcy(bytes_body=True)
def test_show_minimum_bandwidth_rule_with_str_body(self):
self._test_show_minimum_bandwidth_rule()
def test_show_minimum_bandwidth_rule_with_bytes_body(self):
self._test_show_minimum_bandwidth_rule(bytes_body=True)
def test_delete_minimum_bandwidth_rule(self):
self.check_service_client_function(
self.qos_min_bw_client.delete_minimum_bandwidth_rule,
"tempest.lib.common.rest_client.RestClient.delete",
{},
status=204,
qos_policy_id=self.FAKE_QOS_POLICY_ID,
rule_id=self.FAKE_MIN_BW_RULE_ID)
def test_list_minimum_bandwidth_rule_with_str_body(self):
self._test_list_minimum_bandwidth_rules()
def test_list_minimum_bandwidth_rule_with_bytes_body(self):
self._test_list_minimum_bandwidth_rules(bytes_body=True)