diff --git a/swh/storage/backfill.py b/swh/storage/backfill.py --- a/swh/storage/backfill.py +++ b/swh/storage/backfill.py @@ -572,7 +572,10 @@ " provided: %s" % (",".join(missing_keys),) ) - if "cls" not in config["storage"] or config["storage"]["cls"] != "local": + if "cls" not in config["storage"] or config["storage"]["cls"] not in ( + "local", + "postgresql", + ): raise ValueError( "swh storage backfiller must be configured to use a local" " (PostgreSQL) storage" diff --git a/swh/storage/migrate_extrinsic_metadata.py b/swh/storage/migrate_extrinsic_metadata.py --- a/swh/storage/migrate_extrinsic_metadata.py +++ b/swh/storage/migrate_extrinsic_metadata.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright (C) 2020 The Software Heritage developers +# Copyright (C) 2020-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -1149,7 +1149,7 @@ steps=[ {"cls": "retry"}, { - "cls": "local", + "cls": "postgresql", "db": storage_dbconn, "objstorage": {"cls": "memory", "args": {}}, }, diff --git a/swh/storage/pytest_plugin.py b/swh/storage/pytest_plugin.py --- a/swh/storage/pytest_plugin.py +++ b/swh/storage/pytest_plugin.py @@ -1,4 +1,4 @@ -# Copyright (C) 2019-2020 The Software Heritage developers +# Copyright (C) 2019-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -29,7 +29,7 @@ """ yield { - "cls": "local", + "cls": "postgresql", "db": swh_storage_postgresql.dsn, "objstorage": {"cls": "memory"}, "check_config": {"check_write": True}, diff --git a/swh/storage/tests/test_backfill.py b/swh/storage/tests/test_backfill.py --- a/swh/storage/tests/test_backfill.py +++ b/swh/storage/tests/test_backfill.py @@ -1,4 +1,4 @@ -# Copyright (C) 2019 The Software Heritage developers +# Copyright (C) 2019-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -29,7 +29,7 @@ "prefix": "swh.tmp_journal.new", "client_id": "swh.journal.client.test", }, - "storage": {"cls": "local", "db": "service=swh-dev"}, + "storage": {"cls": "postgresql", "db": "service=swh-dev"}, } diff --git a/swh/storage/tests/test_init.py b/swh/storage/tests/test_init.py --- a/swh/storage/tests/test_init.py +++ b/swh/storage/tests/test_init.py @@ -1,4 +1,4 @@ -# Copyright (C) 2019 The Software Heritage developers +# Copyright (C) 2019-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -22,7 +22,7 @@ ("remote", client.RemoteStorage, {"url": "url"}), ("memory", InMemoryStorage, {}), ( - "local", + "postgresql", DbStorage, {"db": "postgresql://db", "objstorage": {"cls": "memory"}}, ), @@ -106,7 +106,8 @@ # the "remote" and "pipeline" cases are tested in dedicated test functions below @pytest.mark.parametrize( - "cls,real_class,kwargs", [x for x in STORAGES if x.id not in ("remote", "local")] + "cls,real_class,kwargs", + [x for x in STORAGES if x.id not in ("remote", "local", "postgresql")], ) def test_get_storage_check_config(cls, real_class, kwargs, monkeypatch): """Instantiating an existing storage with check_config should be ok @@ -116,14 +117,15 @@ @patch("swh.storage.postgresql.storage.psycopg2.pool") -def test_get_storage_local_check_config(mock_pool, monkeypatch): +@pytest.mark.parametrize("clazz", ["local", "postgresql"]) +def test_get_storage_local_check_config(mock_pool, monkeypatch, clazz): """Instantiating a local storage with check_config should be ok """ mock_pool.ThreadedConnectionPool.return_value = None check_backend_check_config( monkeypatch, - {"cls": "local", "db": "postgresql://db", "objstorage": {"cls": "memory"}}, + {"cls": clazz, "db": "postgresql://db", "objstorage": {"cls": "memory"}}, backend_storage_cls=DbStorage, ) diff --git a/swh/storage/tests/test_server.py b/swh/storage/tests/test_server.py --- a/swh/storage/tests/test_server.py +++ b/swh/storage/tests/test_server.py @@ -1,4 +1,4 @@ -# Copyright (C) 2019-2020 The Software Heritage developers +# Copyright (C) 2019-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -62,7 +62,7 @@ def test_load_and_check_config_local_config_fine(tmpdir): """'local' complete configuration is fine""" - config = {"storage": {"cls": "local", "db": "db", "objstorage": "something",}} + config = {"storage": {"cls": "postgresql", "db": "db", "objstorage": "something",}} config_path = prepare_config_file(tmpdir, config) cfg = load_and_check_config(config_path) assert cfg == config