diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-04-10 16:38:07 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-04-10 16:38:07 +0000 |
commit | 87d4e4c7803fec8ef1db0619159557c44597f635 (patch) | |
tree | de3b03cb00c91cfc4c0876ba0f92b33996e12b26 | |
parent | ebb3f0e2b5abd473d14404d43b0f0c32c2a4d5e2 (diff) | |
parent | 9e004bdbc96bfc54ba9350f07925354095d51465 (diff) | |
download | oslo-db-87d4e4c7803fec8ef1db0619159557c44597f635.tar.gz |
Merge "Sanity check after migration"
-rw-r--r-- | oslo_db/sqlalchemy/migration.py | 10 | ||||
-rw-r--r-- | oslo_db/tests/old_import_api/sqlalchemy/test_migration_common.py | 3 | ||||
-rw-r--r-- | oslo_db/tests/sqlalchemy/test_migration_common.py | 3 |
3 files changed, 11 insertions, 5 deletions
diff --git a/oslo_db/sqlalchemy/migration.py b/oslo_db/sqlalchemy/migration.py index 308ce60..d07ffc8 100644 --- a/oslo_db/sqlalchemy/migration.py +++ b/oslo_db/sqlalchemy/migration.py @@ -76,10 +76,14 @@ def db_sync(engine, abs_path, version=None, init_version=0, sanity_check=True): if sanity_check: _db_schema_sanity_check(engine) if version is None or version > current_version: - return versioning_api.upgrade(engine, repository, version) + migration = versioning_api.upgrade(engine, repository, version) else: - return versioning_api.downgrade(engine, repository, - version) + migration = versioning_api.downgrade(engine, repository, + version) + if sanity_check: + _db_schema_sanity_check(engine) + + return migration def _db_schema_sanity_check(engine): diff --git a/oslo_db/tests/old_import_api/sqlalchemy/test_migration_common.py b/oslo_db/tests/old_import_api/sqlalchemy/test_migration_common.py index 98ae46e..c81c93a 100644 --- a/oslo_db/tests/old_import_api/sqlalchemy/test_migration_common.py +++ b/oslo_db/tests/old_import_api/sqlalchemy/test_migration_common.py @@ -158,7 +158,8 @@ class TestMigrationCommon(test_base.DbTestCase): mock_find_repo.return_value = self.return_value migration.db_sync(self.engine, self.path, self.test_version) - mock_sanity.assert_called_once_with(self.engine) + self.assertEqual([mock.call(self.engine), mock.call(self.engine)], + mock_sanity.call_args_list) def test_db_sync_sanity_skipped(self): with test_utils.nested( diff --git a/oslo_db/tests/sqlalchemy/test_migration_common.py b/oslo_db/tests/sqlalchemy/test_migration_common.py index 95efab1..ebdaaa9 100644 --- a/oslo_db/tests/sqlalchemy/test_migration_common.py +++ b/oslo_db/tests/sqlalchemy/test_migration_common.py @@ -174,7 +174,8 @@ class TestMigrationCommon(test_base.DbTestCase): mock_find_repo.return_value = self.return_value migration.db_sync(self.engine, self.path, self.test_version) - mock_sanity.assert_called_once_with(self.engine) + self.assertEqual([mock.call(self.engine), mock.call(self.engine)], + mock_sanity.call_args_list) def test_db_sync_sanity_skipped(self): with test_utils.nested( |