summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBrant Knudson <bknudson@us.ibm.com>2013-05-18 14:28:34 -0500
committerBrant Knudson <bknudson@us.ibm.com>2013-07-12 13:59:32 -0500
commit405a914db7d2938a76384821e556df9024e6c8ac (patch)
tree073dbfbba13ab196d7790fe7931501700d50de77 /tests
parent24a6f41405299e4c7c9e2d80969311b1c9b6fb5a (diff)
downloadkeystone-405a914db7d2938a76384821e556df9024e6c8ac.tar.gz
keystone-405a914db7d2938a76384821e556df9024e6c8ac.tar.xz
keystone-405a914db7d2938a76384821e556df9024e6c8ac.zip
Clear cached engine when global engine changes
The keystone.common.sql.core.Base class cached the global database engine when get_session() was called. When the global database engine changed to a new instance, the cached copy was used in subsequent calls to get_session(), leading to using the old engine and tests failing to run by themselves. This change makes it so that when the global database engine is changed, Base will use the new engine rather than the invalid one. Change-Id: I75aa3c230d9b4fd666ab8d478c9e9a27669905e8 Fixes: Bug #1179259
Diffstat (limited to 'tests')
-rw-r--r--tests/test_sql_core.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/test_sql_core.py b/tests/test_sql_core.py
index bb413485..e60005f5 100644
--- a/tests/test_sql_core.py
+++ b/tests/test_sql_core.py
@@ -172,3 +172,11 @@ class TestBase(test.TestCase):
self.assertFalse(session.autocommit)
self.assertTrue(session.expire_on_commit)
+
+ def test_get_session_invalidated(self):
+ # If clear the global engine, a new engine is used for get_session().
+ base = sql.Base()
+ session1 = base.get_session()
+ sql.set_global_engine(None)
+ session2 = base.get_session()
+ self.assertIsNot(session1.bind, session2.bind)