Revert "Unit test for checking cross-version migrations compatibility"

This reverts commit 8234b92e57.

Due to discussions at the midcycle and based upon the complexity of
cross-version schema support, it has been determined that this
simple test is unfortunately both insufficient and the incorrect
approach to ensure schema compatibility. We have discussed and
come to a decision on how we are going both prove out the
plan for cross-version support and the appropriate path for
upgrade. The base feature of what this test encompasses will
instead be migrated over to a full separate gate/check job
that will be able to handle the more complex tasks of
ensuring schema upgrades make sense. For now this
test is inaccurate and missing changes such as FK retargeting
and blocking the ability to perform work that is needed
for the Mitaka cycle. The plan made at the midcycle
will continue through Mitaka with the plan to enact
enforcement in Newton.

Change-Id: I9ae0caed991b18600b70d408f32d837c92d059c2
This commit is contained in:
Morgan Fainberg 2016-01-29 08:09:26 -06:00
parent afef20658a
commit c5a1b47bf9
2 changed files with 0 additions and 165 deletions

View File

@ -1,162 +0,0 @@
# Copyright 2016 Intel Corporation
#
# 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 os
import fixtures
from migrate.versioning import repository
from oslo_db.sqlalchemy import test_base
from oslo_db.sqlalchemy import test_migrations
import sqlalchemy
import testtools
from keystone.common.sql import migrate_repo
class DBOperationNotAllowed(Exception):
pass
class BannedDBSchemaOperations(fixtures.Fixture):
"""Ban some operations for migrations."""
def __init__(self, banned_resources=None):
super(BannedDBSchemaOperations, self).__init__()
self._banned_resources = banned_resources or []
@staticmethod
def _explode(resource, op):
raise DBOperationNotAllowed(
'Operation %s.%s() is not allowed in a database migration' % (
resource, op))
def setUp(self):
super(BannedDBSchemaOperations, self).setUp()
for resource in self._banned_resources:
self.useFixture(fixtures.MonkeyPatch(
'sqlalchemy.%s.drop' % resource,
lambda *a, **k: self._explode(resource, 'drop')))
self.useFixture(fixtures.MonkeyPatch(
'sqlalchemy.%s.alter' % resource,
lambda *a, **k: self._explode(resource, 'alter')))
class TestBannedDBSchemaOperations(testtools.TestCase):
"""Test the BannedDBSchemaOperations fixture."""
def test_column(self):
"""Test column drops and alters raise DBOperationNotAllowed."""
column = sqlalchemy.Column()
with BannedDBSchemaOperations(banned_resources=['Column']):
self.assertRaises(DBOperationNotAllowed, column.drop)
self.assertRaises(DBOperationNotAllowed, column.alter)
def test_table(self):
"""Test table drops and alters raise DBOperationNotAllowed."""
table = sqlalchemy.Table()
with BannedDBSchemaOperations(banned_resources=['Table']):
self.assertRaises(DBOperationNotAllowed, table.drop)
self.assertRaises(DBOperationNotAllowed, table.alter)
class KeystoneMigrationsCheckers(test_migrations.WalkVersionsMixin):
"""Walk over and test all sqlalchemy-migrate migrations."""
@property
def INIT_VERSION(self):
return migrate_repo.DB_INIT_VERSION
@property
def REPOSITORY(self):
migrate_file = migrate_repo.__file__
return repository.Repository(
os.path.abspath(os.path.dirname(migrate_file))
)
@property
def migration_api(self):
temp = __import__('oslo_db.sqlalchemy.migration', globals(),
locals(), ['versioning_api'], 0)
return temp.versioning_api
@property
def migrate_engine(self):
return self.engine
def migrate_up(self, version, with_data=False):
"""Check that migrations don't cause downtime.
Schema migrations can be done online, allowing for rolling upgrades.
"""
# NOTE(xek):
# This is a list of migrations where we allow dropping and altering
# things. The rules for adding exceptions are very specific:
#
# 1) Migrations which don't cause incompatibilities are allowed,
# for example dropping an index or constraint.
#
# 2) Migrations removing structures not used in the previous version
# are allowed (we keep compatibility between releases), ex.:
#
# a) feature is deprecated according to the deprecation policies
# (release 1),
#
# b) code supporting the feature is removed the following release
# (release 2),
#
# c) table can be dropped a release after the code has been removed
# (i.e. in release 3).
#
# 3) Any other changes which don't pass this test are disallowed.
#
# Please follow the guidelines outlined at:
# http://docs.openstack.org/developer/keystone/developing.html#online-migration
exceptions = [
# NOTE(xek): Reviewers: DO NOT ALLOW THINGS TO BE ADDED HERE
]
# NOTE(xek): We start requiring things be additive in Mitaka, so
# ignore all migrations before that point.
MITAKA_START = 81
if version >= MITAKA_START and version not in exceptions:
banned = ['Table', 'Column']
else:
banned = None
with BannedDBSchemaOperations(banned):
super(KeystoneMigrationsCheckers,
self).migrate_up(version, with_data)
snake_walk = False
downgrade = False
def test_walk_versions(self):
self.walk_versions(self.snake_walk, self.downgrade)
class TestKeystoneMigrationsMySQL(
KeystoneMigrationsCheckers, test_base.MySQLOpportunisticTestCase):
pass
class TestKeystoneMigrationsPostgreSQL(
KeystoneMigrationsCheckers, test_base.PostgreSQLOpportunisticTestCase):
pass
class TestKeystoneMigrationsSQLite(
KeystoneMigrationsCheckers, test_base.DbTestCase):
pass

View File

@ -37,6 +37,3 @@ tempest-lib>=0.13.0 # Apache-2.0
# Functional tests.
requests!=2.9.0,>=2.8.1 # Apache-2.0
# For fixtures from oslo.db
testresources>=0.2.4 # Apache-2.0/BSD