[openstack-dev] [oslo] oslo.db reset session?
mbayer at redhat.com
Tue Feb 23 16:09:12 UTC 2016
On 02/23/2016 09:22 AM, Sean Dague wrote:
> With enginefascade working coming into projects, there seems to be some
> new bits around oslo.db global sessions.
> The effect of this on tests is a little problematic. Because it builds
> global state which couples between tests. I've got a review to use mysql
> connection explicitly for some Nova functional tests which correctly
> fails and exposes a bug when run individually. However, when run in a
> full test run, the global session means that it's not run against mysql,
> it's run against sqlite, and passes.
> We need something that's the inverse of session.configure() -
> to reset the global session.
> Pointers would be welcomed.
from the oslo.db side, we have frameworks for testing that handle all of
these details (e.g. oslo_db.sqlalchemy.test_base.DbTestCase and
DbFixture). I don't believe Nova uses these frameworks (I think it
should long term), but for now the techniques used by oslo.db's
framework should likely be used:
self.test.enginefacade = enginefacade._TestTransactionFactory(
self.test.engine, self.test.sessionmaker, apply_global=True,
The above apply_global flag indicates that the global enginefacade
should use this TestTransactionFactory until disposed.
More information about the OpenStack-dev