From a98dc7680d4689f5ce5f602f9c5cb3bcc77de215 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Wed, 26 Feb 2014 11:36:56 +0900 Subject: [PATCH] tests/unit: refactor reading neutron.conf.test neutron.conf.test includes rpc_backend whose value is stashed. Thus it is required to reset when tearing down, otherwise the stale status will be used by succeeding tests causing random error. This patch refactors reading neutron.conf.test and resets the status of rpc_backend properly. Closes-Bug: #1281481 Closes-Bug: #1284549 Change-Id: I0fa5945b6adbb9945d353028ec88d00ccbf4e31a --- neutron/tests/base.py | 27 +++++++++++++++ neutron/tests/unit/cisco/test_config.py | 5 +-- neutron/tests/unit/cisco/test_plugin_model.py | 5 +-- .../db/loadbalancer/test_db_loadbalancer.py | 7 ---- .../tests/unit/metaplugin/test_metaplugin.py | 8 ----- .../drivers/cisco/nexus/test_cisco_config.py | 6 +--- neutron/tests/unit/test_api_v2.py | 15 ++------- neutron/tests/unit/test_api_v2_extension.py | 4 +-- neutron/tests/unit/test_db_plugin.py | 12 ++----- neutron/tests/unit/test_dhcp_agent.py | 11 ++----- .../unit/test_extension_extended_attribute.py | 3 +- .../unit/test_extension_security_group.py | 7 ---- neutron/tests/unit/test_extensions.py | 22 +++---------- neutron/tests/unit/test_linux_dhcp.py | 5 +-- neutron/tests/unit/test_neutron_manager.py | 12 +------ neutron/tests/unit/test_quota_ext.py | 4 +-- .../tests/unit/test_routerserviceinsertion.py | 3 +- .../unit/vmware/extensions/test_networkgw.py | 4 +-- neutron/tests/unit/vmware/test_nsx_opts.py | 33 +++++++++---------- neutron/tests/unit/vmware/test_nsx_sync.py | 3 +- .../vmware/vshield/test_firewall_driver.py | 3 +- .../vshield/test_loadbalancer_driver.py | 3 +- .../unit/vmware/vshield/test_vcns_driver.py | 3 +- 23 files changed, 68 insertions(+), 137 deletions(-) diff --git a/neutron/tests/base.py b/neutron/tests/base.py index 69b1b84bb..7eb566cba 100644 --- a/neutron/tests/base.py +++ b/neutron/tests/base.py @@ -20,6 +20,7 @@ import contextlib import logging import os +import os.path import sys import eventlet.timeout @@ -28,10 +29,13 @@ import mock from oslo.config import cfg import testtools +from neutron.common import config from neutron.common import constants as const from neutron import manager from neutron.openstack.common.notifier import api as notifier_api from neutron.openstack.common.notifier import test_notifier +from neutron.openstack.common import rpc +from neutron.openstack.common.rpc import impl_fake from neutron.tests import post_mortem_debug @@ -40,6 +44,13 @@ CONF.import_opt('state_path', 'neutron.common.config') TRUE_STRING = ['True', '1'] LOG_FORMAT = "%(asctime)s %(levelname)8s [%(name)s] %(message)s" +ROOTDIR = os.path.dirname(__file__) +ETCDIR = os.path.join(ROOTDIR, 'etc') + + +def etcdir(*p): + return os.path.join(ETCDIR, *p) + def fake_use_fatal_exceptions(*args): return True @@ -75,8 +86,24 @@ class BaseTestCase(testtools.TestCase): notification_driver = [test_notifier.__name__] cfg.CONF.set_override("notification_driver", notification_driver) + @staticmethod + def config_parse(conf=None, args=None): + """Create the default configurations.""" + # neutron.conf.test includes rpc_backend which needs to be cleaned up + if args is None: + args = ['--config-file', etcdir('neutron.conf.test')] + if conf is None: + config.parse(args=args) + else: + conf(args) + + def _cleanup_rpc_backend(self): + rpc._RPCIMPL = None + impl_fake.CONSUMERS.clear() + def setUp(self): super(BaseTestCase, self).setUp() + self.addCleanup(self._cleanup_rpc_backend) # Configure this first to ensure pm debugging support for setUp() if os.environ.get('OS_POST_MORTEM_DEBUG') in TRUE_STRING: diff --git a/neutron/tests/unit/cisco/test_config.py b/neutron/tests/unit/cisco/test_config.py index 620f99b86..7104ed06a 100644 --- a/neutron/tests/unit/cisco/test_config.py +++ b/neutron/tests/unit/cisco/test_config.py @@ -16,18 +16,15 @@ import mock from oslo.config import cfg -from neutron.common import config as neutron_config from neutron.plugins.cisco.common import config as cisco_config from neutron.tests import base -from neutron.tests.unit import test_api_v2 class TestCiscoNexusPluginConfig(base.BaseTestCase): def setUp(self): # Point neutron config file to: neutron/tests/etc/neutron.conf.test - args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')] - neutron_config.parse(args=args) + self.config_parse() super(TestCiscoNexusPluginConfig, self).setUp() diff --git a/neutron/tests/unit/cisco/test_plugin_model.py b/neutron/tests/unit/cisco/test_plugin_model.py index a87f9aad5..fa87a5010 100755 --- a/neutron/tests/unit/cisco/test_plugin_model.py +++ b/neutron/tests/unit/cisco/test_plugin_model.py @@ -17,22 +17,19 @@ import sys import mock -from neutron.common import config from neutron import context from neutron.plugins.cisco.common import cisco_constants as const from neutron.plugins.cisco.common import config as cisco_config from neutron.plugins.cisco.models import virt_phy_sw_v2 from neutron.plugins.cisco.nexus import cisco_nexus_plugin_v2 from neutron.tests import base -from neutron.tests.unit import test_api_v2 class TestCiscoPluginModel(base.BaseTestCase): def setUp(self): # Point config file to: neutron/tests/etc/neutron.conf.test - args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')] - config.parse(args=args) + self.config_parse() super(TestCiscoPluginModel, self).setUp() diff --git a/neutron/tests/unit/db/loadbalancer/test_db_loadbalancer.py b/neutron/tests/unit/db/loadbalancer/test_db_loadbalancer.py index af255c1c9..17ee42b39 100644 --- a/neutron/tests/unit/db/loadbalancer/test_db_loadbalancer.py +++ b/neutron/tests/unit/db/loadbalancer/test_db_loadbalancer.py @@ -15,7 +15,6 @@ import contextlib import logging -import os import mock from oslo.config import cfg @@ -51,18 +50,12 @@ DB_LB_PLUGIN_KLASS = ( ) NOOP_DRIVER_KLASS = ('neutron.tests.unit.db.loadbalancer.test_db_loadbalancer.' 'NoopLbaaSDriver') -ROOTDIR = os.path.dirname(__file__) + '../../../..' -ETCDIR = os.path.join(ROOTDIR, 'etc') extensions_path = ':'.join(neutron.extensions.__path__) _subnet_id = "0c798ed8-33ba-11e2-8b28-000c291c4d14" -def etcdir(*p): - return os.path.join(ETCDIR, *p) - - class NoopLbaaSDriver(abstract_driver.LoadBalancerAbstractDriver): """A dummy lbass driver that that only performs object deletion.""" diff --git a/neutron/tests/unit/metaplugin/test_metaplugin.py b/neutron/tests/unit/metaplugin/test_metaplugin.py index 43fb761fc..d56ab62ef 100644 --- a/neutron/tests/unit/metaplugin/test_metaplugin.py +++ b/neutron/tests/unit/metaplugin/test_metaplugin.py @@ -15,8 +15,6 @@ # License for the specific language governing permissions and limitations # under the License. -import os - import mock from oslo.config import cfg import testtools @@ -36,8 +34,6 @@ from neutron.plugins.metaplugin.meta_neutron_plugin import MetaPluginV2 from neutron.tests import base CONF_FILE = "" -ROOTDIR = os.path.dirname(os.path.dirname(__file__)) -ETCDIR = os.path.join(ROOTDIR, 'etc') META_PATH = "neutron.plugins.metaplugin" FAKE_PATH = "neutron.tests.unit.metaplugin" PROXY_PATH = "%s.proxy_neutron_plugin.ProxyPluginV2" % META_PATH @@ -49,10 +45,6 @@ fake1:%s.fake_plugin.Fake1,fake2:%s.fake_plugin.Fake2 """.strip() % (FAKE_PATH, FAKE_PATH) -def etcdir(*p): - return os.path.join(ETCDIR, *p) - - def setup_metaplugin_conf(has_l3=True): cfg.CONF.set_override('auth_url', 'http://localhost:35357/v2.0', 'PROXY') diff --git a/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_config.py b/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_config.py index de12ff235..55f0db3da 100644 --- a/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_config.py +++ b/neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_config.py @@ -17,18 +17,14 @@ import mock from oslo.config import cfg -from neutron.common import config as neutron_config from neutron.plugins.ml2.drivers.cisco.nexus import config as cisco_config from neutron.tests import base -from neutron.tests.unit import test_api_v2 class TestCiscoNexusPluginConfig(base.BaseTestCase): def setUp(self): - # Point neutron config file to: neutron/tests/etc/neutron.conf.test - args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')] - neutron_config.parse(args=args) + self.config_parse() super(TestCiscoNexusPluginConfig, self).setUp() def test_config_parse_error(self): diff --git a/neutron/tests/unit/test_api_v2.py b/neutron/tests/unit/test_api_v2.py index 23441f0a3..26cde7d5d 100644 --- a/neutron/tests/unit/test_api_v2.py +++ b/neutron/tests/unit/test_api_v2.py @@ -30,7 +30,6 @@ from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api from neutron.api.v2 import attributes from neutron.api.v2 import base as v2_base from neutron.api.v2 import router -from neutron.common import config from neutron.common import exceptions as n_exc from neutron import context from neutron.manager import NeutronManager @@ -44,16 +43,11 @@ from neutron.tests.unit import testlib_api ROOTDIR = os.path.dirname(os.path.dirname(__file__)) -ETCDIR = os.path.join(ROOTDIR, 'etc') EXTDIR = os.path.join(ROOTDIR, 'unit/extensions') _uuid = uuidutils.generate_uuid -def etcdir(*p): - return os.path.join(ETCDIR, *p) - - def _get_path(resource, id=None, action=None, fmt=None): path = '/%s' % resource @@ -102,8 +96,7 @@ class APIv2TestBase(base.BaseTestCase): # Ensure existing ExtensionManager is not used PluginAwareExtensionManager._instance = None # Create the default configurations - args = ['--config-file', etcdir('neutron.conf.test')] - config.parse(args=args) + self.config_parse() # Update the plugin self.setup_coreplugin(plugin) cfg.CONF.set_override('allow_pagination', True) @@ -1136,8 +1129,7 @@ class SubresourceTest(base.BaseTestCase): for resource, attrs in attributes.RESOURCE_ATTRIBUTE_MAP.iteritems(): self.saved_attr_map[resource] = attrs.copy() - args = ['--config-file', etcdir('neutron.conf.test')] - config.parse(args=args) + self.config_parse() self.setup_coreplugin(plugin) self._plugin_patcher = mock.patch(plugin, autospec=True) @@ -1410,8 +1402,7 @@ class ExtensionTestCase(base.BaseTestCase): self.saved_attr_map[resource] = attrs.copy() # Create the default configurations - args = ['--config-file', etcdir('neutron.conf.test')] - config.parse(args=args) + self.config_parse() # Update the plugin and extensions path self.setup_coreplugin(plugin) diff --git a/neutron/tests/unit/test_api_v2_extension.py b/neutron/tests/unit/test_api_v2_extension.py index 812b797ca..856f8290c 100644 --- a/neutron/tests/unit/test_api_v2_extension.py +++ b/neutron/tests/unit/test_api_v2_extension.py @@ -27,7 +27,6 @@ import webtest from neutron.api import extensions from neutron.api.v2 import attributes -from neutron.common import config from neutron import quota from neutron.tests.unit import test_api_v2 from neutron.tests.unit import test_extensions @@ -60,8 +59,7 @@ class ExtensionTestCase(testlib_api.WebTestCase): self.addCleanup(self._resotre_attr_map) # Create the default configurations - args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')] - config.parse(args) + self.config_parse() #just stubbing core plugin with plugin self.setup_coreplugin(plugin) diff --git a/neutron/tests/unit/test_db_plugin.py b/neutron/tests/unit/test_db_plugin.py index 43dc762aa..d61de971e 100644 --- a/neutron/tests/unit/test_db_plugin.py +++ b/neutron/tests/unit/test_db_plugin.py @@ -17,7 +17,6 @@ import contextlib import copy -import os import mock from oslo.config import cfg @@ -30,7 +29,6 @@ from neutron.api.extensions import PluginAwareExtensionManager from neutron.api.v2 import attributes from neutron.api.v2.attributes import ATTR_NOT_SPECIFIED from neutron.api.v2.router import APIRouter -from neutron.common import config from neutron.common import constants from neutron.common import exceptions as n_exc from neutron.common.test_lib import test_config @@ -45,8 +43,6 @@ from neutron.tests.unit import test_extensions from neutron.tests.unit import testlib_api DB_PLUGIN_KLASS = 'neutron.db.db_base_plugin_v2.NeutronDbPluginV2' -ROOTDIR = os.path.dirname(os.path.dirname(__file__)) -ETCDIR = os.path.join(ROOTDIR, 'etc') def optional_ctx(obj, fallback): @@ -59,10 +55,6 @@ def optional_ctx(obj, fallback): return context_wrapper() -def etcdir(*p): - return os.path.join(ETCDIR, *p) - - def _fake_get_pagination_helper(self, request): return api_common.PaginationEmulatedHelper(request, self._primary_key) @@ -98,11 +90,11 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase): plugin = DB_PLUGIN_KLASS # Create the default configurations - args = ['--config-file', etcdir('neutron.conf.test')] + args = ['--config-file', base.etcdir('neutron.conf.test')] # If test_config specifies some config-file, use it, as well for config_file in test_config.get('config_files', []): args.extend(['--config-file', config_file]) - config.parse(args=args) + self.config_parse(args=args) # Update the plugin self.setup_coreplugin(plugin) cfg.CONF.set_override( diff --git a/neutron/tests/unit/test_dhcp_agent.py b/neutron/tests/unit/test_dhcp_agent.py index a0a9cbe2d..dd5f1ce12 100644 --- a/neutron/tests/unit/test_dhcp_agent.py +++ b/neutron/tests/unit/test_dhcp_agent.py @@ -16,7 +16,6 @@ # under the License. import copy -import os import sys import uuid @@ -36,8 +35,6 @@ from neutron.openstack.common.rpc import common from neutron.tests import base -ROOTDIR = os.path.dirname(os.path.dirname(__file__)) -ETCDIR = os.path.join(ROOTDIR, 'etc') HOSTNAME = 'hostname' dev_man = dhcp.DeviceManager rpc_api = dhcp_agent.DhcpPluginApi @@ -45,10 +42,6 @@ DEVICE_MANAGER = '%s.%s' % (dev_man.__module__, dev_man.__name__) DHCP_PLUGIN = '%s.%s' % (rpc_api.__module__, rpc_api.__name__) -def etcdir(*p): - return os.path.join(ETCDIR, *p) - - fake_tenant_id = 'aaaaaaaa-aaaa-aaaa-aaaaaaaaaaaa' fake_subnet1_allocation_pools = dhcp.DictModel(dict(id='', start='172.9.9.2', end='172.9.9.254')) @@ -158,7 +151,7 @@ class TestDhcpAgent(base.BaseTestCase): with mock.patch.object(sys, 'argv') as sys_argv: sys_argv.return_value = [ 'dhcp', '--config-file', - etcdir('neutron.conf.test')] + base.etcdir('neutron.conf.test')] cfg.CONF.register_opts(dhcp_agent.DhcpAgent.OPTS) config.register_interface_driver_opts_helper(cfg.CONF) config.register_agent_state_opts_helper(cfg.CONF) @@ -183,7 +176,7 @@ class TestDhcpAgent(base.BaseTestCase): with mock.patch.object(sys, 'argv') as sys_argv: with mock.patch(launcher_str) as launcher: sys_argv.return_value = ['dhcp', '--config-file', - etcdir('neutron.conf.test')] + base.etcdir('neutron.conf.test')] dhcp_agent.main() launcher.assert_has_calls( [mock.call(), mock.call().launch_service(mock.ANY), diff --git a/neutron/tests/unit/test_extension_extended_attribute.py b/neutron/tests/unit/test_extension_extended_attribute.py index 3d7c0283c..5c4ad4038 100644 --- a/neutron/tests/unit/test_extension_extended_attribute.py +++ b/neutron/tests/unit/test_extension_extended_attribute.py @@ -77,8 +77,7 @@ class ExtensionExtendedAttributeTestCase(base.BaseTestCase): ) # point config file to: neutron/tests/etc/neutron.conf.test - args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')] - config.parse(args=args) + self.config_parse() self.setup_coreplugin(plugin) diff --git a/neutron/tests/unit/test_extension_security_group.py b/neutron/tests/unit/test_extension_security_group.py index 5ba27eff4..4a38f6da2 100644 --- a/neutron/tests/unit/test_extension_security_group.py +++ b/neutron/tests/unit/test_extension_security_group.py @@ -14,7 +14,6 @@ # limitations under the License. import contextlib -import os import mock import webob.exc @@ -31,12 +30,6 @@ from neutron.tests.unit import test_db_plugin DB_PLUGIN_KLASS = ('neutron.tests.unit.test_extension_security_group.' 'SecurityGroupTestPlugin') -ROOTDIR = os.path.dirname(os.path.dirname(__file__)) -ETCDIR = os.path.join(ROOTDIR, 'etc') - - -def etcdir(*p): - return os.path.join(ETCDIR, *p) class SecurityGroupTestExtensionManager(object): diff --git a/neutron/tests/unit/test_extensions.py b/neutron/tests/unit/test_extensions.py index 4b0c639a6..fc373709b 100644 --- a/neutron/tests/unit/test_extensions.py +++ b/neutron/tests/unit/test_extensions.py @@ -15,8 +15,6 @@ # License for the specific language governing permissions and limitations # under the License. -import os - import mock import routes import webob @@ -37,14 +35,6 @@ from neutron import wsgi LOG = logging.getLogger(__name__) - -ROOTDIR = os.path.dirname(os.path.dirname(__file__)) -ETCDIR = os.path.join(ROOTDIR, 'etc') - - -def etcdir(*p): - return os.path.join(ETCDIR, *p) - extensions_path = ':'.join(neutron.tests.unit.extensions.__path__) @@ -404,7 +394,7 @@ class RequestExtensionTest(base.BaseTestCase): res.body = jsonutils.dumps(data) return res - base_app = webtest.TestApp(setup_base_app()) + base_app = webtest.TestApp(setup_base_app(self)) response = base_app.put("/dummy_resources/1", {'uneditable': "new_value"}) self.assertEqual(response.json['uneditable'], "original_value") @@ -606,10 +596,8 @@ def app_factory(global_conf, **local_conf): return ExtensionsTestApp(conf) -def setup_base_app(): - config_file = 'neutron.conf.test' - args = ['--config-file', etcdir(config_file)] - config.parse(args=args) +def setup_base_app(test): + base.BaseTestCase.config_parse() app = config.load_paste_app('extensions_test_app') return app @@ -619,9 +607,7 @@ def setup_extensions_middleware(extension_manager=None): extensions.PluginAwareExtensionManager( extensions_path, {constants.CORE: FakePluginWithExtension()})) - config_file = 'neutron.conf.test' - args = ['--config-file', etcdir(config_file)] - config.parse(args=args) + base.BaseTestCase.config_parse() app = config.load_paste_app('extensions_test_app') return extensions.ExtensionMiddleware(app, ext_mgr=extension_manager) diff --git a/neutron/tests/unit/test_linux_dhcp.py b/neutron/tests/unit/test_linux_dhcp.py index 3a1d76ef8..fe54b2846 100644 --- a/neutron/tests/unit/test_linux_dhcp.py +++ b/neutron/tests/unit/test_linux_dhcp.py @@ -390,9 +390,6 @@ class LocalChild(dhcp.DhcpLocalProcess): class TestBase(base.BaseTestCase): def setUp(self): super(TestBase, self).setUp() - root = os.path.dirname(os.path.dirname(__file__)) - args = ['--config-file', - os.path.join(root, 'etc', 'neutron.conf.test')] self.conf = config.setup_conf() self.conf.register_opts(base_config.core_opts) self.conf.register_opts(dhcp.OPTS) @@ -401,7 +398,7 @@ class TestBase(base.BaseTestCase): self.mock_mgr = instance.start() self.conf.register_opt(cfg.BoolOpt('enable_isolated_metadata', default=True)) - self.conf(args=args) + self.config_parse(self.conf) self.conf.set_override('state_path', '') self.conf.use_namespaces = True diff --git a/neutron/tests/unit/test_neutron_manager.py b/neutron/tests/unit/test_neutron_manager.py index 65bb8dc52..4a9b7e50d 100644 --- a/neutron/tests/unit/test_neutron_manager.py +++ b/neutron/tests/unit/test_neutron_manager.py @@ -15,14 +15,12 @@ # License for the specific language governing permissions and limitations # under the License. -import os import types import fixtures from oslo.config import cfg -from neutron.common import config from neutron.manager import NeutronManager from neutron.manager import validate_post_plugin_load from neutron.manager import validate_pre_plugin_load @@ -34,12 +32,6 @@ from neutron.tests.unit import dummy_plugin LOG = logging.getLogger(__name__) DB_PLUGIN_KLASS = 'neutron.db.db_base_plugin_v2.NeutronDbPluginV2' -ROOTDIR = os.path.dirname(os.path.dirname(__file__)) -ETCDIR = os.path.join(ROOTDIR, 'etc') - - -def etcdir(*p): - return os.path.join(ETCDIR, *p) class MultiServiceCorePlugin(object): @@ -55,9 +47,7 @@ class NeutronManagerTestCase(base.BaseTestCase): def setUp(self): super(NeutronManagerTestCase, self).setUp() - args = ['--config-file', etcdir('neutron.conf.test')] - # If test_config specifies some config-file, use it, as well - config.parse(args=args) + self.config_parse() self.setup_coreplugin() self.useFixture( fixtures.MonkeyPatch('neutron.manager.NeutronManager._instance')) diff --git a/neutron/tests/unit/test_quota_ext.py b/neutron/tests/unit/test_quota_ext.py index cf11ecb65..c95e4d3e0 100644 --- a/neutron/tests/unit/test_quota_ext.py +++ b/neutron/tests/unit/test_quota_ext.py @@ -32,7 +32,6 @@ from neutron.db import quota_db from neutron import quota from neutron.tests import base from neutron.tests.unit import test_api_v2 -from neutron.tests.unit import test_extensions from neutron.tests.unit import testlib_api TARGET_PLUGIN = ('neutron.plugins.linuxbridge.lb_neutron_plugin' @@ -54,8 +53,7 @@ class QuotaExtensionTestCase(testlib_api.WebTestCase): self.saved_attr_map[resource] = attrs.copy() # Create the default configurations - args = ['--config-file', test_extensions.etcdir('neutron.conf.test')] - config.parse(args=args) + self.config_parse() # Update the plugin and extensions path self.setup_coreplugin(TARGET_PLUGIN) diff --git a/neutron/tests/unit/test_routerserviceinsertion.py b/neutron/tests/unit/test_routerserviceinsertion.py index b1043d919..d84d0db6e 100644 --- a/neutron/tests/unit/test_routerserviceinsertion.py +++ b/neutron/tests/unit/test_routerserviceinsertion.py @@ -163,8 +163,7 @@ class RouterServiceInsertionTestCase(base.BaseTestCase): ) # point config file to: neutron/tests/etc/neutron.conf.test - args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')] - config.parse(args=args) + self.config_parse() #just stubbing core plugin with LoadBalancer plugin self.setup_coreplugin(plugin) diff --git a/neutron/tests/unit/vmware/extensions/test_networkgw.py b/neutron/tests/unit/vmware/extensions/test_networkgw.py index 540c9cbd1..dcca5c492 100644 --- a/neutron/tests/unit/vmware/extensions/test_networkgw.py +++ b/neutron/tests/unit/vmware/extensions/test_networkgw.py @@ -22,7 +22,6 @@ import webtest from neutron.api import extensions from neutron.api.extensions import PluginAwareExtensionManager from neutron.api.v2 import attributes -from neutron.common import config from neutron import context from neutron.db import api as db_api from neutron.db import db_base_plugin_v2 @@ -77,8 +76,7 @@ class NetworkGatewayExtensionTestCase(base.BaseTestCase): extensions.PluginAwareExtensionManager._instance = None # Create the default configurations - args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')] - config.parse(args=args) + self.config_parse() # Update the plugin and extensions path self.setup_coreplugin(plugin) diff --git a/neutron/tests/unit/vmware/test_nsx_opts.py b/neutron/tests/unit/vmware/test_nsx_opts.py index 9a18fcb78..6897ab95e 100644 --- a/neutron/tests/unit/vmware/test_nsx_opts.py +++ b/neutron/tests/unit/vmware/test_nsx_opts.py @@ -18,7 +18,6 @@ import fixtures import mock from oslo.config import cfg -from neutron.common import config as q_config from neutron.manager import NeutronManager from neutron.openstack.common import uuidutils from neutron.plugins.vmware.api_client import client @@ -99,8 +98,8 @@ class ConfigurationTest(base.BaseTestCase): self.assertEqual('whatever', cluster.default_interface_name) def test_load_plugin_with_full_options(self): - q_config.parse(['--config-file', BASE_CONF_PATH, - '--config-file', NSX_INI_FULL_PATH]) + self.config_parse(args=['--config-file', BASE_CONF_PATH, + '--config-file', NSX_INI_FULL_PATH]) cfg.CONF.set_override('core_plugin', PLUGIN_NAME) plugin = NeutronManager().get_plugin() cluster = plugin.cluster @@ -108,8 +107,8 @@ class ConfigurationTest(base.BaseTestCase): self._assert_extra_options(cluster) def test_load_plugin_with_required_options_only(self): - q_config.parse(['--config-file', BASE_CONF_PATH, - '--config-file', NSX_INI_PATH]) + self.config_parse(args=['--config-file', BASE_CONF_PATH, + '--config-file', NSX_INI_PATH]) cfg.CONF.set_override('core_plugin', PLUGIN_NAME) plugin = NeutronManager().get_plugin() self._assert_required_options(plugin.cluster) @@ -135,16 +134,16 @@ class ConfigurationTest(base.BaseTestCase): self.assertEqual('breth0', cfg.CONF.default_interface_name) def test_load_api_extensions(self): - q_config.parse(['--config-file', BASE_CONF_PATH, - '--config-file', NSX_INI_FULL_PATH]) + self.config_parse(args=['--config-file', BASE_CONF_PATH, + '--config-file', NSX_INI_FULL_PATH]) cfg.CONF.set_override('core_plugin', PLUGIN_NAME) # Load the configuration, and initialize the plugin NeutronManager().get_plugin() self.assertIn('extensions', cfg.CONF.api_extensions_path) def test_agentless_extensions(self): - q_config.parse(['--config-file', BASE_CONF_PATH, - '--config-file', NSX_INI_AGENTLESS_PATH]) + self.config_parse(args=['--config-file', BASE_CONF_PATH, + '--config-file', NSX_INI_AGENTLESS_PATH]) cfg.CONF.set_override('core_plugin', PLUGIN_NAME) self.assertEqual(config.AgentModes.AGENTLESS, cfg.CONF.NSX.agent_mode) @@ -162,8 +161,8 @@ class ConfigurationTest(base.BaseTestCase): plugin.supported_extension_aliases) def test_agentless_extensions_version_fail(self): - q_config.parse(['--config-file', BASE_CONF_PATH, - '--config-file', NSX_INI_AGENTLESS_PATH]) + self.config_parse(args=['--config-file', BASE_CONF_PATH, + '--config-file', NSX_INI_AGENTLESS_PATH]) cfg.CONF.set_override('core_plugin', PLUGIN_NAME) self.assertEqual(config.AgentModes.AGENTLESS, cfg.CONF.NSX.agent_mode) @@ -173,8 +172,8 @@ class ConfigurationTest(base.BaseTestCase): self.assertRaises(exceptions.NsxPluginException, NeutronManager) def test_agentless_extensions_unmet_deps_fail(self): - q_config.parse(['--config-file', BASE_CONF_PATH, - '--config-file', NSX_INI_AGENTLESS_PATH]) + self.config_parse(args=['--config-file', BASE_CONF_PATH, + '--config-file', NSX_INI_AGENTLESS_PATH]) cfg.CONF.set_override('core_plugin', PLUGIN_NAME) self.assertEqual(config.AgentModes.AGENTLESS, cfg.CONF.NSX.agent_mode) @@ -188,8 +187,8 @@ class ConfigurationTest(base.BaseTestCase): NeutronManager) def test_agent_extensions(self): - q_config.parse(['--config-file', BASE_CONF_PATH, - '--config-file', NSX_INI_FULL_PATH]) + self.config_parse(args=['--config-file', BASE_CONF_PATH, + '--config-file', NSX_INI_FULL_PATH]) cfg.CONF.set_override('core_plugin', PLUGIN_NAME) self.assertEqual(config.AgentModes.AGENT, cfg.CONF.NSX.agent_mode) @@ -218,8 +217,8 @@ class OldNVPConfigurationTest(base.BaseTestCase): self.assertEqual(cluster.default_tz_uuid, 'fake_tz_uuid') def test_load_plugin_with_deprecated_options(self): - q_config.parse(['--config-file', BASE_CONF_PATH, - '--config-file', NVP_INI_DEPR_PATH]) + self.config_parse(args=['--config-file', BASE_CONF_PATH, + '--config-file', NVP_INI_DEPR_PATH]) cfg.CONF.set_override('core_plugin', PLUGIN_NAME) plugin = NeutronManager().get_plugin() cluster = plugin.cluster diff --git a/neutron/tests/unit/vmware/test_nsx_sync.py b/neutron/tests/unit/vmware/test_nsx_sync.py index a3abb772d..1b847ffd3 100644 --- a/neutron/tests/unit/vmware/test_nsx_sync.py +++ b/neutron/tests/unit/vmware/test_nsx_sync.py @@ -21,7 +21,6 @@ import mock from oslo.config import cfg from neutron.api.v2 import attributes as attr -from neutron.common import config from neutron.common import constants from neutron.common import exceptions as n_exc from neutron import context @@ -287,7 +286,7 @@ class SyncTestCase(base.BaseTestCase): # and setup needed config variables args = ['--config-file', get_fake_conf('neutron.conf.test'), '--config-file', get_fake_conf('nsx.ini.test')] - config.parse(args=args) + self.config_parse(args=args) cfg.CONF.set_override('allow_overlapping_ips', True) self._plugin = plugin.NsxPlugin() # Mock neutron manager plugin load functions to speed up tests diff --git a/neutron/tests/unit/vmware/vshield/test_firewall_driver.py b/neutron/tests/unit/vmware/vshield/test_firewall_driver.py index 6956be6fc..e27637b07 100644 --- a/neutron/tests/unit/vmware/vshield/test_firewall_driver.py +++ b/neutron/tests/unit/vmware/vshield/test_firewall_driver.py @@ -17,7 +17,6 @@ import contextlib import mock import webob.exc -from neutron.common import config as n_config from neutron import context from neutron.db.firewall import firewall_db from neutron.openstack.common import uuidutils @@ -61,7 +60,7 @@ class VcnsDriverTestCase(test_db_firewall.FirewallPluginDbTestCase, def setUp(self): - n_config.parse(['--config-file', VCNS_CONFIG_FILE]) + self.config_parse(args=['--config-file', VCNS_CONFIG_FILE]) # mock vcns self.fc2 = fake_vcns.FakeVcns(unique_router_name=False) self.mock_vcns = mock.patch(VCNS_NAME, autospec=True) diff --git a/neutron/tests/unit/vmware/vshield/test_loadbalancer_driver.py b/neutron/tests/unit/vmware/vshield/test_loadbalancer_driver.py index db0a77283..6afdf980b 100644 --- a/neutron/tests/unit/vmware/vshield/test_loadbalancer_driver.py +++ b/neutron/tests/unit/vmware/vshield/test_loadbalancer_driver.py @@ -16,7 +16,6 @@ import mock -from neutron.common import config as n_config from neutron import context from neutron.openstack.common import uuidutils from neutron.plugins.vmware.dbexts import vcns_db @@ -78,7 +77,7 @@ class VcnsDriverTestCase(test_db_loadbalancer.LoadBalancerPluginDbTestCase): def setUp(self): - n_config.parse(['--config-file', VCNS_CONFIG_FILE]) + self.config_parse(args=['--config-file', VCNS_CONFIG_FILE]) # mock vcns self.fc2 = fake_vcns.FakeVcns(unique_router_name=False) self.mock_vcns = mock.patch(VCNS_NAME, autospec=True) diff --git a/neutron/tests/unit/vmware/vshield/test_vcns_driver.py b/neutron/tests/unit/vmware/vshield/test_vcns_driver.py index 65ece2b39..649ce1211 100644 --- a/neutron/tests/unit/vmware/vshield/test_vcns_driver.py +++ b/neutron/tests/unit/vmware/vshield/test_vcns_driver.py @@ -16,7 +16,6 @@ from eventlet import greenthread import mock -from neutron.common import config as n_config from neutron.plugins.vmware.vshield.common import constants as vcns_const from neutron.plugins.vmware.vshield.common.constants import RouterStatus from neutron.plugins.vmware.vshield.tasks.constants import TaskState @@ -315,7 +314,7 @@ class VcnsDriverTestCase(base.BaseTestCase): def setUp(self): super(VcnsDriverTestCase, self).setUp() - n_config.parse(['--config-file', VCNS_CONFIG_FILE]) + self.config_parse(args=['--config-file', VCNS_CONFIG_FILE]) self.fc = fake_vcns.FakeVcns() self.mock_vcns = mock.patch(VCNS_NAME, autospec=True)