Skip to content

refactor SingleDbTestFixture class to add generic db initialization

This series of commits, along with their counterparts in swh-archiver, swh-indexer, swh-scheduler, swh-storage and swh-vault is the firt step for swh-storage#1265 (closed) (aka kill swh-storage-datatest).

we aim at removing the need for the swh-storage-testdata/dumps files in any test that reauire a pg database.

For this we build the required db based on sql files now shipped within the python package. This require several refactorings of SingleDbTestFixture.setUpClass and .add_db() methods:

  • replace the 2 arguments (dump, dump_type) by a single 'dumps' one; this later must be an iterable of couples (dump_file, dump_type)
  • refactor all needed helper functions accordingly.

We also add a small helper function to sort numerical file names, and provide a DB_DUMP_TYPES as a global variable to prepare the next commit in which a new cli tool 'swh-db-init' is added.

We also provide a new generic swh-db-init cli tool used to initialise a database for a given (swh) module, like:

swh-db-init storage

Related to swh-storage#1265 (closed).

Test Plan

swh-core tests should still run fine, but this breaks listed packages until other patches are applied.


Migrated from D538 (view on Phabricator)

Merge request reports