From a97204f81556308a32c73a6a27e8dd9cd4b2c9f8 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Sat, 19 Jan 2013 14:33:04 -0500 Subject: [PATCH] fix mysql race in tests because of testr, we can't assume the migrations tests run in sequence, so they make run all at the same time. This is fine for our in memory sqlite db, but when talking to a real external database, not so good. Since a second mysql test was added, we started racing on these migrations them often hitting at the same time causing random fails in gate. Fix this by moving all the mysql tests into 1 test function, so we won't race. Fixes bug #1101874 Change-Id: I7627f3bd510266c99af018d355f960b352573759 --- nova/tests/test_migrations.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py index abd04a64..82c95889 100644 --- a/nova/tests/test_migrations.py +++ b/nova/tests/test_migrations.py @@ -222,7 +222,7 @@ class TestMigrations(test.TestCase): if _is_backend_avail('mysql', user="openstack_cifail"): self.fail("Shouldn't have connected") - def test_mysql_innodb(self): + def test_mysql_opportunistically(self): # Test that table creation on mysql only builds InnoDB tables if not _is_backend_avail('mysql'): self.skipTest("mysql not available") @@ -233,6 +233,12 @@ class TestMigrations(test.TestCase): self.engines["mysqlcitest"] = engine self.test_databases["mysqlcitest"] = connect_string + # Test that we end in an innodb + self._check_mysql_innodb(engine) + # Test IP transition + self._check_mysql_migration_149(engine) + + def _check_mysql_innodb(self, engine): # build a fully populated mysql database with all the tables self._reset_databases() self._walk_versions(engine, False, False) @@ -298,16 +304,8 @@ class TestMigrations(test.TestCase): "AND column_name='cidr'").scalar()) connection.close() - def test_migration_149_mysql(self): + def _check_mysql_migration_149(self, engine): """Test updating a table with IPAddress columns.""" - if not _have_mysql(): - self.skipTest("mysql not available") - - connect_string = _get_connect_string("mysql") - engine = sqlalchemy.create_engine(connect_string) - self.engines["mysqlcitest"] = engine - self.test_databases["mysqlcitest"] = connect_string - self._reset_databases() migration_api.version_control(engine, TestMigrations.REPOSITORY, migration.INIT_VERSION)