Remove individual cfg.CONF.resets from tests

oslo.config.CONF.reset is added to cleanup in BaseTestCase, so it does
not need to be done by individual test cases.

Change-Id: I5fced5c2d480e78e5bb7cc150f0b653313884456
Closes-Bug: #1291144
This commit is contained in:
Henry Gessau 2014-03-12 01:36:13 -04:00
parent 3196cef698
commit 3d8ee7eb63
41 changed files with 0 additions and 77 deletions

View File

@ -18,7 +18,6 @@
# @author: Abhishek Raut, Cisco Systems Inc.
from mock import patch
from oslo.config import cfg
from neutron.api import extensions as neutron_extensions
from neutron.api.v2 import attributes
@ -201,7 +200,6 @@ class N1kvPluginTestCase(test_plugin.NeutronDbPluginV2TestCase):
n1kv_neutron_plugin.N1kvNeutronPluginV2._setup_vsm = _fake_setup_vsm
neutron_extensions.append_api_extensions_path(extensions.__path__)
self.addCleanup(cfg.CONF.reset)
ext_mgr = NetworkProfileTestExtensionManager()
# Save the original RESOURCE_ATTRIBUTE_MAP

View File

@ -101,7 +101,6 @@ class CiscoNetworkPluginV2TestCase(test_db_plugin.NeutronDbPluginV2TestCase):
for group in config[module]:
for opt, val in config[module][group].items():
module.cfg.CONF.set_override(opt, val, group)
self.addCleanup(module.cfg.CONF.reset)
# Configure the Nexus switch dictionary
# TODO(Henry): add tests for other devices
@ -1012,7 +1011,6 @@ class TestCiscoRouterInterfacesV2(CiscoNetworkPluginV2TestCase):
super(TestCiscoRouterInterfacesV2, self).setUp()
ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
self.addCleanup(cisco_config.CONF.reset)
@contextlib.contextmanager
def _network_subnet_router(self):

View File

@ -189,7 +189,6 @@ class TestCiscoNexusPlugin(base.BaseTestCase):
'provider_vlan_auto_create', auto_create, 'CISCO')
cfg.CONF.set_override(
'provider_vlan_auto_trunk', auto_trunk, 'CISCO')
self.addCleanup(cfg.CONF.reset)
with mock.patch.object(cdb, 'is_provider_vlan',
return_value=True) as mock_db:
# Create a provider network

View File

@ -36,8 +36,6 @@ class TestCiscoPluginModel(base.BaseTestCase):
super(TestCiscoPluginModel, self).setUp()
self.addCleanup(cisco_config.CONF.reset)
def test_non_nexus_device_driver(self):
"""Tests handling of an non-Nexus device driver being configured."""
with mock.patch.dict(sys.modules, {'mock_driver': mock.Mock()}):

View File

@ -352,15 +352,11 @@ class LoadBalancerPluginDbTestCase(LoadBalancerTestMixin,
mock_lbaas_agent = mock.MagicMock()
get_lbaas_agent_patcher.start().return_value = mock_lbaas_agent
mock_lbaas_agent.__getitem__.return_value = {'host': 'host'}
self.addCleanup(cfg.CONF.reset)
self._subnet_id = _subnet_id
class TestLoadBalancer(LoadBalancerPluginDbTestCase):
def setUp(self):
self.addCleanup(cfg.CONF.reset)
super(TestLoadBalancer, self).setUp()
def test_create_vip(self, **extras):
expected = {

View File

@ -37,7 +37,6 @@ class TestEmbraneL3NatDBTestCase(router_test.L3NatDBIntTestCase):
def setUp(self):
cfg.CONF.set_override('admin_password', "admin123", 'heleos')
self.addCleanup(cfg.CONF.reset)
self.addCleanup(db.clear_db)
super(TestEmbraneL3NatDBTestCase, self).setUp()

View File

@ -36,7 +36,6 @@ class EmbranePluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
def setUp(self):
cfg.CONF.set_override('admin_password', "admin123", 'heleos')
self.addCleanup(cfg.CONF.reset)
self.addCleanup(db.clear_db)
super(EmbranePluginV2TestCase, self).setUp(self._plugin_name)

View File

@ -36,7 +36,6 @@ class TestHyperVNeutronAgent(base.BaseTestCase):
def setUp(self):
super(TestHyperVNeutronAgent, self).setUp()
self.addCleanup(cfg.CONF.reset)
# Avoid rpc initialization for unit tests
cfg.CONF.set_override('rpc_backend',
'neutron.openstack.common.rpc.impl_fake')

View File

@ -37,14 +37,12 @@ class CreateAgentConfigMap(base.BaseTestCase):
self.assertTrue(sdnve_neutron_agent.create_agent_config_map(cfg.CONF))
def test_create_agent_config_using_controller_ips(self):
self.addCleanup(cfg.CONF.reset)
cfg.CONF.set_override('controller_ips',
['10.10.10.1', '10.10.10.2'], group='SDNVE')
cfgmap = sdnve_neutron_agent.create_agent_config_map(cfg.CONF)
self.assertEqual(cfgmap['controller_ip'], '10.10.10.1')
def test_create_agent_config_using_interface_mappings(self):
self.addCleanup(cfg.CONF.reset)
cfg.CONF.set_override('interface_mappings',
['interface1 : eth1', 'interface2 : eth2'],
group='SDNVE')
@ -57,7 +55,6 @@ class TestSdnveNeutronAgent(base.BaseTestCase):
def setUp(self):
super(TestSdnveNeutronAgent, self).setUp()
self.addCleanup(cfg.CONF.reset)
notifier_p = mock.patch(NOTIFIER)
notifier_cls = notifier_p.start()
self.notifier = mock.Mock()

View File

@ -18,7 +18,6 @@
import mock
from oslo.config import cfg
from neutron.openstack.common import uuidutils
from neutron.plugins.ibm.common import constants
@ -37,7 +36,6 @@ class TestSdnveApi(base.BaseTestCase):
def setUp(self):
super(TestSdnveApi, self).setUp()
self.addCleanup(cfg.CONF.reset)
class MockKeystoneClient(object):
def __init__(self, **kwargs):

View File

@ -47,7 +47,6 @@ class TestLinuxBridge(base.BaseTestCase):
def setUp(self):
super(TestLinuxBridge, self).setUp()
self.addCleanup(cfg.CONF.reset)
interface_mappings = {'physnet1': 'eth1'}
root_helper = cfg.CONF.AGENT.root_helper
@ -704,7 +703,6 @@ class TestLinuxBridgeManager(base.BaseTestCase):
class TestLinuxBridgeRpcCallbacks(base.BaseTestCase):
def setUp(self):
cfg.CONF.set_override('local_ip', LOCAL_IP, 'VXLAN')
self.addCleanup(cfg.CONF.reset)
super(TestLinuxBridgeRpcCallbacks, self).setUp()
self.u_execute_p = mock.patch('neutron.agent.linux.utils.execute')

View File

@ -45,8 +45,6 @@ class TestBrocadeMechDriverV2(test_db_plugin.NeutronDbPluginV2TestCase):
for opt, val in ml2_opts.items():
ml2_config.cfg.CONF.set_override(opt, val, 'ml2')
self.addCleanup(ml2_config.cfg.CONF.reset)
def mocked_brocade_init(self):
self._driver = mock.MagicMock()

View File

@ -72,14 +72,12 @@ class CiscoML2MechanismTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
}
for opt, val in ml2_opts.items():
ml2_config.cfg.CONF.set_override(opt, val, 'ml2')
self.addCleanup(ml2_config.cfg.CONF.reset)
# Configure the ML2 VLAN parameters
phys_vrange = ':'.join([PHYS_NET, str(VLAN_START), str(VLAN_END)])
vlan_config.cfg.CONF.set_override('network_vlan_ranges',
[phys_vrange],
'ml2_type_vlan')
self.addCleanup(vlan_config.cfg.CONF.reset)
# Configure the Cisco Nexus mechanism driver
nexus_config = {

View File

@ -46,14 +46,12 @@ class TestBigSwitchMechDriverBase(trp.BigSwitchProxyPluginV2TestCase):
}
for opt, val in ml2_opts.items():
ml2_config.cfg.CONF.set_override(opt, val, 'ml2')
self.addCleanup(ml2_config.cfg.CONF.reset)
# Configure the ML2 VLAN parameters
phys_vrange = ':'.join([PHYS_NET, str(VLAN_START), str(VLAN_END)])
vlan_config.cfg.CONF.set_override('network_vlan_ranges',
[phys_vrange],
'ml2_type_vlan')
self.addCleanup(vlan_config.cfg.CONF.reset)
super(TestBigSwitchMechDriverBase,
self).setUp(ML2_PLUGIN)

View File

@ -83,7 +83,6 @@ class TestL2PopulationRpcTestCase(test_plugin.NeutronDbPluginV2TestCase):
'l2population'],
'ml2')
super(TestL2PopulationRpcTestCase, self).setUp(PLUGIN_NAME)
self.addCleanup(config.cfg.CONF.reset)
self.adminContext = context.get_admin_context()

View File

@ -29,7 +29,6 @@ class NCSTestCase(test_plugin.NeutronDbPluginV2TestCase):
config.cfg.CONF.set_override('mechanism_drivers',
['logger', 'ncs'],
'ml2')
self.addCleanup(config.cfg.CONF.reset)
super(NCSTestCase, self).setUp(PLUGIN_NAME)
self.port_create_status = 'DOWN'
mechanism_ncs.NCSMechanismDriver.sendjson = self.check_sendjson

View File

@ -56,7 +56,6 @@ class Ml2PluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
self.phys_vrange = ':'.join([self.physnet, self.vlan_range])
config.cfg.CONF.set_override('network_vlan_ranges', [self.phys_vrange],
group='ml2_type_vlan')
self.addCleanup(config.cfg.CONF.reset)
super(Ml2PluginV2TestCase, self).setUp(PLUGIN_NAME,
service_plugins=service_plugins)
self.port_create_status = 'DOWN'

View File

@ -36,7 +36,6 @@ class PortBindingTestCase(test_plugin.NeutronDbPluginV2TestCase):
config.cfg.CONF.set_override('mechanism_drivers',
['logger', 'test'],
'ml2')
self.addCleanup(config.cfg.CONF.reset)
super(PortBindingTestCase, self).setUp(PLUGIN_NAME)
self.port_create_status = 'DOWN'
self.plugin = manager.NeutronManager.get_plugin()

View File

@ -50,7 +50,6 @@ class VxlanTypeTest(base.BaseTestCase):
self.driver.vxlan_vni_ranges = TUNNEL_RANGES
self.driver._sync_vxlan_allocations()
self.session = db.get_session()
self.addCleanup(cfg.CONF.reset)
self.addCleanup(db.clear_db)
def test_vxlan_tunnel_type(self):

View File

@ -37,7 +37,6 @@ class TestNecAgentBase(base.BaseTestCase):
def setUp(self):
super(TestNecAgentBase, self).setUp()
self.addCleanup(cfg.CONF.reset)
cfg.CONF.set_override('rpc_backend',
'neutron.openstack.common.rpc.impl_fake')
cfg.CONF.set_override('host', 'dummy-host')

View File

@ -33,7 +33,6 @@ class TestOneConvergenceAgentBase(base.BaseTestCase):
def setUp(self):
super(TestOneConvergenceAgentBase, self).setUp()
self.addCleanup(cfg.CONF.reset)
cfg.CONF.set_override('rpc_backend',
'neutron.openstack.common.rpc.impl_fake')
with contextlib.nested(

View File

@ -41,7 +41,6 @@ class CreateAgentConfigMap(base.BaseTestCase):
self.assertTrue(ovs_neutron_agent.create_agent_config_map(cfg.CONF))
def test_create_agent_config_map_fails_for_invalid_tunnel_config(self):
self.addCleanup(cfg.CONF.reset)
# An ip address is required for tunneling but there is no default,
# verify this for both gre and vxlan tunnels.
cfg.CONF.set_override('tunnel_types', [p_const.TYPE_GRE],
@ -54,7 +53,6 @@ class CreateAgentConfigMap(base.BaseTestCase):
ovs_neutron_agent.create_agent_config_map(cfg.CONF)
def test_create_agent_config_map_enable_tunneling(self):
self.addCleanup(cfg.CONF.reset)
# Verify setting only enable_tunneling will default tunnel_type to GRE
cfg.CONF.set_override('tunnel_types', None, group='AGENT')
cfg.CONF.set_override('enable_tunneling', True, group='OVS')
@ -63,20 +61,17 @@ class CreateAgentConfigMap(base.BaseTestCase):
self.assertEqual(cfgmap['tunnel_types'], [p_const.TYPE_GRE])
def test_create_agent_config_map_fails_no_local_ip(self):
self.addCleanup(cfg.CONF.reset)
# An ip address is required for tunneling but there is no default
cfg.CONF.set_override('enable_tunneling', True, group='OVS')
with testtools.ExpectedException(ValueError):
ovs_neutron_agent.create_agent_config_map(cfg.CONF)
def test_create_agent_config_map_fails_for_invalid_tunnel_type(self):
self.addCleanup(cfg.CONF.reset)
cfg.CONF.set_override('tunnel_types', ['foobar'], group='AGENT')
with testtools.ExpectedException(ValueError):
ovs_neutron_agent.create_agent_config_map(cfg.CONF)
def test_create_agent_config_map_multiple_tunnel_types(self):
self.addCleanup(cfg.CONF.reset)
cfg.CONF.set_override('local_ip', '10.10.10.10', group='OVS')
cfg.CONF.set_override('tunnel_types', [p_const.TYPE_GRE,
p_const.TYPE_VXLAN], group='AGENT')
@ -89,7 +84,6 @@ class TestOvsNeutronAgent(base.BaseTestCase):
def setUp(self):
super(TestOvsNeutronAgent, self).setUp()
self.addCleanup(cfg.CONF.reset)
notifier_p = mock.patch(NOTIFIER)
notifier_cls = notifier_p.start()
self.notifier = mock.Mock()
@ -763,7 +757,6 @@ class AncillaryBridgesTest(base.BaseTestCase):
def setUp(self):
super(AncillaryBridgesTest, self).setUp()
self.addCleanup(cfg.CONF.reset)
notifier_p = mock.patch(NOTIFIER)
notifier_cls = notifier_p.start()
self.notifier = mock.Mock()

View File

@ -25,10 +25,6 @@ from neutron.tests import base
class TestLbaasService(base.BaseTestCase):
def setUp(self):
super(TestLbaasService, self).setUp()
self.addCleanup(cfg.CONF.reset)
def test_start(self):
with mock.patch.object(
agent.rpc_service.Service, 'start'

View File

@ -177,7 +177,6 @@ class AgentDBTestCase(AgentDBTestMixIn,
self.saved_attr_map[resource] = attrs.copy()
ext_mgr = AgentTestExtensionManager()
self.addCleanup(self.restore_resource_attribute_map)
self.addCleanup(cfg.CONF.reset)
super(AgentDBTestCase, self).setUp(plugin=plugin, ext_mgr=ext_mgr)
def restore_resource_attribute_map(self):

View File

@ -16,16 +16,12 @@
# under the License.
import mock
from oslo.config import cfg
from neutron.agent import netns_cleanup_util as util
from neutron.tests import base
class TestNetnsCleanup(base.BaseTestCase):
def setUp(self):
super(TestNetnsCleanup, self).setUp()
self.addCleanup(cfg.CONF.reset)
def test_kill_dhcp(self, dhcp_active=True):
conf = mock.Mock()

View File

@ -18,7 +18,6 @@
import contextlib
import itertools
import mock
from oslo.config import cfg
from neutron.agent.linux import ip_lib
from neutron.agent.linux import ovs_lib
@ -28,9 +27,6 @@ from neutron.tests import base
class TestOVSCleanup(base.BaseTestCase):
def setUp(self):
super(TestOVSCleanup, self).setUp()
self.addCleanup(cfg.CONF.reset)
def test_setup_conf(self):
conf = util.setup_conf()

View File

@ -113,7 +113,6 @@ class APIv2TestBase(base.BaseTestCase):
instance._NeutronPluginBaseV2__native_pagination_support = True
instance._NeutronPluginBaseV2__native_sorting_support = True
self.addCleanup(self._plugin_patcher.stop)
self.addCleanup(cfg.CONF.reset)
api = router.APIRouter()
self.api = webtest.TestApp(api)
@ -1144,7 +1143,6 @@ class SubresourceTest(base.BaseTestCase):
self._plugin_patcher = mock.patch(plugin, autospec=True)
self.plugin = self._plugin_patcher.start()
self.addCleanup(self._plugin_patcher.stop)
self.addCleanup(cfg.CONF.reset)
router.SUB_RESOURCES['dummy'] = {
'collection_name': 'dummies',
@ -1387,7 +1385,6 @@ class ExtensionTestCase(base.BaseTestCase):
self._plugin_patcher.stop()
self.api = None
self.plugin = None
cfg.CONF.reset()
# Restore the global RESOURCE_ATTRIBUTE_MAP
attributes.RESOURCE_ATTRIBUTE_MAP = self.saved_attr_map

View File

@ -41,7 +41,6 @@ class TestCli(base.BaseTestCase):
self.do_alembic_cmd_p = mock.patch.object(cli, 'do_alembic_command')
self.do_alembic_cmd = self.do_alembic_cmd_p.start()
self.addCleanup(self.do_alembic_cmd_p.stop)
self.addCleanup(cli.CONF.reset)
def _main_test_helper(self, argv, func_name, exp_args=(), exp_kwargs={}):
with mock.patch.object(sys, 'argv', argv):

View File

@ -160,7 +160,6 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
# NOTE(jkoelker) for a 'pluggable' framework, Neutron sure
# doesn't like when the plugin changes ;)
db.clear_db()
cfg.CONF.reset()
# Restore the original attribute map
attributes.RESOURCE_ATTRIBUTE_MAP = self._attribute_map_bk
super(NeutronDbPluginV2TestCase, self).tearDown()

View File

@ -490,7 +490,6 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
self.plugin_p.stop()
self.mock_makedirs_p.stop()
self.mock_init_p.stop()
cfg.CONF.reset()
super(TestDhcpAgentEventHandler, self).tearDown()
def _enable_dhcp_helper(self, isolated_metadata=False):
@ -1118,7 +1117,6 @@ class TestDeviceManager(base.BaseTestCase):
self.dvr_cls_p.stop()
self.device_exists_p.stop()
self.iproute_cls_p.stop()
cfg.CONF.reset()
super(TestDeviceManager, self).tearDown()
def _test_setup_helper(self, device_exists, reuse_existing=False,

View File

@ -104,7 +104,6 @@ class ExtensionExtendedAttributeTestCase(base.BaseTestCase):
attributes.RESOURCE_ATTRIBUTE_MAP.update(
extattr.EXTENDED_ATTRIBUTES_2_0)
self.agentscheduler_dbMinxin = manager.NeutronManager.get_plugin()
self.addCleanup(cfg.CONF.reset)
self.addCleanup(self.restore_attribute_map)
quota.QUOTAS._driver = None

View File

@ -82,7 +82,6 @@ class ProvidernetExtensionTestCase(testlib_api.WebTestCase):
ext_mgr = ProviderExtensionManager()
self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
self.addCleanup(self._plugin_patcher.stop)
self.addCleanup(cfg.CONF.reset)
self.addCleanup(self._restore_attribute_map)
self.api = webtest.TestApp(router.APIRouter())

View File

@ -59,7 +59,6 @@ class NeutronManagerTestCase(base.BaseTestCase):
# If test_config specifies some config-file, use it, as well
config.parse(args=args)
self.setup_coreplugin()
self.addCleanup(cfg.CONF.reset)
self.useFixture(
fixtures.MonkeyPatch('neutron.manager.NeutronManager._instance'))

View File

@ -82,7 +82,6 @@ class QuotaExtensionTestCase(testlib_api.WebTestCase):
self.api = None
self.plugin = None
db.clear_db()
cfg.CONF.reset()
# Restore the global RESOURCE_ATTRIBUTE_MAP
attributes.RESOURCE_ATTRIBUTE_MAP = self.saved_attr_map

View File

@ -170,7 +170,6 @@ class RouterServiceInsertionTestCase(base.BaseTestCase):
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 existing ExtensionManager is not used
@ -197,7 +196,6 @@ class RouterServiceInsertionTestCase(base.BaseTestCase):
def tearDown(self):
self.api = None
db.clear_db()
cfg.CONF.reset()
super(RouterServiceInsertionTestCase, self).tearDown()
def _setup_core_resources(self):

View File

@ -179,7 +179,6 @@ class ServiceTypeExtensionTestCaseBase(testlib_api.WebTestCase):
cfg.CONF.set_override('service_plugins',
["%s.%s" % (dp.__name__,
dp.DummyServicePlugin.__name__)])
self.addCleanup(cfg.CONF.reset)
# Ensure existing ExtensionManager is not used
extensions.PluginAwareExtensionManager._instance = None
ext_mgr = TestServiceTypeExtensionManager()

View File

@ -77,7 +77,6 @@ class MacLearningDBTestCase(test_db_plugin.NeutronDbPluginV2TestCase):
cfg.CONF.set_override('metadata_mode', None, 'NSX')
self.addCleanup(self.fc.reset_all)
self.addCleanup(self.restore_resource_attribute_map)
self.addCleanup(cfg.CONF.reset)
super(MacLearningDBTestCase, self).setUp(plugin=PLUGIN_NAME,
ext_mgr=ext_mgr)

View File

@ -81,7 +81,6 @@ class NetworkGatewayExtensionTestCase(base.BaseTestCase):
# Update the plugin and extensions path
self.setup_coreplugin(plugin)
self.addCleanup(cfg.CONF.reset)
_plugin_patcher = mock.patch(plugin, autospec=True)
self.plugin = _plugin_patcher.start()

View File

@ -49,7 +49,6 @@ class DhcpAgentNotifierTestCase(test_base.OvsDhcpAgentNotifierTestCase):
self.addCleanup(self.fc.reset_all)
self.addCleanup(patch_sync.stop)
self.addCleanup(self.mock_nsx_api.stop)
self.addCleanup(cfg.CONF.reset)
def _test_gateway_subnet_notification(self, gateway='10.0.0.1'):
cfg.CONF.set_override('metadata_mode', 'dhcp_host_route', 'NSX')

View File

@ -268,7 +268,6 @@ class LsnManagerTestCase(base.BaseTestCase):
self.mock_lsn_api = self.mock_lsn_api_p.start()
nsx.register_dhcp_opts(cfg)
nsx.register_metadata_opts(cfg)
self.addCleanup(cfg.CONF.reset)
self.addCleanup(self.mock_lsn_api_p.stop)
def test_lsn_get(self):
@ -703,7 +702,6 @@ class PersistentLsnManagerTestCase(base.BaseTestCase):
self.context = context.get_admin_context()
self.mock_lsn_api_p = mock.patch.object(lsn_man, 'lsn_api')
self.mock_lsn_api = self.mock_lsn_api_p.start()
self.addCleanup(cfg.CONF.reset)
self.addCleanup(self.mock_lsn_api_p.stop)
self.addCleanup(db.clear_db)

View File

@ -302,10 +302,6 @@ class SyncTestCase(base.BaseTestCase):
self.addCleanup(mock_nm_get_plugin.stop)
self.addCleanup(mock_nm_get_service_plugins.stop)
def tearDown(self):
cfg.CONF.reset()
super(SyncTestCase, self).tearDown()
@contextlib.contextmanager
def _populate_data(self, ctx, net_size=2, port_size=2, router_size=2):