Add tests ensuring models and migrations are in sync
Co-Authored-By: Nate Johnston <Nate_Johnston@cable.comcast.com> Change-Id: I40bc69d6db5520a34d318ed6ebf26754f104d6bd
This commit is contained in:
parent
b09e41243d
commit
9c79d0bc51
|
@ -0,0 +1,21 @@
|
|||
# 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.
|
||||
|
||||
from neutron.db.migration.models import head
|
||||
|
||||
from neutron_fwaas.db.firewall import firewall_db # noqa
|
||||
from neutron_fwaas.db.firewall import firewall_router_insertion_db # noqa
|
||||
from neutron_fwaas.db.firewall.v2 import firewall_db_v2 # noqa
|
||||
|
||||
|
||||
def get_metadata():
|
||||
return head.model_base.BASEV2.metadata
|
|
@ -4,7 +4,7 @@ set -ex
|
|||
|
||||
# Below variables are set to exceute this script
|
||||
IS_GATE=${IS_GATE:-False}
|
||||
INSTALL_MYSQL_ONLY=${INSTALL_MYSQL_ONLY:-True}
|
||||
INSTALL_MYSQL_ONLY=${INSTALL_MYSQL_ONLY:-False}
|
||||
|
||||
CONTRIB_DIR="$BASE/new/neutron-fwaas/neutron_fwaas/tests/contrib"
|
||||
|
||||
|
@ -81,4 +81,4 @@ if [[ "$IS_GATE" != "True" ]]; then
|
|||
if [[ "$INSTALL_MYSQL_ONLY" == "True" ]]; then
|
||||
_install_databases nopg
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
# 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.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from neutron.db.migration.alembic_migrations import external
|
||||
from neutron.db.migration import cli as migration
|
||||
from neutron.tests.functional.db import test_migrations
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
from neutron_fwaas.db.models import head
|
||||
|
||||
# EXTERNAL_TABLES should contain all names of tables that are not related to
|
||||
# current repo.
|
||||
EXTERNAL_TABLES = set(external.TABLES) - set(external.FWAAS_TABLES)
|
||||
# Model moved to vendor repo
|
||||
EXTERNAL_TABLES.update({'cisco_firewall_associations'})
|
||||
|
||||
VERSION_TABLE = 'alembic_version_fwaas'
|
||||
|
||||
|
||||
class _TestModelsMigrationsFWaaS(test_migrations._TestModelsMigrations):
|
||||
|
||||
def db_sync(self, engine):
|
||||
cfg.CONF.set_override('connection', engine.url, group='database')
|
||||
for conf in migration.get_alembic_configs():
|
||||
self.alembic_config = conf
|
||||
self.alembic_config.neutron_config = cfg.CONF
|
||||
migration.do_alembic_command(conf, 'upgrade', 'heads')
|
||||
|
||||
def get_metadata(self):
|
||||
return head.get_metadata()
|
||||
|
||||
def include_object(self, object_, name, type_, reflected, compare_to):
|
||||
if type_ == 'table' and (name.startswith('alembic') or
|
||||
name == VERSION_TABLE or
|
||||
name in EXTERNAL_TABLES):
|
||||
return False
|
||||
if type_ == 'index' and reflected and name.startswith("idx_autoinc_"):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
class TestModelsMigrationsMysql(testlib_api.MySQLTestCaseMixin,
|
||||
_TestModelsMigrationsFWaaS,
|
||||
testlib_api.SqlTestCaseLight):
|
||||
pass
|
||||
|
||||
|
||||
class TestModelsMigrationsPostgresql(testlib_api.PostgreSQLTestCaseMixin,
|
||||
_TestModelsMigrationsFWaaS,
|
||||
testlib_api.SqlTestCaseLight):
|
||||
pass
|
|
@ -19,3 +19,5 @@ WebOb>=1.2.3 # MIT
|
|||
WebTest>=2.0 # MIT
|
||||
oslotest>=1.10.0 # Apache-2.0
|
||||
reno>=1.8.0 # Apache2
|
||||
PyMySQL>=0.6.2,!=0.7.7 # MIT License
|
||||
psycopg2>=2.5 # LGPL/ZPL
|
||||
|
|
Loading…
Reference in New Issue