Page MenuHomeSoftware Heritage

D8162.id29479.diff
No OneTemporary

D8162.id29479.diff

diff --git a/swh/vault/api/server.py b/swh/vault/api/server.py
--- a/swh/vault/api/server.py
+++ b/swh/vault/api/server.py
@@ -61,15 +61,16 @@
def check_config(cfg: Dict[str, Any]) -> Dict[str, Any]:
- """Ensure the configuration is ok to run a local vault server, and propagate defaults.
+ """Ensure the configuration is ok to run a postgresql vault server, and propagate
+ defaults.
Raises:
- EnvironmentError if the configuration is not for local instance
+ EnvironmentError if the configuration is not for postgresql instance
ValueError if one of the following keys is missing: vault, cache, storage,
scheduler
Returns:
- New configuration dict to instantiate a local vault server instance.
+ New configuration dict to instantiate a postgresql vault server instance.
"""
cfg = cfg.copy()
@@ -78,9 +79,9 @@
raise ValueError("missing 'vault' configuration")
vcfg = cfg["vault"]
- if vcfg["cls"] != "local":
+ if vcfg["cls"] not in ("local", "postgresql"):
raise EnvironmentError(
- "The vault backend can only be started with a 'local' configuration",
+ "The vault backend can only be started with a 'postgresql' configuration",
)
# TODO: Soft-deprecation of args key. Remove when ready.
diff --git a/swh/vault/tests/test_server.py b/swh/vault/tests/test_server.py
--- a/swh/vault/tests/test_server.py
+++ b/swh/vault/tests/test_server.py
@@ -22,7 +22,7 @@
"""Returns a vault server configuration, with ``storage``, ``scheduler`` and
``cache`` set at the toplevel"""
return {
- "vault": {"cls": "local", "db": swh_vault_config["db"]},
+ "vault": {"cls": "postgresql", "db": swh_vault_config["db"]},
"client_max_size": 1024**3,
**{k: v for k, v in swh_vault_config.items() if k != "db"},
}
@@ -160,14 +160,17 @@
def test_check_config_not_local() -> None:
"""Wrong configuration raises"""
expected_error = (
- "The vault backend can only be started with a 'local' configuration"
+ "The vault backend can only be started with a 'postgresql' configuration"
)
with pytest.raises(EnvironmentError, match=expected_error):
check_config({"vault": {"cls": "remote"}})
-def test_check_config_ok(swh_vault_server_config) -> None:
+@pytest.mark.parametrize("clazz", ["local", "postgresql"])
+def test_check_config_ok(swh_vault_server_config, clazz) -> None:
"""Check that the default config is accepted"""
+ config = swh_vault_server_config.copy()
+ config["vault"]["cls"] = clazz
assert check_config(swh_vault_server_config) is not None

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 3, 3:50 PM (2 w, 12 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3218698

Event Timeline