]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
tests/unit: refactor reading neutron.conf.test
authorIsaku Yamahata <isaku.yamahata@intel.com>
Wed, 26 Feb 2014 02:36:56 +0000 (11:36 +0900)
committerIsaku Yamahata <isaku.yamahata@intel.com>
Thu, 1 May 2014 02:20:18 +0000 (11:20 +0900)
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

23 files changed:
neutron/tests/base.py
neutron/tests/unit/cisco/test_config.py
neutron/tests/unit/cisco/test_plugin_model.py
neutron/tests/unit/db/loadbalancer/test_db_loadbalancer.py
neutron/tests/unit/metaplugin/test_metaplugin.py
neutron/tests/unit/ml2/drivers/cisco/nexus/test_cisco_config.py
neutron/tests/unit/test_api_v2.py
neutron/tests/unit/test_api_v2_extension.py
neutron/tests/unit/test_db_plugin.py
neutron/tests/unit/test_dhcp_agent.py
neutron/tests/unit/test_extension_extended_attribute.py
neutron/tests/unit/test_extension_security_group.py
neutron/tests/unit/test_extensions.py
neutron/tests/unit/test_linux_dhcp.py
neutron/tests/unit/test_neutron_manager.py
neutron/tests/unit/test_quota_ext.py
neutron/tests/unit/test_routerserviceinsertion.py
neutron/tests/unit/vmware/extensions/test_networkgw.py
neutron/tests/unit/vmware/test_nsx_opts.py
neutron/tests/unit/vmware/test_nsx_sync.py
neutron/tests/unit/vmware/vshield/test_firewall_driver.py
neutron/tests/unit/vmware/vshield/test_loadbalancer_driver.py
neutron/tests/unit/vmware/vshield/test_vcns_driver.py

index 69b1b84bb47dbb26845409b3511de3b699eef65a..7eb566cba922f63e0b936ce591ba0a8a309205c9 100644 (file)
@@ -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:
index 620f99b86f666bb69241ff37b8613b15d558145e..7104ed06a7eb6777377565a8a43b2b29aeaed609 100644 (file)
 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()
 
index a87f9aad56267a0390e3ee41117b147eb0a9566d..fa87a501048956ed1180faa1e123cc52b618c647 100755 (executable)
@@ -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()
 
index af255c1c95064522777c8c235885e37ef4904859..17ee42b39bdf18253192df3162e9559e25b8f140 100644 (file)
@@ -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."""
 
index 43fb761fc8dd6152a3c1399ad24e5f93ddc57ea1..d56ab62ef4cbbe097d7d0d5d16ff7d7be997855d 100644 (file)
@@ -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')
index de12ff235ef76441fc97db7802d9f3fcaaaafbc9..55f0db3daca3ddd7dbe5b19ee7a882c11335fa07 100644 (file)
 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):
index 23441f0a3c027a3f8b672580e4c31d416f60db0d..26cde7d5d2d39c2d0bc7a38576debc58766d9069 100644 (file)
@@ -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)
index 812b797cae72b4f0f3b22dd21236757b7d7b4f1a..856f8290c779243bbba4ff23b631cd08948a342b 100644 (file)
@@ -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)
index 43dc762aacd09fe4bc644286b4199f89f4123dd6..d61de971e4a665e82cd017d2987bdee6dd4c9d2f 100644 (file)
@@ -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(
index a0a9cbe2dcad59aa31ed5942421cf80d555b8558..dd5f1ce127eeeb81fe17782b9d10a7cf6a4d614b 100644 (file)
@@ -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),
index 3d7c0283c368620b5c0bfdc6d948a9c6319d7858..5c4ad40381bae605822e1d874fa90ff1287a41d2 100644 (file)
@@ -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)
 
index 5ba27eff43f56bbb3c4673b81b7070378bf52fd9..4a38f6da2f11f4d48fff6a848790feac3847bced 100644 (file)
@@ -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):
index 4b0c639a63fbcf1c062d5c67744840fd79723b0e..fc373709bbc48ffa32665dbbba57c98dd5e3aaf4 100644 (file)
@@ -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)
 
index 3a1d76ef8c8694a537eacf8df751d32ad245191d..fe54b28469742f6cc8ae79b3199fd632263c3038 100644 (file)
@@ -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
 
index 65bb8dc52245dd6d5905ca4c8f874265465ac302..4a9b7e50ded2f8762ff9c253f7151aa6d8ea335b 100644 (file)
 #    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'))
index cf11ecb658d01a99b51f75ee887bd2a57762af07..c95e4d3e0344609c939e136a4be7b0fdf87d8f02 100644 (file)
@@ -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)
index b1043d919c29a311d9209d0fc132e05008552259..d84d0db6e228650a30fe27f3ff2305f6bf1f6d0f 100644 (file)
@@ -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)
index 540c9cbd1240814ab392f7055ead1fd4307527f2..dcca5c4927a8fda425ddae1f696c29b1afb83cf9 100644 (file)
@@ -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)
index 9a18fcb7877f683bcfc4d194272aa06ac4d6878c..6897ab95eed4a3e6043b571a26403b560754668b 100644 (file)
@@ -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
index a3abb772dd84a4a9b605fd36fed71c043e2f8315..1b847ffd3f48cb4add7cb79ac05585381e97048c 100644 (file)
@@ -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
index 6956be6fcd379af6448ed546a7b24ab494f044b7..e27637b07893ed31f35384973710e123ceee14dd 100644 (file)
@@ -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)
index db0a77283129dfc8f1604af342c1ff690af6f8ce..6afdf980ba89521e31a8e6d24a7161bdea493903 100644 (file)
@@ -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)
index 65ece2b399f83e225293a513bfc874ca614cdb95..649ce1211115ed0eb2d9f450d4f360f1ac14abfb 100644 (file)
@@ -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)