Some of the tests (e.g. NeutronDbPluginV2AsMixinTestCase) do not call
config_parse so if the database engine is not already been setup by another
test before the config object is reset on teardown, the database connection
will fail since the database config is then empty.
This patch adds a new setup_config method called during the base test case
setUp method which calls config_parse by default to load the default config.
Tests that couldn't use the default config were then modified to override the
setup_config method.
Some other unit tests were slightly adjusted to pass using the default config.
Closes-Bug: #
1346673
Change-Id: I3724200fa932115c0a8c264640b1a9dbe431a1cc
if sys.version_info < (2, 7) and getattr(self, 'fmt', '') == 'xml':
raise self.skipException('XML Testing Skipped in Py26')
+ self.setup_config()
+
+ def setup_config(self):
+ """Tests that need a non-default config can override this method."""
+ self.config_parse()
+
def config(self, **kw):
"""Override some configuration values.
super(OFAAgentTestCase, self).setUp()
self.fake_oflib_of = fake_oflib.patch_fake_oflib_of().start()
self.mod_agent = importutils.import_module(self._AGENT_NAME)
+ self.ryuapp = mock.Mock()
+
+ def setup_config(self):
cfg.CONF.set_default('firewall_driver',
'neutron.agent.firewall.NoopFirewallDriver',
group='SECURITYGROUP')
- self.ryuapp = mock.Mock()
cfg.CONF.register_cli_opts([
cfg.StrOpt('ofp-listen-host', default='',
help='openflow listen host'),
class TestNetnsCleanup(base.BaseTestCase):
+ def setup_config(self):
+ # don't use default config
+ pass
+
def test_setup_conf(self):
expected_opts = interface.OPTS
conf = util.setup_conf()
class TestOVSCleanup(base.BaseTestCase):
+ def setup_config(self):
+ # don't use default config
+ pass
+
def test_setup_conf(self):
conf = util.setup_conf()
self.assertEqual(conf.external_network_bridge, 'br-ex')
class ConfigurationTest(base.BaseTestCase):
+ def setup_config(self):
+ # don't use default config
+ pass
+
def test_defaults(self):
self.assertEqual('0.0.0.0', cfg.CONF.bind_host)
self.assertEqual(9696, cfg.CONF.bind_port)
def test_enable_isolated_metadata_proxy_with_metadata_network(self):
cfg.CONF.set_override('enable_metadata_network', True)
cfg.CONF.set_override('debug', True)
+ cfg.CONF.set_override('verbose', False)
cfg.CONF.set_override('log_file', 'test.log')
class_path = 'neutron.agent.linux.ip_lib.IPWrapper'
self.external_process_p.stop()
'interface_driver', 'neutron.agent.linux.interface.NullDriver'
)
cfg.CONF.set_override('use_namespaces', True)
+ cfg.CONF.set_override('verbose', False)
agent_config.register_root_helper(cfg.CONF)
device_exists_p = mock.patch(