Merge "Implement ModelMigrationSyncTest"
This commit is contained in:
commit
33814c49b0
15
neutron_vpnaas/db/migration/alembic_migrations/__init__.py
Normal file
15
neutron_vpnaas/db/migration/alembic_migrations/__init__.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Copyright 2015 Mirantis 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.
|
||||||
|
|
||||||
|
VPNAAS_VERSION_TABLE = 'alembic_version_vpnaas'
|
@ -12,18 +12,19 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from logging import config as logging_config
|
|
||||||
|
|
||||||
from alembic import context
|
from alembic import context
|
||||||
from neutron.db import model_base
|
from logging import config as logging_config
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_db.sqlalchemy import session
|
from oslo_db.sqlalchemy import session
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy import event
|
from sqlalchemy import event
|
||||||
|
|
||||||
|
from neutron.db import model_base
|
||||||
|
|
||||||
|
from neutron_vpnaas.db.migration import alembic_migrations
|
||||||
|
|
||||||
|
|
||||||
MYSQL_ENGINE = None
|
MYSQL_ENGINE = None
|
||||||
VPNAAS_VERSION_TABLE = 'alembic_version_vpnaas'
|
|
||||||
config = context.config
|
config = context.config
|
||||||
neutron_config = config.neutron_config
|
neutron_config = config.neutron_config
|
||||||
logging_config.fileConfig(config.config_file_name)
|
logging_config.fileConfig(config.config_file_name)
|
||||||
@ -49,7 +50,7 @@ def run_migrations_offline():
|
|||||||
kwargs['url'] = neutron_config.database.connection
|
kwargs['url'] = neutron_config.database.connection
|
||||||
else:
|
else:
|
||||||
kwargs['dialect_name'] = neutron_config.database.engine
|
kwargs['dialect_name'] = neutron_config.database.engine
|
||||||
kwargs['version_table'] = VPNAAS_VERSION_TABLE
|
kwargs['version_table'] = alembic_migrations.VPNAAS_VERSION_TABLE
|
||||||
context.configure(**kwargs)
|
context.configure(**kwargs)
|
||||||
|
|
||||||
with context.begin_transaction():
|
with context.begin_transaction():
|
||||||
@ -70,7 +71,7 @@ def run_migrations_online():
|
|||||||
context.configure(
|
context.configure(
|
||||||
connection=connection,
|
connection=connection,
|
||||||
target_metadata=target_metadata,
|
target_metadata=target_metadata,
|
||||||
version_table=VPNAAS_VERSION_TABLE
|
version_table=alembic_migrations.VPNAAS_VERSION_TABLE
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
with context.begin_transaction():
|
with context.begin_transaction():
|
||||||
|
0
neutron_vpnaas/db/models/__init__.py
Normal file
0
neutron_vpnaas/db/models/__init__.py
Normal file
31
neutron_vpnaas/db/models/head.py
Normal file
31
neutron_vpnaas/db/models/head.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Copyright (c) 2014 OpenStack Foundation.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
"""
|
||||||
|
The module provides all database models at current HEAD.
|
||||||
|
|
||||||
|
Its purpose is to create comparable metadata with current database schema.
|
||||||
|
Based on this comparison database can be healed with healing migration.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from neutron.db.migration.models import head
|
||||||
|
|
||||||
|
from neutron_vpnaas.db.vpn import vpn_db # noqa
|
||||||
|
from neutron_vpnaas.services.vpn.service_drivers import cisco_csr_db # noqa
|
||||||
|
|
||||||
|
|
||||||
|
def get_metadata():
|
||||||
|
return head.model_base.BASEV2.metadata
|
@ -0,0 +1,59 @@
|
|||||||
|
# Copyright 2015 Mirantis 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.
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
from neutron.db.migration.alembic_migrations import external
|
||||||
|
from neutron.db.migration import cli as migration
|
||||||
|
from neutron.tests.common import base
|
||||||
|
from neutron.tests.functional.db import test_migrations
|
||||||
|
|
||||||
|
from neutron_vpnaas.db.migration import alembic_migrations
|
||||||
|
from neutron_vpnaas.db.models import head
|
||||||
|
|
||||||
|
EXTERNAL_TABLES = set(external.TABLES) - set(external.VPNAAS_TABLES)
|
||||||
|
|
||||||
|
|
||||||
|
class _TestModelsMigrationsVPNAAS(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 == alembic_migrations.VPNAAS_VERSION_TABLE or
|
||||||
|
name in EXTERNAL_TABLES):
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
def get_engine(self):
|
||||||
|
return self.engine
|
||||||
|
|
||||||
|
|
||||||
|
class TestModelsMigrationsMysql(_TestModelsMigrationsVPNAAS,
|
||||||
|
base.MySQLTestCase):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestModelsMigrationsPsql(_TestModelsMigrationsVPNAAS,
|
||||||
|
base.PostgreSQLTestCase):
|
||||||
|
pass
|
10
neutron_vpnaas/tests/functional/requirements.txt
Normal file
10
neutron_vpnaas/tests/functional/requirements.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Additional requirements for functional tests
|
||||||
|
|
||||||
|
# The order of packages is significant, because pip processes them in the order
|
||||||
|
# of appearance. Changing the order has an impact on the overall integration
|
||||||
|
# process, which may cause wedges in the gate later.
|
||||||
|
|
||||||
|
psutil>=1.1.1,<2.0.0
|
||||||
|
psycopg2
|
||||||
|
PyMySQL>=0.6.2 # MIT License
|
||||||
|
|
12
tox.ini
12
tox.ini
@ -15,10 +15,10 @@ commands =
|
|||||||
# there is also secret magic in pretty_tox.sh which lets you run in a fail only
|
# there is also secret magic in pretty_tox.sh which lets you run in a fail only
|
||||||
# mode. To do this define the TRACE_FAILONLY environmental variable.
|
# mode. To do this define the TRACE_FAILONLY environmental variable.
|
||||||
|
|
||||||
# [testenv:functional]
|
[testenv:functional]
|
||||||
# setenv = OS_TEST_PATH=./neutron-vpnaas/tests/functional
|
deps =
|
||||||
# commands =
|
{[testenv]deps}
|
||||||
# python setup.py testr --slowest --testr-args='{posargs}'
|
-r{toxinidir}/neutron_vpnaas/tests/functional/requirements.txt
|
||||||
|
|
||||||
[testenv:dsvm-functional]
|
[testenv:dsvm-functional]
|
||||||
setenv = OS_TEST_PATH=./neutron_vpnaas/tests/functional/openswan
|
setenv = OS_TEST_PATH=./neutron_vpnaas/tests/functional/openswan
|
||||||
@ -26,6 +26,8 @@ setenv = OS_TEST_PATH=./neutron_vpnaas/tests/functional/openswan
|
|||||||
OS_ROOTWRAP_CMD=sudo {envdir}/bin/neutron-rootwrap {envdir}/etc/neutron/rootwrap.conf
|
OS_ROOTWRAP_CMD=sudo {envdir}/bin/neutron-rootwrap {envdir}/etc/neutron/rootwrap.conf
|
||||||
OS_ROOTWRAP_DAEMON_CMD=sudo {envdir}/bin/neutron-rootwrap-daemon {envdir}/etc/neutron/rootwrap.conf
|
OS_ROOTWRAP_DAEMON_CMD=sudo {envdir}/bin/neutron-rootwrap-daemon {envdir}/etc/neutron/rootwrap.conf
|
||||||
OS_FAIL_ON_MISSING_DEPS=1
|
OS_FAIL_ON_MISSING_DEPS=1
|
||||||
|
deps =
|
||||||
|
{[testenv:functional]deps}
|
||||||
sitepackages=True
|
sitepackages=True
|
||||||
whitelist_externals =
|
whitelist_externals =
|
||||||
sh
|
sh
|
||||||
@ -41,6 +43,8 @@ setenv = OS_TEST_PATH=./neutron_vpnaas/tests/functional/strongswan
|
|||||||
OS_ROOTWRAP_CMD=sudo {envdir}/bin/neutron-rootwrap {envdir}/etc/neutron/rootwrap.conf
|
OS_ROOTWRAP_CMD=sudo {envdir}/bin/neutron-rootwrap {envdir}/etc/neutron/rootwrap.conf
|
||||||
OS_ROOTWRAP_DAEMON_CMD=sudo {envdir}/bin/neutron-rootwrap-daemon {envdir}/etc/neutron/rootwrap.conf
|
OS_ROOTWRAP_DAEMON_CMD=sudo {envdir}/bin/neutron-rootwrap-daemon {envdir}/etc/neutron/rootwrap.conf
|
||||||
OS_FAIL_ON_MISSING_DEPS=1
|
OS_FAIL_ON_MISSING_DEPS=1
|
||||||
|
deps =
|
||||||
|
{[testenv:functional]deps}
|
||||||
sitepackages=True
|
sitepackages=True
|
||||||
whitelist_externals =
|
whitelist_externals =
|
||||||
sh
|
sh
|
||||||
|
Loading…
Reference in New Issue
Block a user