From 99fd239ba679d16b73684fbe0dbe31a2e472cba7 Mon Sep 17 00:00:00 2001 From: Jakub Libosvar Date: Thu, 20 Aug 2015 16:02:11 +0000 Subject: [PATCH] fullstack: use migration scripts to create db schema Previously, we used create_all() based on models. We don't use create_all() in production code and there is no guarantee models and scripts are in sync even though we have a good functional test that validates that. There are still pieces that can't be compared by alembic. Change-Id: I72fa67811f0763298416e6e084a8b9b86619795b Closes-Bug: 1486528 --- neutron/tests/fullstack/base.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/neutron/tests/fullstack/base.py b/neutron/tests/fullstack/base.py index 579831524f0..ca2218da957 100644 --- a/neutron/tests/fullstack/base.py +++ b/neutron/tests/fullstack/base.py @@ -15,8 +15,7 @@ from oslo_config import cfg from oslo_db.sqlalchemy import test_base -from neutron.db.migration.models import head # noqa -from neutron.db import model_base +from neutron.db.migration import cli as migration from neutron.tests.common import base from neutron.tests.fullstack.resources import client as client_resource @@ -62,11 +61,13 @@ class BaseFullStackTestCase(base.MySQLTestCase): 'password': test_base.DbFixture.PASSWORD, 'db_name': self.engine.url.database}) + alembic_config = migration.get_neutron_config() + alembic_config.neutron_config = cfg.CONF self.original_conn = cfg.CONF.database.connection self.addCleanup(self._revert_connection_address) cfg.CONF.set_override('connection', conn, group='database') - model_base.BASEV2.metadata.create_all(self.engine) + migration.do_alembic_command(alembic_config, 'upgrade', 'heads') def _revert_connection_address(self): cfg.CONF.set_override('connection',