コード例 #1
0
ファイル: base.py プロジェクト: HoratiusTang/neutron
    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')
コード例 #2
0
ファイル: base.py プロジェクト: dingboopt/neutron-x
    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')
コード例 #3
0
ファイル: test_migrations.py プロジェクト: jaguar13/neutron
 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
コード例 #4
0
 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
コード例 #5
0
ファイル: test_migrations.py プロジェクト: openstack/neutron
    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))
コード例 #6
0
ファイル: test_migrations.py プロジェクト: zhh1989/neutron
    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))
コード例 #7
0
 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
コード例 #8
0
 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
コード例 #9
0
    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)
コード例 #10
0
ファイル: test_migration.py プロジェクト: Blahhhhh/neutron
 def test_validate_revisions(self, *mocks):
     cli.validate_revisions(cli.get_neutron_config())
コード例 #11
0
 def setUp(self):
     super(TestSanityCheck, self).setUp()
     self.alembic_config = migration.get_neutron_config()
     self.alembic_config.neutron_config = cfg.CONF
コード例 #12
0
 def setUp(self):
     super(TestWalkDowngrade, self).setUp()
     self.alembic_config = migration.get_neutron_config()
     self.alembic_config.neutron_config = cfg.CONF
コード例 #13
0
 def test_validate_labels(self, *mocks):
     cli.validate_labels(cli.get_neutron_config())
コード例 #14
0
 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
コード例 #15
0
ファイル: test_migrations.py プロジェクト: jaguar13/neutron
 def setUp(self):
     super(TestSanityCheck, self).setUp()
     self.alembic_config = migration.get_neutron_config()
     self.alembic_config.neutron_config = cfg.CONF
コード例 #16
0
ファイル: test_migrations.py プロジェクト: jaguar13/neutron
 def setUp(self):
     super(TestWalkDowngrade, self).setUp()
     self.alembic_config = migration.get_neutron_config()
     self.alembic_config.neutron_config = cfg.CONF
コード例 #17
0
ファイル: test_migrations.py プロジェクト: jaguar13/neutron
 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
コード例 #18
0
 def test_validate_labels(self, *mocks):
     cli.validate_labels(cli.get_neutron_config())
コード例 #19
0
ファイル: testlib_api.py プロジェクト: gotostack/neutron
 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')
コード例 #20
0
 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')
コード例 #21
0
 def test_validate_revisions(self, *mocks):
     cli.validate_revisions(cli.get_neutron_config())