def create_db_tables(self): """Populate the new database. MySQLTestCase creates a new database for each test, but these need to be populated with the appropriate tables. Before we can do that, we must change the 'connection' option which the Neutron code knows to look at. Currently, the username and password options are hard-coded by oslo.db and neutron/tests/functional/contrib/gate_hook.sh. Also, we only support MySQL for now, but the groundwork for adding Postgres is already laid. """ conn = ("mysql+pymysql://%(username)s:%(password)s" "@127.0.0.1/%(db_name)s" % { 'username': test_base.DbFixture.USERNAME, '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') migration.do_alembic_command(alembic_config, 'upgrade', 'heads')
def _get_alembic_config(self, uri): db_config = migration.get_neutron_config() self.script_dir = alembic_script.ScriptDirectory.from_config(db_config) db_config.neutron_config = cfg.CONF db_config.neutron_config.set_override('connection', six.text_type(uri), group='database') return db_config
def setUp(self): super(_TestModelsMigrations, self).setUp() self.cfg = self.useFixture(config_fixture.Config()) self.cfg.config(core_plugin='ml2') self.alembic_config = migration.get_neutron_config() self.alembic_config.neutron_config = cfg.CONF # Migration tests can take a long time self.useFixture(test_base.Timeout(scaling=self.TIMEOUT_SCALING_FACTOR))
def setUp(self): patch = mock.patch.dict('sys.modules', { 'heleosapi': mock.MagicMock(), }) patch.start() self.addCleanup(patch.stop) super(_TestModelsMigrations, self).setUp() self.cfg = self.useFixture(config_fixture.Config()) self.cfg.config(core_plugin=CORE_PLUGIN) self.alembic_config = migration.get_neutron_config() self.alembic_config.neutron_config = cfg.CONF
def setUp(self): super(KaloomL3ServicePluginTestCase, self).setUp() self.mysqld = testing.mysqld.Mysqld(my_cnf={'skip-networking': None}) URL = create_engine(self.mysqld.url()).url oslo_cfg.CONF.set_override('connection', URL, group='database') #"neutron-db-manage upgrade head" equivalent alembic_cfg = migration_cli.get_neutron_config() alembic_cfg.neutron_config = oslo_cfg.CONF test_helper.upgrade(alembic_cfg) #"neutron-kaloom-db-manage upgrade head" equivalent script_location = 'networking_kaloom.ml2.drivers.kaloom.db.migration:alembic_migrations' alembic_cfg_kaloom = alembic_config.Config() alembic_cfg_kaloom.set_main_option("script_location", script_location) alembic_cfg_kaloom.neutron_config = oslo_cfg.CONF test_helper.upgrade(alembic_cfg_kaloom) with patch.object(neutron_context.db_api, '_CTX_MANAGER', test_helper.get_context_manager(URL)): self.ctx = neutron_context.get_admin_context() self.ctx.session #print self.ctx.session.connection().engine self.setup_coreplugin(load_plugins=False) oslo_cfg.CONF.set_override("core_plugin", test_db_base_plugin_v2.DB_PLUGIN_KLASS) oslo_cfg.CONF.set_override("service_plugins", ['segments']) manager.init() self.l2_plugin = directory.get_plugin() self.segments_plugin = importutils.import_object( 'neutron.services.segments.plugin.Plugin') #patch plugin.db_api._CTX_MANAGER = test_helper.get_context_manager(URL) plugin.kaloom_db.db_api.context_manager = test_helper.get_context_manager( URL) db_api.context_manager = test_helper.get_context_manager(URL) #fix l3_port_check issue def delete_port(context, id, l3_port_check=True): return original_delete_port(context, id) original_delete_port = self.l2_plugin.delete_port self.l2_plugin.delete_port = Mock(side_effect=delete_port)
def test_validate_revisions(self, *mocks): cli.validate_revisions(cli.get_neutron_config())
def setUp(self): super(TestSanityCheck, self).setUp() self.alembic_config = migration.get_neutron_config() self.alembic_config.neutron_config = cfg.CONF
def setUp(self): super(TestWalkDowngrade, self).setUp() self.alembic_config = migration.get_neutron_config() self.alembic_config.neutron_config = cfg.CONF
def test_validate_labels(self, *mocks): cli.validate_labels(cli.get_neutron_config())
def setUp(self): super(_TestModelsMigrations, self).setUp() self.cfg = self.useFixture(config_fixture.Config()) self.cfg.config(core_plugin='ml2') self.alembic_config = migration.get_neutron_config() self.alembic_config.neutron_config = cfg.CONF
def setUp(self): super(_TestModelsMigrations, self).setUp() self.cfg = self.useFixture(config_fixture.Config()) self.cfg.config(core_plugin=CORE_PLUGIN) self.alembic_config = migration.get_neutron_config() self.alembic_config.neutron_config = cfg.CONF
def _generate_schema_w_migrations(cls, engine): alembic_config = migration.get_neutron_config() with engine.connect() as conn: alembic_config.attributes['connection'] = conn migration.do_alembic_command( alembic_config, 'upgrade', 'heads')
def _generate_schema_w_migrations(cls, engine): alembic_config = migration.get_neutron_config() with engine.connect() as conn: alembic_config.attributes['connection'] = conn migration.do_alembic_command(alembic_config, 'upgrade', 'heads')