Add test to create policy with multiple rules
The test validates that:
1.Two bandwidth limit rules could be both attached to a policy.
2.The system prevents addition of rules with the same direction to a policy.
Change-Id: I387d50673795c2a5073ec298426960fca593c017
diff --git a/neutron_tempest_plugin/api/test_qos.py b/neutron_tempest_plugin/api/test_qos.py
index 25d2e81..b54cc66 100644
--- a/neutron_tempest_plugin/api/test_qos.py
+++ b/neutron_tempest_plugin/api/test_qos.py
@@ -588,7 +588,8 @@
class QosBandwidthLimitRuleWithDirectionTestJSON(
QosBandwidthLimitRuleTestJSON):
-
+ DIRECTION_EGRESS = "egress"
+ DIRECTION_INGRESS = "ingress"
required_extensions = (
QosBandwidthLimitRuleTestJSON.required_extensions +
['qos-bw-limit-direction']
@@ -598,6 +599,50 @@
('egress', {'direction': 'egress'}),
]
+ @classmethod
+ @base.require_qos_rule_type(qos_consts.RULE_TYPE_BANDWIDTH_LIMIT)
+ def resource_setup(cls):
+ super(QosBandwidthLimitRuleWithDirectionTestJSON, cls).resource_setup()
+
+ @decorators.idempotent_id('c8cbe502-0f7e-11ea-8d71-362b9e155667')
+ def test_create_policy_with_multiple_rules(self):
+ # Create a policy with multiple rules
+ policy = self.create_qos_policy(name='test-policy1',
+ description='test policy1',
+ shared=False)
+
+ rule1 = self.create_qos_bandwidth_limit_rule(policy_id=policy['id'],
+ max_kbps=1024,
+ max_burst_kbps=1024,
+ direction=self.
+ DIRECTION_EGRESS)
+ rule2 = self.create_qos_bandwidth_limit_rule(policy_id=policy['id'],
+ max_kbps=1024,
+ max_burst_kbps=1024,
+ direction=self.
+ DIRECTION_INGRESS)
+ # Check that the rules were added to the policy
+ rules = self.admin_client.list_bandwidth_limit_rules(
+ policy['id'])['bandwidth_limit_rules']
+ rules_ids = [rule['id'] for rule in rules]
+ self.assertIn(rule1['id'], rules_ids)
+ self.assertIn(rule2['id'], rules_ids)
+
+ # Check that the rules creation fails for the same rule types
+ self.assertRaises(exceptions.Conflict,
+ self.create_qos_bandwidth_limit_rule,
+ policy_id=policy['id'],
+ max_kbps=1025,
+ max_burst_kbps=1025,
+ direction=self.DIRECTION_EGRESS)
+
+ self.assertRaises(exceptions.Conflict,
+ self.create_qos_bandwidth_limit_rule,
+ policy_id=policy['id'],
+ max_kbps=1025,
+ max_burst_kbps=1025,
+ direction=self.DIRECTION_INGRESS)
+
class RbacSharedQosPoliciesTest(base.BaseAdminNetworkTest):