Cleanup Security Group rules after TC execution
Security group rules created by SecGroupRulesQuotaTest are not
being cleaned up after TC execution. Security Group rules normally
would get cleanup if associated Security Group is deleted. However,
SecGroupRulesQuotaTest doesn't create any Security Groups. The
Security Group rules are created in default or existing Security
Groups. Thus, the SecGroupRulesQuotaTest should be responsible to
clean up the rules which created by the TC.
Change-Id: I4dd2d9eb7e60101ba7f5c3d915ec27ee6c46b227
diff --git a/neutron_tempest_plugin/api/test_security_groups.py b/neutron_tempest_plugin/api/test_security_groups.py
index 94b6dbf..0970d83 100644
--- a/neutron_tempest_plugin/api/test_security_groups.py
+++ b/neutron_tempest_plugin/api/test_security_groups.py
@@ -240,12 +240,14 @@
def _create_security_group_rules(self, amount, port_index=1):
for i in range(amount):
- self.create_security_group_rule(**{
+ ingress_rule = self.create_security_group_rule(**{
'project_id': self.client.tenant_id,
'direction': 'ingress',
'port_range_max': port_index + i,
'port_range_min': port_index + i,
'protocol': 'tcp'})
+ self.addCleanup(
+ self.client.delete_security_group_rule, ingress_rule['id'])
def _increase_sg_rules_quota(self):
sg_rules_quota = self._get_sg_rules_quota()