Merge "Tempest tests uses only supported QoS rule types"
diff --git a/neutron/tests/tempest/api/base.py b/neutron/tests/tempest/api/base.py
index 3321ad4..0d77064 100644
--- a/neutron/tests/tempest/api/base.py
+++ b/neutron/tests/tempest/api/base.py
@@ -349,6 +349,11 @@
return interface
@classmethod
+ def get_supported_qos_rule_types(cls):
+ body = cls.client.list_qos_rule_types()
+ return [rule_type['type'] for rule_type in body['rule_types']]
+
+ @classmethod
def create_qos_policy(cls, name, description=None, shared=False,
tenant_id=None):
"""Wrapper utility that returns a test QoS policy."""
@@ -492,6 +497,18 @@
raise exceptions.InvalidConfiguration(message)
+def require_qos_rule_type(rule_type):
+ def decorator(f):
+ @functools.wraps(f)
+ def wrapper(self, *func_args, **func_kwargs):
+ if rule_type not in self.get_supported_qos_rule_types():
+ raise self.skipException(
+ "%s rule type is required." % rule_type)
+ return f(self, *func_args, **func_kwargs)
+ return wrapper
+ return decorator
+
+
def _require_sorting(f):
@functools.wraps(f)
def inner(self, *args, **kwargs):
diff --git a/neutron/tests/tempest/api/test_qos.py b/neutron/tests/tempest/api/test_qos.py
index 2f1c75a..7752f94 100644
--- a/neutron/tests/tempest/api/test_qos.py
+++ b/neutron/tests/tempest/api/test_qos.py
@@ -360,6 +360,7 @@
class QosBandwidthLimitRuleTestJSON(base.BaseAdminNetworkTest):
@classmethod
+ @base.require_qos_rule_type(qos_consts.RULE_TYPE_BANDWIDTH_LIMIT)
@test.requires_ext(extension="qos", service="network")
def resource_setup(cls):
super(QosBandwidthLimitRuleTestJSON, cls).resource_setup()
@@ -771,6 +772,7 @@
VALID_DSCP_MARK2 = 48
@classmethod
+ @base.require_qos_rule_type(qos_consts.RULE_TYPE_DSCP_MARKING)
@test.requires_ext(extension="qos", service="network")
def resource_setup(cls):
super(QosDscpMarkingRuleTestJSON, cls).resource_setup()
@@ -904,6 +906,7 @@
RULES_NAME = RULE_NAME + "s"
@classmethod
+ @base.require_qos_rule_type(qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH)
@test.requires_ext(extension="qos", service="network")
def resource_setup(cls):
super(QosMinimumBandwidthRuleTestJSON, cls).resource_setup()
diff --git a/neutron/tests/tempest/scenario/test_qos.py b/neutron/tests/tempest/scenario/test_qos.py
index a58b6e4..f44e631 100644
--- a/neutron/tests/tempest/scenario/test_qos.py
+++ b/neutron/tests/tempest/scenario/test_qos.py
@@ -22,6 +22,8 @@
from tempest import test
from neutron.common import utils
+from neutron.services.qos import qos_consts
+from neutron.tests.tempest.api import base as base_api
from neutron.tests.tempest import config
from neutron.tests.tempest.scenario import base
from neutron.tests.tempest.scenario import constants
@@ -78,6 +80,7 @@
FILE_PATH = "/tmp/img"
@classmethod
+ @base_api.require_qos_rule_type(qos_consts.RULE_TYPE_BANDWIDTH_LIMIT)
@test.requires_ext(extension="qos", service="network")
def resource_setup(cls):
super(QoSTest, cls).resource_setup()