tmpdir = local('/tmp/pytest-of-jenkins/pytest-0/test_load_and_check_config_emp0')
config = {'client_max_size': '10', 'objstorage': {'args': {}, 'cls': 'memory'}}
@pytest.mark.parametrize(
"config",
[
pytest.param(
{
"objstorage": {
"cls": "pathslicing",
"args": {"root": "root", "slicing": "slicing"},
}
},
id="pathslicing-bw-compat",
),
pytest.param(
{
"objstorage": {
"cls": "pathslicing",
"root": "root",
"slicing": "slicing",
}
},
id="pathslicing",
),
pytest.param(
{"client_max_size": "10", "objstorage": {"cls": "memory", "args": {}}},
id="empty-args-bw-compat",
),
pytest.param(
{"client_max_size": "10", "objstorage": {"cls": "memory"}}, id="empty-args"
),
],
)
def test_load_and_check_config(tmpdir, config):
"""pathslicing configuration fine loads ok"""
config_path = prepare_config_file(tmpdir, config)
> cfg = load_and_check_config(config_path)
.tox/py3/lib/python3.7/site-packages/swh/objstorage/tests/test_server.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/objstorage/api/server.py:217: in load_and_check_config
return validate_config(cfg)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cfg = {'client_max_size': '10', 'objstorage': {'args': {}, 'cls': 'memory'}}
def validate_config(cfg):
"""Check the minimal configuration is set to run the api or raise an
explanatory error.
Args:
cfg (dict): Loaded configuration.
Raises:
Error if the setup is not as expected
Returns:
configuration as a dict
"""
if "objstorage" not in cfg:
raise KeyError("Invalid configuration; missing objstorage config entry")
missing_keys = []
vcfg = cfg["objstorage"]
if "cls" not in vcfg:
raise KeyError("Invalid configuration; missing cls config entry")
cls = vcfg["cls"]
if cls == "pathslicing":
# Backwards-compatibility: either get the deprecated `args` from the
# objstorage config, or use the full config itself to check for keys
args = vcfg.get("args", vcfg)
for key in ("root", "slicing"):
v = args.get(key)
if v is None:
missing_keys.append(key)
if missing_keys:
raise KeyError(
"Invalid configuration; missing %s config entry"
% (", ".join(missing_keys),)
)
elif cls in ["memory", "noop"]:
raise EnvironmentError(
> "Memory or Noop implementation are not production objstorage."
)
E OSError: Memory or Noop implementation are not production objstorage.
.tox/py3/lib/python3.7/site-packages/swh/objstorage/api/server.py:260: OSError
TEST RESULT
TEST RESULT
- Run At
- Oct 25 2021, 5:26 PM