From: Assaf Muller Date: Wed, 26 Aug 2015 20:27:37 +0000 (-0400) Subject: Fix py34 No sql_connection parameter is established error X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=a584f4b42d5a93959d23ef03d06f6acb3eb62c00;p=openstack-build%2Fneutron-build.git Fix py34 No sql_connection parameter is established error Tests that were using DB connections that did not happen to import config.py were not setting the DB connection string. The base test class now sets the string instead of relying on an import to happen. Change-Id: I7aceffff427d6526c0059dd88f67a58783292abd Closes-Bug: #1489098 --- diff --git a/neutron/common/config.py b/neutron/common/config.py index c8e4eebf5..9911dd69c 100644 --- a/neutron/common/config.py +++ b/neutron/common/config.py @@ -152,13 +152,18 @@ cfg.CONF.register_cli_opts(core_cli_opts) # Ensure that the control exchange is set correctly oslo_messaging.set_transport_defaults(control_exchange='neutron') -_SQL_CONNECTION_DEFAULT = 'sqlite://' -# Update the default QueuePool parameters. These can be tweaked by the -# configuration variables - max_pool_size, max_overflow and pool_timeout -db_options.set_defaults(cfg.CONF, - connection=_SQL_CONNECTION_DEFAULT, - sqlite_db='', max_pool_size=10, - max_overflow=20, pool_timeout=10) + + +def set_db_defaults(): + # Update the default QueuePool parameters. These can be tweaked by the + # conf variables - max_pool_size, max_overflow and pool_timeout + db_options.set_defaults( + cfg.CONF, + connection='sqlite://', + sqlite_db='', max_pool_size=10, + max_overflow=20, pool_timeout=10) + +set_db_defaults() NOVA_CONF_SECTION = 'nova' diff --git a/neutron/tests/base.py b/neutron/tests/base.py index d89be686b..cb5fb3ee6 100644 --- a/neutron/tests/base.py +++ b/neutron/tests/base.py @@ -127,6 +127,11 @@ class DietTestCase(testtools.TestCase): def setUp(self): super(DietTestCase, self).setUp() + # FIXME(amuller): this must be called in the Neutron unit tests base + # class to initialize the DB connection string. Moving this may cause + # non-deterministic failures. Bug #1489098 for more info. + config.set_db_defaults() + # Configure this first to ensure pm debugging support for setUp() debugger = os.environ.get('OS_POST_MORTEM_DEBUGGER') if debugger: