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
This commit is contained in:
Assaf Muller 2015-08-26 16:27:37 -04:00 committed by armando-migliaccio
parent d66f0e2791
commit a584f4b42d
2 changed files with 17 additions and 7 deletions

View File

@ -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'

View File

@ -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: