summaryrefslogtreecommitdiffstats
path: root/tests/test_sql_upgrade.py
diff options
context:
space:
mode:
authorBrant Knudson <bknudson@us.ibm.com>2013-06-14 13:03:41 -0500
committerBrant Knudson <bknudson@us.ibm.com>2013-07-10 13:23:33 -0500
commitcd8fa2b0e7ca002b7621fe0e35b921154946e12b (patch)
tree70bf55adb9813986c796f05a99e7dcaa5365d6c6 /tests/test_sql_upgrade.py
parent25277d0d2866df6a3378540a4ef0778398090475 (diff)
downloadkeystone-cd8fa2b0e7ca002b7621fe0e35b921154946e12b.tar.gz
keystone-cd8fa2b0e7ca002b7621fe0e35b921154946e12b.tar.xz
keystone-cd8fa2b0e7ca002b7621fe0e35b921154946e12b.zip
Use InnoDB for MySQL
This change adds a migration to convert any non-InnoDB tables to InnoDB. On some systems, the default engine is MyISAM, which doesn't support features used by Keystone (foreign keys). The approach is the same as what's used in Nova. A test is added to ensure that all tables use InnoDB after migration. The test passes when all the tables are mysql_engine='InnoDB'. This is accomplished by adding a new migration that migrates all the tables that aren't InnoDB to InnoDB. Fixes bug 1191110. Change-Id: I220f7642f5468c5cf4194f248210f90ff983b6e5
Diffstat (limited to 'tests/test_sql_upgrade.py')
-rw-r--r--tests/test_sql_upgrade.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_sql_upgrade.py b/tests/test_sql_upgrade.py
index 21db6ade..e7e34b4b 100644
--- a/tests/test_sql_upgrade.py
+++ b/tests/test_sql_upgrade.py
@@ -506,6 +506,10 @@ class SqlUpgradeTests(test.TestCase):
def test_downgrade_to_0(self):
self.upgrade(self.max_version)
+
+ if self.engine.name == 'mysql':
+ self._mysql_check_all_tables_innodb()
+
self.downgrade(0)
for table_name in ["user", "token", "role", "user_tenant_membership",
"metadata"]:
@@ -961,3 +965,26 @@ class SqlUpgradeTests(test.TestCase):
for ver, change in changeset:
self.schema.runchange(ver, change, changeset.step)
self.assertEqual(self.schema.version, version)
+
+ def _mysql_check_all_tables_innodb(self):
+ database = self.engine.url.database
+
+ connection = self.engine.connect()
+ # sanity check
+ total = connection.execute("SELECT count(*) "
+ "from information_schema.TABLES "
+ "where TABLE_SCHEMA='%(database)s'" %
+ locals())
+ self.assertTrue(total.scalar() > 0, "No tables found. Wrong schema?")
+
+ noninnodb = connection.execute("SELECT table_name "
+ "from information_schema.TABLES "
+ "where TABLE_SCHEMA='%(database)s' "
+ "and ENGINE!='InnoDB' "
+ "and TABLE_NAME!='migrate_version'" %
+ locals())
+ names = [x[0] for x in noninnodb]
+ self.assertEqual(names, [],
+ "Non-InnoDB tables exist")
+
+ connection.close()