From 5ca931c6d0e3a4759e7392cc7ee5f728d66c182f Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Thu, 15 Mar 2012 22:52:49 -0400 Subject: [PATCH] Re-instate security group delete test case While fixing lp#956366, we realized that it's fine to delete a security group referenced by an ingress rule of another security group because the ingress rule gets deleted. Re-instate the test for this specific case, but test that the ingress rule gets deleted rather than an exception being thrown. Change-Id: I81ad16431f5f8f13561dfcb320213366e1e8864e --- nova/tests/api/ec2/test_cloud.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py index fc6c656fe13..29ee3b7de1c 100644 --- a/nova/tests/api/ec2/test_cloud.py +++ b/nova/tests/api/ec2/test_cloud.py @@ -496,6 +496,25 @@ def test_revoke_security_group_ingress_missing_group_name_or_id(self): self.assertRaises(exception.EC2APIError, revoke, self.context, **kwargs) + def test_delete_security_group_in_use_by_group(self): + group1 = self.cloud.create_security_group(self.context, 'testgrp1', + "test group 1") + group2 = self.cloud.create_security_group(self.context, 'testgrp2', + "test group 2") + kwargs = {'groups': {'1': {'user_id': u'%s' % self.context.user_id, + 'group_name': u'testgrp2'}}, + } + self.cloud.authorize_security_group_ingress(self.context, + group_name='testgrp1', **kwargs) + + group1 = db.security_group_get_by_name(self.context, + self.project_id, 'testgrp1') + get_rules = db.security_group_rule_get_by_security_group + + self.assertTrue(get_rules(self.context, group1.id)) + self.cloud.delete_security_group(self.context, 'testgrp2') + self.assertFalse(get_rules(self.context, group1.id)) + def test_delete_security_group_in_use_by_instance(self): """Ensure that a group can not be deleted if in use by an instance.""" image_uuid = 'cedef40a-ed67-4d10-800e-17455edce175'