Reviewed: https://review.openstack.org/551192 Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=3002df76d1133697cd0c3494c272cd41606d5899 Submitter: Zuul Branch: master
commit 3002df76d1133697cd0c3494c272cd41606d5899 Author: Lujin <[email protected]> Date: Fri Mar 9 16:05:05 2018 +0900 Fix UTs to accommodate new_facade flag in OVO objects In current UTs, in tests that do not actually touch databases, we mock out refresh and expunge in current context. This will not work under new engine facade, as new sessions are created everytime. We will need this fix when we set any object's new_facade flag to True. Closes-Bug: #1750735 Change-Id: I3a8bc06a671e37959e3014f8672b9a5e118c5c52 ** Changed in: neutron Status: In Progress => Fix Released -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to neutron. https://bugs.launchpad.net/bugs/1750735 Title: [OVO] UT fails when setting new_facade to True Status in neutron: Fix Released Bug description: How to reproduce: 1) Set new_facade = True in any OVO object. I tried PortBinding(), Port() and Network(). 2) Run python -m testtools.run neutron/tests/unit/objects/test_network.py or python -m testtools.run neutron/tests/unit/objects/test_port.py 3) Example of failures: ====================================================================== ERROR: neutron.tests.unit.objects.test_network.NetworkObjectIfaceTestCase.test_update_updates_from_db_object ---------------------------------------------------------------------- Traceback (most recent call last): File "neutron/tests/base.py", line 132, in func return f(self, *args, **kwargs) File "neutron/tests/base.py", line 132, in func return f(self, *args, **kwargs) File "/home/stack/small_port_2/neutron/.tox/py27/local/lib/python2.7/site-packages/mock/mock.py", line 1305, in patched return func(*args, **keywargs) File "neutron/tests/unit/objects/test_base.py", line 1167, in test_update_updates_from_db_object obj.update() File "neutron/objects/base.py", line 319, in decorator self.obj_context.session.refresh(self.db_obj) File "/home/stack/small_port_2/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1498, in refresh self._expire_state(state, attribute_names) File "/home/stack/small_port_2/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1600, in _expire_state self._validate_persistent(state) File "/home/stack/small_port_2/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 2042, in _validate_persistent state_str(state)) sqlalchemy.exc.InvalidRequestError: Instance '<Network at 0x7febff8aea90>' is not persistent within this Session I believe something merged after Feb. 9th breaks them. As in [1], no codes changes from Feb. 9th but it fails on recheck on Feb. 20th. [1] https://review.openstack.org/#/c/537320/ Update ============================================================== I think it is [1] which introduces new_facade attr is causing trouble. I need to double check. [1] https://github.com/openstack/neutron/commit/6f83466307fb21aee5bb596974644d457ae1fa60 #diff-e900a9020bbb5db562fe3b148873a78d ===================================================================== Update on 06/03/2018 After some more digging, I found the root cause of this bug is due to new engine facade will start a new session. then these two lines [2] are not applied. (py27) stack@luo-dev:~/small_port_2/neutron$ python -m testtools.run neutron.tests.unit.objects.test_ports.PortIfaceObjTestCase.test_get_object_unique_key Tests running... > /home/stack/small_port_2/neutron/neutron/tests/unit/objects/test_base.py(803)test_get_object_unique_key() -> print self.context (Pdb) c <neutron_lib.context.Context object at 0x7f486878a550> <sqlalchemy.orm.session.Session object at 0x7f48683d6610> > /home/stack/small_port_2/neutron/neutron/objects/base.py(553)get_object() -> print context (Pdb) c <neutron_lib.context.Context object at 0x7f486878a550> <sqlalchemy.orm.session.Session object at 0x7f48683d6610> > /home/stack/small_port_2/neutron/neutron/objects/base.py(557)get_object() -> print context (Pdb) c <neutron_lib.context.Context object at 0x7f486878a550> <sqlalchemy.orm.session.Session object at 0x7f4867e9ee50> [2] https://github.com/openstack/neutron/blob/master/neutron/tests/unit/objects/test_base.py#L695-L696 To manage notifications about this bug go to: https://bugs.launchpad.net/neutron/+bug/1750735/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : [email protected] Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp

