Ok, so I uploaded https://review.openstack.org/#/c/283728/ on the top of Sean's patches.
We'll take a closer look tomorrow, if we can just put something like this to oslo.db/sqlalchemy/test_base as a public test fixture. On Tue, Feb 23, 2016 at 7:23 PM, Mike Bayer <mba...@redhat.com> wrote: > > > On 02/23/2016 12:06 PM, Roman Podoliaka wrote: >> >> Mike, >> >> I think that won't work as Nova creates its own instance of >> _TransactionContextManager: >> >> >> https://github.com/openstack/nova/blob/d8ddecf6e3ed1e8193e5f6dba910eb29bbe6dac6/nova/db/sqlalchemy/api.py#L134-L135 >> >> Maybe we could change _TestTransactionFactory a bit, so that it takes >> a context manager instance as an argument? > > > If they aren't using the enginefacade global context, then that's even > easier. They should be able to drop in _TestTransactionFactory or any other > TransactionFactory into the _TransactionContextManager they have and then > swap it back. If there aren't API methods for this already, because > everything in enginefacade is underscored, feel free to add. Also I'm not > sure how the enginefacade integration with nova didn't already cover this, I > guess it doesn't yet impact all of those existing MySQLOpportunisticTest > classes it has. > > > > > >> >> On Tue, Feb 23, 2016 at 6:09 PM, Mike Bayer <mba...@redhat.com> wrote: >>> >>> >>> >>> 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. >>>> >>>> https://review.openstack.org/#/c/283364/ >>>> >>>> We need something that's the inverse of session.configure() - >>>> >>>> >>>> https://github.com/openstack/nova/blob/d8ddecf6e3ed1e8193e5f6dba910eb29bbe6dac6/nova/tests/fixtures.py#L205 >>>> 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, >>> synchronous_reader=True) >>> >>> self.addCleanup(self.test.enginefacade.dispose_global) >>> >>> >>> The above apply_global flag indicates that the global enginefacade should >>> use this TestTransactionFactory until disposed. >>> >>> >>> >>> >>> >>>> >>>> -Sean >>>> >>> >>> >>> __________________________________________________________________________ >>> OpenStack Development Mailing List (not for usage questions) >>> Unsubscribe: >>> openstack-dev-requ...@lists.openstack.org?subject:unsubscribe >>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev >> >> >> __________________________________________________________________________ >> OpenStack Development Mailing List (not for usage questions) >> Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe >> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev >> > > __________________________________________________________________________ > OpenStack Development Mailing List (not for usage questions) > Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev __________________________________________________________________________ OpenStack Development Mailing List (not for usage questions) Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev