Skip to content
Snippets Groups Projects
  1. Mar 09, 2022
  2. Mar 03, 2022
  3. Mar 02, 2022
  4. Mar 01, 2022
  5. Feb 17, 2022
    • David Douard's avatar
      Prevent root conftest.py from loading swh.core at module loading time · 9c9475f7
      David Douard authored
      move the import statement in swhmain() body.
      Having the swh.core module loaded with the execution of conftest.py can
      have weird side effects, especially on pytest's discovery mechanism in
      the context of tox, namely make pytest load test files from the source
      directory rather than from the installed package in the tox venv,
      potentially leading to ImportPathMismatchError.
    • David Douard's avatar
      Add a documentation section for swh.core.db · 1bee4ce5
      David Douard authored
      this is far from completion.
      1bee4ce5
    • David Douard's avatar
      Replace mock_package_sql by a mock_import_swhmodule fixture · 84b63d5b
      David Douard authored
      in favor of using (and thus testing) the stock get_sql_for_package()
      function (on the mock module returned by mock_import_swhmodule).
      
      This comes with a change in expected test data structure for sql
      script; the `tests/data/<mod>` is now expected to store the sql script
      files in a dedicated `sql/` sub directory instead of having them
      directly in the `<mod>` directory so that the get_sql_for_package() can
      be used in tests unmocked.
      84b63d5b
    • David Douard's avatar
    • David Douard's avatar
      Refactor swh.core.db.pytest_plugin · 5822dab0
      David Douard authored
      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.
      5822dab0
  6. Feb 16, 2022
    • David Douard's avatar
      Add a 'swh db upgrade' command · 16e2fd49
      David Douard authored
      this new command allows to handle the database migration from the
      current version to the latest version advertized but the backend
      datastore.
      
      This feature is only working for "new style" swh.core.db based
      datastores.
      16e2fd49
    • David Douard's avatar
      Make 'swh db init' fill the dbversion table · 7e07b1f3
      David Douard authored
      for this feature to work properly, the backend datastore package must
      provide the 'get_datastore' factory function in its root namespace and
      the datastore instance must provide a 'get_current_version()' method.
      
      This also means the canonical cli usage for the `swh db init` is now
      using the config file (via `--config-file` or `SWH_CONFIG_FILENAME`)
      instead of giving only the db cnx string (`--db-name`), so that the
      backend datastore class can be instanciated using the `get_datastore()`
      factory function.
      
      However a '--initial-version' cli option has been added to 'swh db init'
      to make it easier, especially for unit tests.
      7e07b1f3
    • David Douard's avatar
      Use a standard postgresql db fixture in test_cli · f8a07dfa
      David Douard authored
      instead of a custom 'test_db' (which did not truncate dbversion and
      origin tables, not sure what the intent was for this).
      f8a07dfa
    • David Douard's avatar
      Add support for dbversion and dbmodule handling in swh db init · c4bd270c
      David Douard authored
      for now, managing the dbversion table (storing the db schema upgrade
      history) is partially the responsibility of the swh modules implementing
      a datastore (swh-storage etc.), and the actual swh module was not stored
      in the database.
      
      This adds support for both the dbversion and dbmodule tables management
      in swh.core.db.
      
      The `swh db init` command now creates both these tables and initialize
      their values if possible.
      For this, it introduces a new common "API" for swh.core.db based datastores:
      
      - a swh module implementing a datastore is expected to have a
        `get_datastore` function in its top namespace; this function is
        typically the actual `get_storage`, `get_scheduler` etc. functions
      - this factory function is expected to use the "postgresql" cls for the
        datastore based on swh.core.db,
      - the datastore instance (eg. instance of the swh.storage.postgresql.Storage
        class) is expected to have a `get_current_version()` method (returning
        an int).
      
      This revision also provides a new `swh db version` command displaying
      the current (code) version (if available), the db version (possibly the whole
      version history) and flavor (if any) for the datastore given as argument.
      
      It should be backward compatible with existing swh datastore modules (i.e.
      not yet adapted to this new API).
      c4bd270c
  7. Feb 11, 2022
  8. Feb 10, 2022
  9. Feb 04, 2022
  10. Jan 20, 2022
  11. Jan 17, 2022
  12. Jan 14, 2022
  13. Dec 16, 2021
  14. Dec 02, 2021
  15. Dec 01, 2021
  16. Nov 25, 2021
  17. Nov 08, 2021
  18. Sep 17, 2021
  19. Sep 15, 2021
  20. Aug 30, 2021
  21. Aug 25, 2021
Loading