Skip to content
Snippets Groups Projects
  1. Apr 26, 2022
  2. Apr 25, 2022
  3. Apr 21, 2022
  4. Apr 15, 2022
    • Nicolas Dandrimont's avatar
      sentry: always override init settings with the environment variables · c1b2e937
      Nicolas Dandrimont authored
      Instead of only overriding the initial settings when they're left unset,
      always override the defaults when the environment variables are set.
      
      This makes the behavior more consistent with the way we usually handle
      environment variables. It also allows setting the environment variable
      `SWH_SENTRY_DISABLE_LOGGING_EVENTS=false`, to enable events based on the
      logging framework in gunicorn backends (where the default has been
      flipped to true).
      c1b2e937
    • Nicolas Dandrimont's avatar
      cli: Ensure tests don't mess with the global logging setup · 151a2f95
      Nicolas Dandrimont authored
      Notably, using logging.config.dictConfig disables all loggers before
      setting its own config. There's no simple way of undoing these changes
      to the logging config.
      
      Even if we had a way to reset a basic logging config, pytest reuses its
      log handler instances across tests, so it's not even that simple to be
      able to reset the logging config from scratch and still have pytest able
      to capture logs.
      
      Instead of any of that, just add a fixture to reset the root logger
      level, and to mock logging.config.dictConfig so that it doesn't actually
      get called.
      151a2f95
  5. Apr 14, 2022
  6. Apr 08, 2022
  7. Apr 06, 2022
  8. Mar 30, 2022
  9. Mar 29, 2022
  10. Mar 23, 2022
    • Antoine Lambert's avatar
      pytest: Exclude build directory for tests discovery · ba5a6ef5
      Antoine Lambert authored
      Due to test modules being copied in subdirectories of the
      build directory by setuptools, it makes pytest fail by raising
      ImportPathMismatchError exceptions when invoked from root
      directory of the module.
      
      So ignore the build folder to discover tests.
      ba5a6ef5
  11. Mar 14, 2022
  12. Mar 09, 2022
  13. Mar 03, 2022
  14. Mar 02, 2022
  15. Mar 01, 2022
  16. 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
  17. 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
  18. Feb 11, 2022
Loading