fix greenthread race conditions in trunk and floating ip leakage

This commit is contained in:
Vishvananda Ishaya
2010-11-17 21:23:12 +00:00
parent 1b9e17b764
commit 4506d3530e
2 changed files with 7 additions and 5 deletions

View File

@@ -101,6 +101,7 @@ class CloudTestCase(test.TrialTestCase):
self.cloud.describe_addresses(self.context)
self.cloud.release_address(self.context,
public_ip=address)
greenthread.sleep(0.3)
db.floating_ip_destroy(self.context, address)
def test_associate_disassociate_address(self):
@@ -111,6 +112,7 @@ class CloudTestCase(test.TrialTestCase):
'host': FLAGS.host})
self.cloud.allocate_address(self.context)
inst = db.instance_create(self.context, {})
fixed = self.network.allocate_fixed_ip(self.context, inst['id'])
ec2_id = cloud.internal_id_to_ec2_id(inst['internal_id'])
self.cloud.associate_address(self.context,
instance_id=ec2_id,
@@ -119,6 +121,8 @@ class CloudTestCase(test.TrialTestCase):
public_ip=address)
self.cloud.release_address(self.context,
public_ip=address)
greenthread.sleep(0.3)
self.network.deallocate_fixed_ip(self.context, fixed)
db.instance_destroy(self.context, inst['id'])
db.floating_ip_destroy(self.context, address)

View File

@@ -138,11 +138,8 @@ class QuotaTestCase(test.TrialTestCase):
def test_too_many_addresses(self):
address = '192.168.0.100'
try:
db.floating_ip_get_by_address(context.get_admin_context(), address)
except exception.NotFound:
db.floating_ip_create(context.get_admin_context(),
{'address': address, 'host': FLAGS.host})
db.floating_ip_create(context.get_admin_context(),
{'address': address, 'host': FLAGS.host})
float_addr = self.network.allocate_floating_ip(self.context,
self.project.id)
# NOTE(vish): This assert never fails. When cloud attempts to
@@ -151,3 +148,4 @@ class QuotaTestCase(test.TrialTestCase):
# that is breaking.
self.assertRaises(cloud.QuotaError, self.cloud.allocate_address,
self.context)
db.floating_ip_destroy(context.get_admin_context(), address)