tests: stop using ml2 plugin full import paths in tests

Stevedore documentation suggest that full import paths are not supposed
to be user visible. Since unit tests emulate users when configuring
oslo.config, we better off relying on well known plugin aliases than
internal details.

For in-tree that may be not a big deal, but with it we set a bad example
for third parties that may later find their tests broken eg. when we
decide to move code around.

TrivialFix

Change-Id: I7bd036ac3df7e7f4c678356d0a793e7d38599dda
This commit is contained in:
Ihar Hrachyshka 2016-07-25 16:52:05 +02:00
parent 122a971656
commit 2a23527a9a
17 changed files with 24 additions and 45 deletions

View File

@ -65,7 +65,7 @@ class NeutronConfigFixture(ConfigFixture):
'lock_path': '$state_path/lock',
'api_paste_config': self._generate_api_paste(),
'policy_file': self._generate_policy_json(),
'core_plugin': 'neutron.plugins.ml2.plugin.Ml2Plugin',
'core_plugin': 'ml2',
'service_plugins': ','.join(service_plugins),
'auth_strategy': 'noauth',
'debug': 'True',

View File

@ -37,8 +37,6 @@ from neutron.tests.unit import testlib_api
cfg.CONF.import_opt('core_plugin', 'neutron.common.config')
CORE_PLUGIN = 'neutron.plugins.ml2.plugin.Ml2Plugin'
CREATION_OPERATIONS = {
'sqla': (sqla_ddl.CreateIndex,
sqla_ddl.CreateTable,
@ -128,7 +126,7 @@ class _TestModelsMigrations(test_migrations.ModelsMigrationsSync):
def setUp(self):
super(_TestModelsMigrations, self).setUp()
self.cfg = self.useFixture(config_fixture.Config())
self.cfg.config(core_plugin=CORE_PLUGIN)
self.cfg.config(core_plugin='ml2')
self.alembic_config = migration.get_neutron_config()
self.alembic_config.neutron_config = cfg.CONF

View File

@ -30,7 +30,7 @@ from neutron.tests.unit import testlib_api
class PecanFunctionalTest(testlib_api.SqlTestCase):
def setUp(self, service_plugins=None, extensions=None):
self.setup_coreplugin('neutron.plugins.ml2.plugin.Ml2Plugin')
self.setup_coreplugin('ml2')
super(PecanFunctionalTest, self).setUp()
self.addCleanup(exts.PluginAwareExtensionManager.clear_instance)
self.addCleanup(set_config, {}, overwrite=True)

View File

@ -280,8 +280,7 @@ class L3LeastRoutersSchedulerTestCase(L3SchedulerBaseTest):
class L3AZSchedulerBaseTest(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
def setUp(self):
core_plugin = 'neutron.plugins.ml2.plugin.Ml2Plugin'
super(L3AZSchedulerBaseTest, self).setUp(plugin=core_plugin)
super(L3AZSchedulerBaseTest, self).setUp(plugin='ml2')
self.l3_plugin = l3_router_plugin.L3RouterPlugin()
self.l3_plugin.router_scheduler = None

View File

@ -223,7 +223,7 @@ class TestRPCServer(TestNeutronServer):
def setUp(self):
super(TestRPCServer, self).setUp()
self.setup_coreplugin(TARGET_PLUGIN)
self.setup_coreplugin('ml2')
self._plugin_patcher = mock.patch(TARGET_PLUGIN, autospec=True)
self.plugin = self._plugin_patcher.start()
self.plugin.return_value.rpc_workers_supported = True
@ -257,7 +257,7 @@ class TestPluginWorker(TestNeutronServer):
def setUp(self):
super(TestPluginWorker, self).setUp()
self.setup_coreplugin(TARGET_PLUGIN)
self.setup_coreplugin('ml2')
self._plugin_patcher = mock.patch(TARGET_PLUGIN, autospec=True)
self.plugin = self._plugin_patcher.start()

View File

@ -225,7 +225,6 @@ class OvsAgentSchedulerTestCaseBase(test_l3.L3NatTestCaseMixin,
AgentSchedulerTestMixIn,
test_plugin.NeutronDbPluginV2TestCase):
fmt = 'json'
plugin_str = 'neutron.plugins.ml2.plugin.Ml2Plugin'
l3_plugin = ('neutron.tests.unit.extensions.test_l3.'
'TestL3NatAgentSchedulingServicePlugin')
@ -241,7 +240,7 @@ class OvsAgentSchedulerTestCaseBase(test_l3.L3NatTestCaseMixin,
mock.patch('neutron.common.rpc.get_client'
).start().return_value = self.client_mock
super(OvsAgentSchedulerTestCaseBase, self).setUp(
self.plugin_str, service_plugins=service_plugins)
'ml2', service_plugins=service_plugins)
mock.patch.object(
self.plugin, 'filter_hosts_with_network_access',
side_effect=lambda context, network_id, hosts: hosts).start()
@ -1292,11 +1291,9 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
class OvsDhcpAgentNotifierTestCase(test_agent.AgentDBTestMixIn,
AgentSchedulerTestMixIn,
test_plugin.NeutronDbPluginV2TestCase):
plugin_str = 'neutron.plugins.ml2.plugin.Ml2Plugin'
def setUp(self):
self.useFixture(tools.AttributeMapMemento())
super(OvsDhcpAgentNotifierTestCase, self).setUp(self.plugin_str)
super(OvsDhcpAgentNotifierTestCase, self).setUp('ml2')
mock.patch.object(
self.plugin, 'filter_hosts_with_network_access',
side_effect=lambda context, network_id, hosts: hosts).start()
@ -1437,7 +1434,6 @@ class OvsL3AgentNotifierTestCase(test_l3.L3NatTestCaseMixin,
test_agent.AgentDBTestMixIn,
AgentSchedulerTestMixIn,
test_plugin.NeutronDbPluginV2TestCase):
plugin_str = 'neutron.plugins.ml2.plugin.Ml2Plugin'
l3_plugin = ('neutron.tests.unit.extensions.test_l3.'
'TestL3NatAgentSchedulingServicePlugin')
@ -1456,7 +1452,7 @@ class OvsL3AgentNotifierTestCase(test_l3.L3NatTestCaseMixin,
else:
service_plugins = None
super(OvsL3AgentNotifierTestCase, self).setUp(
self.plugin_str, service_plugins=service_plugins)
'ml2', service_plugins=service_plugins)
ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
self.adminContext = context.get_admin_context()

View File

@ -222,5 +222,4 @@ class TestPortUpdateIpam(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
class TestPortUpdateIpamML2(TestPortUpdateIpam):
def setUp(self):
super(TestPortUpdateIpamML2, self).setUp(
plugin='neutron.plugins.ml2.plugin.Ml2Plugin')
super(TestPortUpdateIpamML2, self).setUp(plugin='ml2')

View File

@ -42,8 +42,7 @@ class FakeL3Plugin(common_db_mixin.CommonDbMixin,
class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
def setUp(self):
core_plugin = 'neutron.plugins.ml2.plugin.Ml2Plugin'
super(L3DvrTestCase, self).setUp(plugin=core_plugin)
super(L3DvrTestCase, self).setUp(plugin='ml2')
self.core_plugin = manager.NeutronManager.get_plugin()
self.ctx = context.get_admin_context()
self.mixin = FakeL3Plugin()

View File

@ -54,7 +54,7 @@ class L3HATestFramework(testlib_api.SqlTestCase):
super(L3HATestFramework, self).setUp()
self.admin_ctx = context.get_admin_context()
self.setup_coreplugin('neutron.plugins.ml2.plugin.Ml2Plugin')
self.setup_coreplugin('ml2')
self.core_plugin = manager.NeutronManager.get_plugin()
notif_p = mock.patch.object(l3_hamode_db.L3_HA_NAT_db_mixin,
'_notify_ha_interfaces_updated')

View File

@ -94,9 +94,8 @@ class TestAZAgentCase(AZTestCommon):
class TestAZNetworkCase(AZTestCommon):
def setUp(self):
plugin = 'neutron.plugins.ml2.plugin.Ml2Plugin'
ext_mgr = AZExtensionManager()
super(TestAZNetworkCase, self).setUp(plugin=plugin, ext_mgr=ext_mgr)
super(TestAZNetworkCase, self).setUp(plugin='ml2', ext_mgr=ext_mgr)
def test_availability_zones_in_create_response(self):
with self.network() as net:

View File

@ -54,7 +54,7 @@ class QuotaExtensionTestCase(testlib_api.WebTestCase):
self.config_parse()
# Update the plugin and extensions path
self.setup_coreplugin(TARGET_PLUGIN)
self.setup_coreplugin('ml2')
quota.QUOTAS = quota.QuotaEngine()
self._plugin_patcher = mock.patch(TARGET_PLUGIN, autospec=True)
self.plugin = self._plugin_patcher.start()

View File

@ -199,8 +199,7 @@ class TestSegment(SegmentTestCase):
class TestSegmentML2(SegmentTestCase):
def setUp(self):
super(TestSegmentML2, self).setUp(
plugin='neutron.plugins.ml2.plugin.Ml2Plugin')
super(TestSegmentML2, self).setUp(plugin='ml2')
def test_segment_notification_on_create_network(self):
with mock.patch.object(registry, 'notify') as notify:
@ -305,7 +304,7 @@ class HostSegmentMappingTestCase(SegmentTestCase):
self._mechanism_drivers,
group='ml2')
if not plugin:
plugin = 'neutron.plugins.ml2.plugin.Ml2Plugin'
plugin = 'ml2'
super(HostSegmentMappingTestCase, self).setUp(plugin=plugin)
db.subscribe()
@ -1039,8 +1038,7 @@ class TestSegmentAwareIpam(SegmentTestCase):
class TestSegmentAwareIpamML2(TestSegmentAwareIpam):
def setUp(self):
super(TestSegmentAwareIpamML2, self).setUp(
plugin='neutron.plugins.ml2.plugin.Ml2Plugin')
super(TestSegmentAwareIpamML2, self).setUp(plugin='ml2')
class TestDhcpAgentSegmentScheduling(HostSegmentMappingTestCase):

View File

@ -76,7 +76,7 @@ config.cfg.CONF.import_opt('network_vlan_ranges',
group='ml2_type_vlan')
PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin'
PLUGIN_NAME = 'ml2'
DEVICE_OWNER_COMPUTE = constants.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
HOST = 'fake_host'

View File

@ -25,13 +25,8 @@ from neutron.plugins.ml2 import models as ml2_models
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin'
class PortBindingTestCase(test_plugin.NeutronDbPluginV2TestCase):
_plugin_name = PLUGIN_NAME
def setUp(self):
# Enable the test mechanism driver to ensure that
# we can successfully call through to all mechanism
@ -42,7 +37,7 @@ class PortBindingTestCase(test_plugin.NeutronDbPluginV2TestCase):
config.cfg.CONF.set_override('network_vlan_ranges',
['physnet1:1000:1099'],
group='ml2_type_vlan')
super(PortBindingTestCase, self).setUp(PLUGIN_NAME)
super(PortBindingTestCase, self).setUp('ml2')
self.port_create_status = 'DOWN'
self.plugin = manager.NeutronManager.get_plugin()
self.plugin.start_rpc_listeners()

View File

@ -27,12 +27,10 @@ from neutron.tests.unit.agent import test_securitygroups_rpc as test_sg_rpc
from neutron.tests.unit.api.v2 import test_base
from neutron.tests.unit.extensions import test_securitygroup as test_sg
PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin'
NOTIFIER = 'neutron.plugins.ml2.rpc.AgentNotifierApi'
class Ml2SecurityGroupsTestCase(test_sg.SecurityGroupDBTestCase):
_plugin_name = PLUGIN_NAME
def setUp(self, plugin=None):
test_sg_rpc.set_firewall_driver(test_sg_rpc.FIREWALL_HYBRID_DRIVER)
@ -41,7 +39,7 @@ class Ml2SecurityGroupsTestCase(test_sg.SecurityGroupDBTestCase):
self.notifier = mock.Mock()
notifier_cls.return_value = self.notifier
self.useFixture(tools.AttributeMapMemento())
super(Ml2SecurityGroupsTestCase, self).setUp(PLUGIN_NAME)
super(Ml2SecurityGroupsTestCase, self).setUp('ml2')
def tearDown(self):
super(Ml2SecurityGroupsTestCase, self).tearDown()

View File

@ -618,8 +618,7 @@ class DHCPAgentAZAwareWeightSchedulerTestCase(TestDhcpSchedulerBaseTestCase):
def setUp(self):
super(DHCPAgentAZAwareWeightSchedulerTestCase, self).setUp()
DB_PLUGIN_KLASS = 'neutron.plugins.ml2.plugin.Ml2Plugin'
self.setup_coreplugin(DB_PLUGIN_KLASS)
self.setup_coreplugin('ml2')
cfg.CONF.set_override("network_scheduler_driver",
'neutron.scheduler.dhcp_agent_scheduler.AZAwareWeightScheduler')
self.plugin = importutils.import_object('neutron.plugins.ml2.plugin.'

View File

@ -863,8 +863,7 @@ class L3DvrScheduler(l3_db.L3_NAT_db_mixin,
class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
def setUp(self):
plugin = 'neutron.plugins.ml2.plugin.Ml2Plugin'
self.setup_coreplugin(plugin)
self.setup_coreplugin('ml2')
super(L3DvrSchedulerTestCase, self).setUp()
self.adminContext = n_context.get_admin_context()
self.dut = L3DvrScheduler()
@ -1418,7 +1417,7 @@ class L3HATestCaseMixin(testlib_api.SqlTestCase,
mock.patch('neutron.common.rpc.get_client').start()
self.plugin = L3HAPlugin()
self.setup_coreplugin('neutron.plugins.ml2.plugin.Ml2Plugin')
self.setup_coreplugin('ml2')
cfg.CONF.set_override('service_plugins',
['neutron.services.l3_router.'
'l3_router_plugin.L3RouterPlugin'])
@ -1821,7 +1820,7 @@ class TestGetL3AgentsWithAgentModeFilter(testlib_api.SqlTestCase,
def setUp(self):
super(TestGetL3AgentsWithAgentModeFilter, self).setUp()
self.plugin = L3HAPlugin()
self.setup_coreplugin('neutron.plugins.ml2.plugin.Ml2Plugin')
self.setup_coreplugin('ml2')
self.adminContext = n_context.get_admin_context()
hosts = ['host_1', 'host_2', 'host_3', 'host_4', 'host_5']
agent_modes = ['legacy', 'dvr_snat', 'dvr', 'fake_mode', 'legacy']