from oslo.config import cfg
import testtools
+from neutron import manager
from neutron.tests import post_mortem_debug
class BaseTestCase(testtools.TestCase):
+ def _cleanup_coreplugin(self):
+ manager.NeutronManager._instance = self._saved_instance
+
+ def setup_coreplugin(self, core_plugin=None):
+ self._saved_instance = manager.NeutronManager._instance
+ self.addCleanup(self._cleanup_coreplugin)
+ manager.NeutronManager._instance = None
+ if core_plugin is not None:
+ cfg.CONF.set_override('core_plugin', core_plugin)
+
def setUp(self):
super(BaseTestCase, self).setUp()
self.client_inst.delete_network.return_value = True
self.client_inst.delete_port.return_value = True
self.client_inst.delete_subnet.return_value = True
+ plugin = MetaPluginV2.__module__ + '.' + MetaPluginV2.__name__
+ self.setup_coreplugin(plugin)
self.plugin = MetaPluginV2(configfile=None)
def _fake_network(self, flavor):
plugin = '%s.%s' % (networkgw.__name__,
networkgw.NetworkGatewayPluginBase.__name__)
self._resource = networkgw.RESOURCE_NAME.replace('-', '_')
- # Ensure 'stale' patched copies of the plugin are never returned
- manager.NeutronManager._instance = None
# Ensure existing ExtensionManager is not used
extensions.PluginAwareExtensionManager._instance = None
config.parse(args=args)
# Update the plugin and extensions path
- cfg.CONF.set_override('core_plugin', plugin)
+ self.setup_coreplugin(plugin)
self.addCleanup(cfg.CONF.reset)
_plugin_patcher = mock.patch(plugin, autospec=True)
from neutron.api.v2 import attributes as attr
from neutron.common import config
from neutron.extensions import loadbalancer
-from neutron import manager
from neutron.openstack.common import uuidutils
from neutron.plugins.common import constants
from neutron import quota
def setUp(self):
super(LoadBalancerExtensionTestCase, self).setUp()
plugin = 'neutron.extensions.loadbalancer.LoadBalancerPluginBase'
- # Ensure 'stale' patched copies of the plugin are never returned
- manager.NeutronManager._instance = None
# Ensure existing ExtensionManager is not used
extensions.PluginAwareExtensionManager._instance = None
config.parse(args)
#just stubbing core plugin with LoadBalancer plugin
- cfg.CONF.set_override('core_plugin', plugin)
+ self.setup_coreplugin(plugin)
cfg.CONF.set_override('service_plugins', [plugin])
self._plugin_patcher = mock.patch(plugin, autospec=True)
from neutron.api.v2 import attributes
from neutron.common import config
from neutron.extensions import vpnaas
-from neutron import manager
from neutron.openstack.common import uuidutils
from neutron.plugins.common import constants
from neutron import quota
def setUp(self):
super(VpnaasExtensionTestCase, self).setUp()
plugin = 'neutron.extensions.vpnaas.VPNPluginBase'
- # Ensure 'stale' patched copies of the plugin are never returned
- manager.NeutronManager._instance = None
# Ensure existing ExtensionManager is not used
extensions.PluginAwareExtensionManager._instance = None
config.parse(args)
#just stubbing core plugin with LoadBalancer plugin
- cfg.CONF.set_override('core_plugin', plugin)
+ self.setup_coreplugin(plugin)
cfg.CONF.set_override('service_plugins', [plugin])
self._plugin_patcher = mock.patch(plugin, autospec=True)
super(APIv2TestBase, self).setUp()
plugin = 'neutron.neutron_plugin_base_v2.NeutronPluginBaseV2'
- # Ensure 'stale' patched copies of the plugin are never returned
- NeutronManager._instance = None
# Ensure existing ExtensionManager is not used
PluginAwareExtensionManager._instance = None
# Create the default configurations
args = ['--config-file', etcdir('neutron.conf.test')]
config.parse(args=args)
# Update the plugin
- cfg.CONF.set_override('core_plugin', plugin)
+ self.setup_coreplugin(plugin)
cfg.CONF.set_override('allow_pagination', True)
cfg.CONF.set_override('allow_sorting', True)
self._plugin_patcher = mock.patch(plugin, autospec=True)
super(SubresourceTest, self).setUp()
plugin = 'neutron.tests.unit.test_api_v2.TestSubresourcePlugin'
- NeutronManager._instance = None
PluginAwareExtensionManager._instance = None
# Save the global RESOURCE_ATTRIBUTE_MAP
args = ['--config-file', etcdir('neutron.conf.test')]
config.parse(args=args)
- cfg.CONF.set_override('core_plugin', plugin)
+ self.setup_coreplugin(plugin)
self._plugin_patcher = mock.patch(plugin, autospec=True)
self.plugin = self._plugin_patcher.start()
super(ExtensionTestCase, self).setUp()
plugin = 'neutron.neutron_plugin_base_v2.NeutronPluginBaseV2'
- # Ensure 'stale' patched copies of the plugin are never returned
- NeutronManager._instance = None
-
# Ensure existing ExtensionManager is not used
PluginAwareExtensionManager._instance = None
config.parse(args=args)
# Update the plugin and extensions path
- cfg.CONF.set_override('core_plugin', plugin)
+ self.setup_coreplugin(plugin)
cfg.CONF.set_override('api_extensions_path', EXTDIR)
self._plugin_patcher = mock.patch(plugin, autospec=True)
ext_mgr=None):
super(NeutronDbPluginV2TestCase, self).setUp()
- # Make sure at each test a new instance of the plugin is returned
- NeutronManager._instance = None
# Make sure at each test according extensions for the plugin is loaded
PluginAwareExtensionManager._instance = None
# Save the attributes map in case the plugin will alter it
args.extend(['--config-file', config_file])
config.parse(args=args)
# Update the plugin
- cfg.CONF.set_override('core_plugin', plugin)
+ self.setup_coreplugin(plugin)
cfg.CONF.set_override(
'service_plugins',
[test_config.get(key, default)
def setUp(self):
super(TestL3GwModeMixin, self).setUp()
+ plugin = __name__ + '.' + TestDbIntPlugin.__name__
+ self.setup_coreplugin(plugin)
self.target_object = TestDbIntPlugin()
# Patch the context
ctx_patcher = mock.patch('neutron.context', autospec=True)
args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')]
config.parse(args=args)
- cfg.CONF.set_override('core_plugin', plugin)
-
- manager.NeutronManager._instance = None
+ self.setup_coreplugin(plugin)
ext_mgr = extensions.PluginAwareExtensionManager(
extensions_path,
from neutron.api.v2 import attributes
from neutron.common import config
from neutron.extensions import firewall
-from neutron import manager
from neutron.openstack.common import uuidutils
from neutron.plugins.common import constants
from neutron.tests import base
def setUp(self):
super(FirewallExtensionTestCase, self).setUp()
plugin = 'neutron.extensions.firewall.FirewallPluginBase'
- # Ensure 'stale' patched copies of the plugin are never returned
- manager.NeutronManager._instance = None
# Ensure existing ExtensionManager is not used
extensions.PluginAwareExtensionManager._instance = None
config.parse(args)
# Stubbing core plugin with Firewall plugin
- cfg.CONF.set_override('core_plugin', plugin)
+ self.setup_coreplugin(plugin)
cfg.CONF.set_override('service_plugins', [plugin])
self._plugin_patcher = mock.patch(plugin, autospec=True)
super(ProvidernetExtensionTestCase, self).setUp()
plugin = 'neutron.neutron_plugin_base_v2.NeutronPluginBaseV2'
- # Ensure 'stale' patched copies of the plugin are never returned
- NeutronManager._instance = None
# Ensure existing ExtensionManager is not used
extensions.PluginAwareExtensionManager._instance = None
self.saved_attr_map[resource] = attrs.copy()
# Update the plugin and extensions path
- cfg.CONF.set_override('core_plugin', plugin)
+ self.setup_coreplugin(plugin)
cfg.CONF.set_override('allow_pagination', True)
cfg.CONF.set_override('allow_sorting', True)
self._plugin_patcher = mock.patch(plugin, autospec=True)
args = ['--config-file', etcdir('neutron.conf.test')]
# If test_config specifies some config-file, use it, as well
config.parse(args=args)
- NeutronManager._instance = None
+ self.setup_coreplugin()
self.addCleanup(cfg.CONF.reset)
self.useFixture(
fixtures.MonkeyPatch('neutron.manager.NeutronManager._instance'))
from neutron import context
from neutron.db import api as db
from neutron.db import quota_db
-from neutron import manager
from neutron.plugins.linuxbridge.db import l2network_db_v2
from neutron import quota
from neutron.tests import base
def setUp(self):
super(QuotaExtensionTestCase, self).setUp()
- # Ensure 'stale' patched copies of the plugin are never returned
- manager.NeutronManager._instance = None
-
# Ensure existing ExtensionManager is not used
extensions.PluginAwareExtensionManager._instance = None
config.parse(args=args)
# Update the plugin and extensions path
- cfg.CONF.set_override('core_plugin', TARGET_PLUGIN)
+ self.setup_coreplugin(TARGET_PLUGIN)
cfg.CONF.set_override(
'quota_items',
['network', 'subnet', 'port', 'extra1'],
config.parse(args=args)
#just stubbing core plugin with LoadBalancer plugin
- cfg.CONF.set_override('core_plugin', plugin)
+ self.setup_coreplugin(plugin)
cfg.CONF.set_override('service_plugins', [])
cfg.CONF.set_override('quota_router', -1, group='QUOTAS')
self.addCleanup(cfg.CONF.reset)
- # Ensure 'stale' patched copies of the plugin are never returned
- neutron.manager.NeutronManager._instance = None
-
# Ensure existing ExtensionManager is not used
ext_mgr = extensions.PluginAwareExtensionManager(
from neutron.db import api as db_api
from neutron.db import servicetype_db as st_db
from neutron.extensions import servicetype
-from neutron import manager
from neutron.plugins.common import constants
from neutron.services import provider_configuration as provconf
from neutron.tests import base
def setUp(self):
# This is needed because otherwise a failure will occur due to
# nonexisting core_plugin
- cfg.CONF.set_override('core_plugin', test_db_plugin.DB_PLUGIN_KLASS)
+ self.setup_coreplugin(test_db_plugin.DB_PLUGIN_KLASS)
cfg.CONF.set_override('service_plugins',
["%s.%s" % (dp.__name__,
dp.DummyServicePlugin.__name__)])
self.addCleanup(cfg.CONF.reset)
- # Make sure at each test a new instance of the plugin is returned
- manager.NeutronManager._instance = None
# Ensure existing ExtensionManager is not used
extensions.PluginAwareExtensionManager._instance = None
ext_mgr = TestServiceTypeExtensionManager()