Page MenuHomeSoftware Heritage

refactor SingleDbTestFixture class to add generic db initialization
ClosedPublic

Authored by douardda on Oct 16 2018, 10:54 PM.

Details

Summary

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 T1265 (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 T1265.

Test Plan

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

Diff Detail

Repository
rDCORE Foundations and core functionalities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

This revision is now accepted and ready to land.Oct 17 2018, 11:22 AM
This revision was automatically updated to reflect the committed changes.