Live SQL migration tests

Make it possible to run the migration tests for the supported databases
without editing the config files.

Blueprint live-sql-gate

Change-Id: Iaf14ad42333b0a0cd1f7d0fb37f135a8bf7af14a
This commit is contained in:
Adam Young 2013-05-24 16:45:39 -04:00
parent d67e31b70c
commit 62abd5d853
4 changed files with 55 additions and 3 deletions

37
tests/_sql_livetest.py Normal file
View File

@ -0,0 +1,37 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Red Hat, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import test_sql_upgrade
from keystone import config
CONF = config.CONF
class PostgresqlMigrateTests(test_sql_upgrade.SqlUpgradeTests):
def config_files(self):
files = (test_sql_upgrade.SqlUpgradeTests.
_config_file_list[:])
files.append("backend_postgresql.conf")
return files
class MysqlMigrateTests(test_sql_upgrade.SqlUpgradeTests):
def config_files(self):
files = (test_sql_upgrade.SqlUpgradeTests.
_config_file_list[:])
files.append("backend_mysql.conf")
return files

4
tests/backend_mysql.conf Normal file
View File

@ -0,0 +1,4 @@
#Used for running the Migrate tests against a live Mysql Server
#See _sql_livetest.py
[sql]
connection = mysql://keystone:keystone@localhost/keystone_test?charset=utf8

View File

@ -0,0 +1,4 @@
#Used for running the Migrate tests against a live Postgresql Server
#See _sql_livetest.py
[sql]
connection = postgresql://keystone:keystone@localhost/keystone_test?client_encoding=utf8

View File

@ -50,11 +50,18 @@ class SqlUpgradeTests(test.TestCase):
self.metadata = sqlalchemy.MetaData()
self.metadata.bind = self.engine
_config_file_list = [test.etcdir('keystone.conf.sample'),
test.testsdir('test_overrides.conf'),
test.testsdir('backend_sql.conf')]
#override this to sepcify the complete list of configuration files
def config_files(self):
return self._config_file_list
def setUp(self):
super(SqlUpgradeTests, self).setUp()
self.config([test.etcdir('keystone.conf.sample'),
test.testsdir('test_overrides.conf'),
test.testsdir('backend_sql.conf')])
self.config(self.config_files())
self.base = sql.Base()
# create and share a single sqlalchemy engine for testing