Reviewed: https://review.opendev.org/c/openstack/nova/+/814735 Committed: https://opendev.org/openstack/nova/commit/a7bccff06b871765fb87ee3e9edd9458c7f73701 Submitter: "Zuul (22348)" Branch: master
commit a7bccff06b871765fb87ee3e9edd9458c7f73701 Author: Balazs Gibizer <[email protected]> Date: Wed Oct 27 16:29:29 2021 +0200 Fix interference in db unit test We discovered that two unit test cases added in I0647bb8545c1464b521a1d866cf5ee674aea2eae cause errors like oslo_db.sqlalchemy.enginefacade.AlreadyStartedError: this TransactionFactory is already started when the db tests run selectively with tox -e py38 nova.tests.unit.db but does not cause errors if the whole unit test suit is run. This error happened because our db code uses two global transaction factory, one for the api DB and one for the main DB. There was a global flag SESSION_CONFIGURED in our Database fixture that guarded against double initialization of the factory. But the faulty test cases in question do not use our Database fixture but use the OpportunisticDBTestMixin from oslo_db. Obviously that fixture does not know about our SESSION_CONFIGURED global. So if one of the offending test case ran first in an executor then that initialized the transaction factory globally and a later test that uses our Database fixture tried to configure it again leading to the error. For some unknown reason if these tests were run in the opposite order the faulty re-initialization did not happen. Probably the OpportunisticDBTestMixin was able to prevent that. A previous patch already removed the global SESSION_CONFIGURED flag from our fixture and replaced it with a per DB specific patch_factory calls that allow resetting the state of the factory at the end of each test case. This would already solve the current test case issue as only our offending test cases would initialize the global factory without cleanup and we have one test case per DB. So there would be no interference. However if in the future we add similar test cases then those can still interfere through the global factory. So this patch fixes the two offending test case. Also it extends the DatabasePoisonFixture used for the NoDbTestCase tesst. The poison now detects if the test case starts any transaction factory. This poison caught another offender test case, test_db_sync_with_special_symbols_in_connection_string, that was marked NoDb but actually using the database. It is now changed to declare itself as a test that sets up the DB manually and also it is changed to use the Database fixture instead of touching the global factory directly. Closes-Bug: #1948963 Change-Id: Id96f1795034490c13125ebbab49b029fb96af1c7 ** Changed in: nova Status: In Progress => Fix Released -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to OpenStack Compute (nova). https://bugs.launchpad.net/bugs/1948963 Title: runnig test_db_version_alembic unit test only with other unit.db tests causes: oslo_db.sqlalchemy.enginefacade.AlreadyStartedError: this TransactionFactory is already started Status in OpenStack Compute (nova): Fix Released Bug description: If you run tox -e py38 nova.tests.unit.db then some unit.db tests will fail with oslo_db.sqlalchemy.enginefacade.AlreadyStartedError: this TransactionFactory is already started The exact failed tests and the amount of them depending on the number of executors and some random seed. To manage notifications about this bug go to: https://bugs.launchpad.net/nova/+bug/1948963/+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

