summaryrefslogtreecommitdiffstats
path: root/tests/test_sql_upgrade.py
diff options
context:
space:
mode:
authorAdam Young <ayoung@redhat.com>2013-02-08 20:32:35 -0500
committerAdam Young <ayoung@redhat.com>2013-02-11 12:23:45 -0500
commit329b00d6dbd624f5554a9c5578b9f6a8070f3312 (patch)
tree417991f8967a9f35baa175194e44d9ce7f1c19df /tests/test_sql_upgrade.py
parent1f258c4d18d876658a67b66efc42c61f9ba4df05 (diff)
downloadkeystone-329b00d6dbd624f5554a9c5578b9f6a8070f3312.tar.gz
keystone-329b00d6dbd624f5554a9c5578b9f6a8070f3312.tar.xz
keystone-329b00d6dbd624f5554a9c5578b9f6a8070f3312.zip
Fix normalize identity sql ugrade for Mysql and postgresql
Change-Id: Idf374a748f8ed2add5310b504806ffabfa64bed9
Diffstat (limited to 'tests/test_sql_upgrade.py')
-rw-r--r--tests/test_sql_upgrade.py37
1 files changed, 22 insertions, 15 deletions
diff --git a/tests/test_sql_upgrade.py b/tests/test_sql_upgrade.py
index e04fc3e5..f0b5fa5d 100644
--- a/tests/test_sql_upgrade.py
+++ b/tests/test_sql_upgrade.py
@@ -44,6 +44,11 @@ CONF = config.CONF
class SqlUpgradeTests(test.TestCase):
+
+ def initialize_sql(self):
+ self.metadata = sqlalchemy.MetaData()
+ self.metadata.bind = self.engine
+
def setUp(self):
super(SqlUpgradeTests, self).setUp()
self.config([test.etcdir('keystone.conf.sample'),
@@ -51,18 +56,16 @@ class SqlUpgradeTests(test.TestCase):
test.testsdir('backend_sql.conf')])
# create and share a single sqlalchemy engine for testing
- base = sql.Base()
- self.engine = base.get_engine(allow_global_engine=False)
- self.Session = base.get_sessionmaker(
- engine=self.engine,
- autocommit=False)
- self.metadata = sqlalchemy.MetaData()
+ self.base = sql.Base()
+ self.engine = self.base.get_engine(allow_global_engine=False)
+ self.Session = self.base.get_sessionmaker(engine=self.engine,
+ autocommit=False)
- # populate the engine with tables & fixtures
- self.metadata.bind = self.engine
+ self.initialize_sql()
self.repo_path = migration._find_migrate_repo()
- self.schema = versioning_api.ControlledSchema.create(self.engine,
- self.repo_path, 0)
+ self.schema = versioning_api.ControlledSchema.create(
+ self.engine,
+ self.repo_path, 0)
# auto-detect the highest available schema version in the migrate_repo
self.max_version = self.schema.repository.version().version
@@ -82,7 +85,7 @@ class SqlUpgradeTests(test.TestCase):
self.assertEqual(version, 0, "DB is at version 0")
def test_two_steps_forward_one_step_back(self):
- """You should be able to cleanly undo a re-apply all upgrades.
+ """You should be able to cleanly undo and re-apply all upgrades.
Upgrades are run in the following order::
@@ -97,6 +100,7 @@ class SqlUpgradeTests(test.TestCase):
def assertTableColumns(self, table_name, expected_cols):
"""Asserts that the table contains the expected set of columns."""
+ self.initialize_sql()
table = self.select_table(table_name)
actual_cols = [col.name for col in table.columns]
self.assertEqual(expected_cols, actual_cols, '%s table' % table_name)
@@ -352,14 +356,17 @@ class SqlUpgradeTests(test.TestCase):
['user_id', 'domain_id', 'data'])
def populate_user_table(self):
+ user_table = sqlalchemy.Table('user',
+ self.metadata,
+ autoload=True)
+ session = self.Session()
+ insert = user_table.insert()
for user in default_fixtures.USERS:
extra = copy.deepcopy(user)
extra.pop('id')
extra.pop('name')
- self.engine.execute("insert into user values ('%s', '%s', '%s')"
- % (user['id'],
- user['name'],
- json.dumps(extra)))
+ user['extra'] = json.dumps(extra)
+ insert.execute(user)
def populate_tenant_table(self):
for tenant in default_fixtures.TENANTS: