HomeSoftware Heritage

Refactor swh.core.db.pytest_plugin

This commit no longer exists in the repository. It may have been part of a branch which was deleted.

Description

Refactor swh.core.db.pytest_plugin

update the postgresql_fact fixture to be able to use new-ish
pytest_postgresql ability to recreate databases between tests from a
template database.

The ides is to stop using the fragile and confusing "reset" of the
database between tests, which means de facto keep a stateful database
between tests, which make tests result depend on de facto order of
execution of these tests.

For example, test_smoke_test_people_db_up_and_reset cannot be executed
alone, since it depends on the fact test_smoke_test_people_db_up has
been executed before so that the people's db has been reset as a result
of the test setup done by the fixture, which will happen if and only if
the database already exists (thus if another test using this db has been
executed before in this test session).

The old table truncate based behavior has been kept (using a no_db_drop
flag argument) in this diff for bw compatibility reasons, and also because
the new drop-and-create-from-template beahvior remains a bit slower,
which might be a problem for some test cases.

Tests for dependencies (swh-storage, etc.) should still pass with this
refactoring, but will be significantly slower.

A series of revisions for these dependencies is about to be proposed to
adapt them to the new db metadata (version, module, flavor) handling
feature coming with swh.core 2, as well as updating their tests to take
advantage of the template-based db creation in tests, which should bring
back test execution time to almost the same as before this refactoring.

This is needed to be able to implement and test support for the new 'swh
db upgrade' all this is actually about.

Details

Provenance
douarddaAuthored on Feb 7 2022, 3:46 PM
douarddaPushed on Feb 17 2022, 1:55 PM
Differential Revision
D7155: Refactor swh.core.db.pytest_plugin
Build Status
Buildable 26965
Build 42163: test-and-buildJenkins console · Jenkins

Commit No Longer Exists

This commit no longer exists in the repository.