Sanity check after migration
Added a sanity_check call after the migration, so if a table in the migration scripts is created not correctly the exception arise before to go in production. Closes-Bug: #1428065 Change-Id: Ib91f2471fa389a6072e8c2aa302504a6c068aa0a
This commit is contained in:
committed by
Roman Podoliaka
parent
9c852c63cd
commit
9e004bdbc9
@@ -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):
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user