requests_mock = <requests_mock.mocker.Mocker object at 0x7fbee0fbb518>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fbee0fbb6d8>
mocked_time = None, origin_info = ('hg', 'mock://fake-origin-url/6')
def test_save_code_now_success(requests_mock, mocker, mocked_time, origin_info):
"""Successful ingestion scenario below threshold"""
scenario = WebScenario()
visit_type, origin = origin_info
root_api_url = "mock://swh-web.example.org"
api_url = SaveCodeNowCheck.api_url_scn(root_api_url, origin, visit_type)
# creation request
scenario.add_step(
"post",
api_url,
fake_response(origin, visit_type, "accepted", "not yet scheduled"),
)
response_scheduled = fake_response(origin, visit_type, "accepted", "scheduled")
# status polling requests
scenario.add_step("get", api_url, [response_scheduled])
# sometimes we can have multiple response so we fake that here
scenario.add_step("get", api_url, [response_scheduled, response_scheduled])
scenario.add_step(
"get", api_url, [fake_response(origin, visit_type, "accepted", "succeeded")]
)
scenario.install_mock(requests_mock)
# fmt: off
result = invoke(
[
"--prometheus-exporter",
"--prometheus-exporter-directory", "/tmp",
"check-savecodenow", "--swh-web-url", root_api_url,
"origin", origin,
> "--visit-type", visit_type,
]
)
.tox/py3/lib/python3.7/site-packages/swh/icinga_plugins/tests/test_save_code_now.py:83:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/icinga_plugins/tests/utils.py:19: in invoke
raise result.exception
.tox/py3/lib/python3.7/site-packages/click/testing.py:408: in invoke
return_value = cli.main(args=args or (), prog_name=prog_name, **extra)
.tox/py3/lib/python3.7/site-packages/click/core.py:1053: in main
rv = self.invoke(ctx)
.tox/py3/lib/python3.7/site-packages/click/core.py:1659: in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
.tox/py3/lib/python3.7/site-packages/click/core.py:1659: in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
.tox/py3/lib/python3.7/site-packages/click/core.py:1395: in invoke
return ctx.invoke(self.callback, **ctx.params)
.tox/py3/lib/python3.7/site-packages/click/core.py:754: in invoke
return __callback(*args, **kwargs)
.tox/py3/lib/python3.7/site-packages/click/decorators.py:26: in new_func
return f(get_current_context(), *args, **kwargs)
.tox/py3/lib/python3.7/site-packages/swh/icinga_plugins/cli.py:107: in check_scn_origin
sys.exit(SaveCodeNowCheck(ctx.obj, origin, visit_type).main())
.tox/py3/lib/python3.7/site-packages/swh/icinga_plugins/save_code_now.py:30: in __init__
self.register_prometheus_gauge("duration", "seconds", ["status"])
.tox/py3/lib/python3.7/site-packages/swh/icinga_plugins/base_check.py:109: in register_prometheus_gauge
labelnames=self._get_label_names(labels),
.tox/py3/lib/python3.7/site-packages/prometheus_client/metrics.py:363: in __init__
_labelvalues=_labelvalues,
.tox/py3/lib/python3.7/site-packages/prometheus_client/metrics.py:136: in __init__
registry.register(self)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <prometheus_client.registry.CollectorRegistry object at 0x7fbee1b64e10>
collector = prometheus_client.metrics.Gauge(swh_e2e_duration_seconds)
def register(self, collector):
"""Add a collector to the registry."""
with self._lock:
names = self._get_names(collector)
duplicates = set(self._names_to_collectors).intersection(names)
if duplicates:
raise ValueError(
'Duplicated timeseries in CollectorRegistry: {0}'.format(
> duplicates))
E ValueError: Duplicated timeseries in CollectorRegistry: {'swh_e2e_duration_seconds'}
.tox/py3/lib/python3.7/site-packages/prometheus_client/registry.py:31: ValueError
TEST RESULT
TEST RESULT
- Run At
- Jan 12 2022, 3:17 PM