summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-05-03 15:34:34 +0000
committerGerrit Code Review <review@openstack.org>2013-05-03 15:34:34 +0000
commit3303ef95e425f9dc5d295a41ca79de40841b81a6 (patch)
tree938a08b88489c3be36bfa118044d8493e5d8005f /nova/tests
parent138b7ffb5ec35eb1806fbe2c5edff2d19dae08cb (diff)
parent6dc7dedaf08de70264a00824dfd35e8e03ffb610 (diff)
Merge "Remove race condition (in FloatingIps)"
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_db_api.py9
-rw-r--r--nova/tests/test_migrations.py30
2 files changed, 39 insertions, 0 deletions
diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py
index fcba2aefa..a3c281b49 100644
--- a/nova/tests/test_db_api.py
+++ b/nova/tests/test_db_api.py
@@ -2989,6 +2989,15 @@ class FloatingIpTestCase(test.TestCase, ModelsObjectComparatorMixin):
'deleted', 'fixed_ip_id',
'fixed_ip'])
+ def test_floating_ip_update_to_duplicate(self):
+ float_ip1 = self._create_floating_ip({'address': '1.1.1.1'})
+ float_ip2 = self._create_floating_ip({'address': '1.1.1.2'})
+
+ self.assertRaises(exception.FloatingIpExists,
+ db.floating_ip_update,
+ self.ctxt, float_ip2['address'],
+ {'address': float_ip1['address']})
+
class InstanceDestroyConstraints(test.TestCase):
diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py
index 8c2f04f21..a0f71b25a 100644
--- a/nova/tests/test_migrations.py
+++ b/nova/tests/test_migrations.py
@@ -1285,6 +1285,36 @@ class TestNovaMigrations(BaseMigrationTestCase, CommonTestsMixIn):
self.assertFalse('availability_zone' in rows[0])
+ def _pre_upgrade_177(self, engine):
+ floating_ips = get_table(engine, 'floating_ips')
+ data = [
+ {'address': '128.128.128.128', 'deleted': 0},
+ {'address': '128.128.128.128', 'deleted': 0},
+ {'address': '128.128.128.129', 'deleted': 0},
+ ]
+
+ for item in data:
+ floating_ips.insert().values(item).execute()
+ return data
+
+ def _check_177(self, engine, data):
+ floating_ips = get_table(engine, 'floating_ips')
+
+ def get_(address, deleted):
+ deleted_value = 0 if not deleted else floating_ips.c.id
+ return floating_ips.select().\
+ where(floating_ips.c.address == address).\
+ where(floating_ips.c.deleted == deleted_value).\
+ execute().\
+ fetchall()
+
+ self.assertEqual(1, len(get_('128.128.128.128', False)))
+ self.assertEqual(1, len(get_('128.128.128.128', True)))
+ self.assertEqual(1, len(get_('128.128.128.129', False)))
+ self.assertRaises(sqlalchemy.exc.IntegrityError,
+ floating_ips.insert().execute,
+ dict(address='128.128.128.129', deleted=0))
+
class TestBaremetalMigrations(BaseMigrationTestCase, CommonTestsMixIn):
"""Test sqlalchemy-migrate migrations."""