Page MenuHomeSoftware Heritage

cli.db: Use attribute current_version instead of undeclared getter
ClosedPublic

Authored by ardumont on May 30 2022, 4:43 PM.

Details

Summary

I have no idea why both exist. But this centralized one (current_version) is declared on
most swh modules vs the other method which is not [2]

[1]

$SWH_ENVIRONMENT_HOME/swh-indexer/swh/indexer/storage/db.py:    current_version = 133
$SWH_ENVIRONMENT_HOME/swh-scheduler/swh/scheduler/backend.py:    current_version = 33
$SWH_ENVIRONMENT_HOME/swh-scrubber/swh/scrubber/db.py:    current_version = 2
$SWH_ENVIRONMENT_HOME/swh-storage/swh/storage/postgresql/db.py:    current_version = 182
$SWH_ENVIRONMENT_HOME/swh-vault/swh/vault/backend.py:    current_version = 4

[2]

grep -r "get_current_version(" $SWH_ENVIRONMENT_HOME/*/swh/
$SWH_ENVIRONMENT_HOME/swh-indexer/swh/indexer/storage/__init__.py:    def get_current_version(self, *, db=None, cur=None):
$SWH_ENVIRONMENT_HOME/swh-scheduler/swh/scheduler/backend.py:    def get_current_version(self):
$SWH_ENVIRONMENT_HOME/swh-storage/swh/storage/postgresql/storage.py:    def get_current_version(self, *, db: Db, cur=None):

Related to T4284
Supersedes D7906

Test Plan

Patched on scrubber0.staging and now the cli works! [1]

[1]

swhworker@scrubber0:~$ swh db --config-file config.yml version scrubber
module: scrubber
current code version: 2
version: 1

Diff Detail

Unit TestsFailed

TimeTest
884 msJenkins > .tox.py3-core-db-server-github-slow-cover.lib.python3.7.site-packages.swh.core.db.tests.test_cli::test_cli_swh_db_create_and_init_db_new_api
cli_runner = <click.testing.CliRunner object at 0x7f9b0dfb1630> postgresql = <connection object at 0x7f9b10c0f408; dsn: 'user=postgres password=xxx dbname=tests host=127.0.0.1 port=18610 options=''', closed: 0> mock_import_swhmodule = <function mock_import_swhmodule.<locals>.import_swhmodule_mock at 0x7f9b0dfeb6a8>
739 msJenkins > .tox.py3-core-db-server-github-slow-cover.lib.python3.7.site-packages.swh.core.db.tests.test_cli::test_cli_swh_db_upgrade_new_api
cli_runner = <click.testing.CliRunner object at 0x7f9b0dfc9d68> postgresql = <connection object at 0x7f9b1163d188; dsn: 'user=postgres password=xxx dbname=tests host=127.0.0.1 port=18610 options=''', closed: 0> datadir = '/var/lib/jenkins/workspace/DCORE/tests-on-diff/.tox/py3-core-db-server-github-slow-cover/lib/python3.7/site-packages/swh/core/db/tests/data'
1 msJenkins > .tox.py3-core-db-server-github-slow-cover.lib.python3.7.site-packages.swh.core.api.tests.test_async::test_async_decode_data_empty_cases[None]
1 msJenkins > .tox.py3-core-db-server-github-slow-cover.lib.python3.7.site-packages.swh.core.api.tests.test_async::test_async_decode_data_empty_cases[]
1 msJenkins > .tox.py3-core-db-server-github-slow-cover.lib.python3.7.site-packages.swh.core.api.tests.test_async::test_async_decode_data_empty_cases[data2]
View Full Test Results (2 Failed · 296 Passed · 1 Skipped)

Event Timeline

Build has FAILED

Patch application report for D7907 (id=28511)

Rebasing onto f18016af5c...

Current branch diff-target is up to date.
Changes applied before test
commit c52516feac901aa72cce833bdd9d06ebb01bfd52
Author: Antoine R. Dumont (@ardumont) <antoine.romain.dumont@gmail.com>
Date:   Mon May 30 16:14:06 2022 +0200

    cli.db: Use attribute current_version instead of undeclared getter
    
    Related to T4284

Link to build: https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/430/
See console output for more information: https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/430/console

Harbormaster returned this revision to the author for changes because remote builds failed.May 30 2022, 4:45 PM
Harbormaster failed remote builds in B29601: Diff 28511!

Build is green

Patch application report for D7907 (id=28513)

Rebasing onto f18016af5c...

Current branch diff-target is up to date.
Changes applied before test
commit 5cda0ca626010cccc7e7f3f73fbfb1b20702ac40
Author: Antoine R. Dumont (@ardumont) <antoine.romain.dumont@gmail.com>
Date:   Mon May 30 16:14:06 2022 +0200

    cli.db: Use attribute current_version instead of undeclared getter
    
    Related to T4284

See https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/431/ for more details.

This revision is now accepted and ready to land.May 30 2022, 5:04 PM