Skip to content

Commit

Permalink
Share one engine for more than just sqlite in-memory
Browse files Browse the repository at this point in the history
This fixes both bug 1162857 and bug 1162845.

Change-Id: Ica5155d3ac03779693d2d54d8e02c2a413c3d3ac
  • Loading branch information
dolph committed Apr 1, 2013
1 parent af31ecd commit 93b8f2d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions keystone/common/sql/core.py
Expand Up @@ -30,7 +30,6 @@
from keystone import config
from keystone import exception
from keystone.openstack.common import jsonutils
from keystone import exception


CONF = config.CONF
Expand Down Expand Up @@ -98,7 +97,6 @@ def set_global_engine(engine):


def get_global_engine():
global GLOBAL_ENGINE
return GLOBAL_ENGINE


Expand Down Expand Up @@ -250,6 +248,8 @@ def new_engine():
# auto-build the db to support wsgi server w/ in-memory backend
if allow_global_engine and CONF.sql.connection == 'sqlite://':
ModelBase.metadata.create_all(bind=engine)

if allow_global_engine:
set_global_engine(engine)

return engine
Expand Down
3 changes: 3 additions & 0 deletions keystone/common/sql/util.py
Expand Up @@ -17,6 +17,7 @@
import os
import shutil

from keystone.common.sql import core
from keystone.common.sql import migration
from keystone import config

Expand All @@ -38,5 +39,7 @@ def setup_test_database():


def teardown_test_database():
core.set_global_engine(None)

if os.path.exists('test.db.pristine'):
os.unlink('test.db.pristine')

0 comments on commit 93b8f2d

Please sign in to comment.