Files
Ashish Gupta baa54dbd7e tests: file-backed SQLite with WAL in threading mode for
Database and CellDatabases Fixtures

Under native threading, default in-memory SQLite is a poor fit for the
Database and CellDatabases fixtures. Use a per-test temp file with WAL
for main and API when threading is enabled, and per-cell file URLs for
CellDatabases; clean up db files and WAL sidecars on teardown. Adjust
DefaultFlavorsFixture test to reconnect before reading flavors so the
insert is visible with file-backed SQLite.

Add DatabaseWriteLock, a new fixture that patches
_TransactionContextManager._transaction_scope to acquire a
process-global RLock before every writer transaction, serialising
writes across threads within a single test.  An RLock is used (not
Lock) because the same test installs both a 'main' and 'api' Database
fixture, so the writer path acquires the lock twice from the same
thread.  The fixture is applied unconditionally for parity between
the eventlet and threading backends.

Database.cleanup() disposes the engine only. Per-test temp sqlite
files are removed when NestedTempfile tears down at the end of the
test.

These unit test adaptations are required:
* test_migration.TestDBURL: decoupled from the Database fixture; now
  mocks _get_engine and _upgrade_alembic to test URL encoding directly.
* test_fixtures.TestDatabaseFixture.test_fixture_{cleanup,api_cleanup}:
  pass because cleanup() now removes the file.
* TestDefaultFlavorsFixture.test_flavors updated to use context
  managers for proper connection cleanup
* test_fixtures.TestDatabaseFixture.test_fixture_{cleanup,api_cleanup}:
  skipped in threading mode (mid-test cleanup()+reconnect is an
  in-memory-only check); use db_fixture.reset() for a fresh DB.
  Still being run under eventlet.

Removes threading_unit_test_excludes.txt as all the excluded tests passes now

Also add an exclude list for functional tests that are currently causing
hangs.

Co-Authored-By: Sean Mooney <smooney@redhat.com>
Change-Id: Ia1463734c347f908b93d8659edbf5cadf05ab5d8
Signed-off-by: Ashish Gupta <ashigupt@redhat.com>
2026-07-09 05:40:42 +05:30
..
2017-01-04 11:05:16 +00:00
2025-09-08 09:35:47 -07:00
2023-10-18 00:43:20 +09:00