storage: get database url in right order

event_connection has been deprecated, so we should get connection
from connection url by default.

Change-Id: I0daf73e7163ade7ce6540199525e694b8d574fb3
This commit is contained in:
Hanxi Liu 2017-02-10 16:53:05 +08:00
parent d70233e3b7
commit 2220ff70a0
2 changed files with 5 additions and 4 deletions

View File

@ -66,8 +66,8 @@ def get_connection_from_config(conf):
else tenacity.stop_never)
)
def _inner():
url = (getattr(conf.database, 'event_connection') or
conf.database.connection)
url = (conf.database.connection or
getattr(conf.database, 'event_connection'))
return get_connection(url, conf)
return _inner()

View File

@ -69,8 +69,9 @@ class ConnectionConfigTest(base.BaseTestCase):
self.assertIsInstance(conn, impl_log.Connection)
def test_two_urls(self):
self.CONF.set_override("connection", "sqlite://", group="database")
self.CONF.set_override("event_connection", "log://", group="database")
self.CONF.set_override("connection", "log://", group="database")
self.CONF.set_override("event_connection", "sqlite://",
group="database")
conn = storage.get_connection_from_config(self.CONF)
self.assertIsInstance(conn, impl_log.Connection)