]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix py34 No sql_connection parameter is established error
authorAssaf Muller <amuller@redhat.com>
Wed, 26 Aug 2015 20:27:37 +0000 (16:27 -0400)
committerarmando-migliaccio <armamig@gmail.com>
Wed, 26 Aug 2015 22:56:56 +0000 (15:56 -0700)
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

neutron/common/config.py
neutron/tests/base.py

index c8e4eebf52cfdba45c470b22e0983e3e62603052..9911dd69cf04ce5e33903aebf9d1e1a2d443f4a0 100644 (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'
 
index d89be686bf5e89caf2b744b54f0db75ff97fa68a..cb5fb3ee66f9077f3b31044ed57ac2612277688f 100644 (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: