* perf(tests): skip empty tables in clear_database and run migration tests first
clear_database issued 20 DELETEs after every test. One EXISTS query now finds which tables hold rows and only those are cleared. The slow migration tests are scheduled first so they overlap the rest of the suite under xdist.
* perf(tests): clone a migrated template into each MariaDB xdist worker
Replaying every migration in each worker at once was most of a cold run. The template database is migrated once under a server lock and copied into each empty worker database. PostgreSQL keeps running migrations per worker.
* fix(tests): address pr-ready code review
Key the MariaDB template on a digest of the migrations and the helpers
they import, so an edited revision or a template left at another
branch's head or half-migrated is rebuilt instead of reused or failing.
Copy alembic_version last and reset a worker database that has tables
but no version row, so a clone cut short is redone on the next run.
* refactor(tests): pr-ready simplify pass
* style(tests): pr-ready polish
* style(tests): pr-ready humanizer pass
* test(tests): cover the template copy and empty-table cleanup
Addresses the Greptile finding that the new database setup paths had no
assertions:
- test_copy_schema_reproduces_the_migrated_database copies the migrated
worker database with _copy_schema and checks tables, views, triggers,
row checksums and the alembic version match the source (MariaDB only).
- test_clear_tables_deletes_only_from_tables_with_rows checks that cleanup
issues a DELETE only for tables holding rows. The fixture body moves into
_clear_tables so the test can call it.
* fix(tests): address pr-ready code review (xhigh)
Hash all of models/ and utils/ into the template digest, warn when the
clone falls back to migrating, defer the digest past the early returns,
and dedupe the DEFINER regex, statement capture and schema-name queries.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* refactor(tests): pr-ready simplify pass
Read tables and views in one query, strip DEFINER once, use the
inspector for the version check, always recreate an unversioned worker
DB, and pull the server lock and template build into helpers.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* style(tests): pr-ready polish
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(db): clear every model table between tests
Derive the cleared tables from BaseModel.metadata.sorted_tables, children
first, instead of a hand-kept list of 20 models. Views and the
permission tables the migrations seed are skipped. A new model is now
cleared without editing the fixture.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* perf(tests): build the MariaDB template once in the xdist controller
pytest_configure_node checks each worker's database on the controller
and, for one with no version row, builds the template (once per session)
and hands its name over through workerinput. Workers copy it without
taking the lock, so copies run in parallel, and a broken migration
fails once instead of once per waiting worker. The template is shared
by every checkout and ROMM_TEST_DB_TAG run, since its digest pins the
schema. DEVELOPER_SETUP.md documents it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>