Do not alter test_config global in test_extension_ext_gw_mode

Bug 1199557

Instead, allow subclasses to instruct the base test class which
API extension manager they should use as it is already done with
the plugin name.

Change-Id: If4e53ffca3bdeb4fb218918358437aca41489de4
This commit is contained in:
Salvatore Orlando 2013-07-10 01:32:51 +02:00
parent 07b0c92979
commit 05691c2e4c
3 changed files with 10 additions and 11 deletions

View File

@ -90,7 +90,7 @@ class NiciraPluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
# Emulate tests against NVP 2.x
instance.return_value.get_nvp_version.return_value = NVPVersion("2.9")
instance.return_value.request.side_effect = _fake_request
super(NiciraPluginV2TestCase, self).setUp(PLUGIN_NAME)
super(NiciraPluginV2TestCase, self).setUp(plugin=PLUGIN_NAME)
cfg.CONF.set_override('metadata_mode', None, 'NVP')
self.addCleanup(self.fc.reset_all)
self.addCleanup(self.mock_nvpapi.stop)
@ -861,8 +861,8 @@ class TestNiciraQoSQueue(NiciraPluginV2TestCase):
self.assertEqual(queue['qos_queue']['max'], 20)
class NiciraExtGwModeTestCase(test_ext_gw_mode.ExtGwModeTestCase,
NiciraPluginV2TestCase):
class NiciraExtGwModeTestCase(NiciraPluginV2TestCase,
test_ext_gw_mode.ExtGwModeTestCase):
pass

View File

@ -76,7 +76,8 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
fmt = 'json'
resource_prefix_map = {}
def setUp(self, plugin=None, service_plugins=None):
def setUp(self, plugin=None, service_plugins=None,
ext_mgr=None):
super(NeutronDbPluginV2TestCase, self).setUp()
# Make sure at each test a new instance of the plugin is returned
@ -148,8 +149,7 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
native_sorting_attr_name, False))
self._skip_native_sorting = not _is_native_sorting_support()
ext_mgr = test_config.get('extension_manager', None)
ext_mgr = ext_mgr or test_config.get('extension_manager')
if ext_mgr:
self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)

View File

@ -26,7 +26,6 @@ from oslo.config import cfg
from webob import exc
from neutron.common import constants
from neutron.common.test_lib import test_config
from neutron.db import api as db_api
from neutron.db import l3_db
from neutron.db import l3_gwmode_db
@ -301,18 +300,18 @@ class TestL3GwModeMixin(base.BaseTestCase):
class ExtGwModeTestCase(test_db_plugin.NeutronDbPluginV2TestCase,
test_l3_plugin.L3NatTestCaseMixin):
def setUp(self):
def setUp(self, plugin=None):
# Store l3 resource attribute map as it will be updated
self._l3_attribute_map_bk = {}
for item in l3.RESOURCE_ATTRIBUTE_MAP:
self._l3_attribute_map_bk[item] = (
l3.RESOURCE_ATTRIBUTE_MAP[item].copy())
test_config['plugin_name_v2'] = (
plugin = plugin or (
'neutron.tests.unit.test_extension_ext_gw_mode.TestDbPlugin')
test_config['extension_manager'] = TestExtensionManager()
# for these tests we need to enable overlapping ips
cfg.CONF.set_default('allow_overlapping_ips', True)
super(ExtGwModeTestCase, self).setUp()
super(ExtGwModeTestCase, self).setUp(plugin=plugin,
ext_mgr=TestExtensionManager())
self.addCleanup(self.restore_l3_attribute_map)
def restore_l3_attribute_map(self):