requests_mock = <requests_mock.mocker.Mocker object at 0x7fbee10ac4e0>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fbee10aca90>
mocked_time = None, origin_info = ('git', 'mock://fake-origin-url/3')
def test_save_code_now_threshold_exceeded(
requests_mock, mocker, mocked_time, origin_info
):
"""Saving requests exceeding threshold should mention warning in output
"""
scenario = WebScenario()
visit_type, origin = origin_info
root_api_url = "mock://swh-web2.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"),
)
# we'll make the response being in the awaiting status
# beyond 13, this will exceed the threshold
for i in range(13):
waiting_status = random.choice(WAITING_STATUSES)
response_scheduled = fake_response(
origin, visit_type, "accepted", waiting_status
)
scenario.add_step("get", api_url, [response_scheduled])
scenario.install_mock(requests_mock)
# fmt: off
result = invoke(
[
"check-savecodenow",
"--swh-web-url", root_api_url,
"origin", origin,
"--visit-type", visit_type,
],
catch_exceptions=True,
)
# fmt: on
> assert result.output == (
f"{SaveCodeNowCheck.TYPE} CRITICAL - {REPORT_MSG} {origin_info} took "
f"more than 130.00s and has status: {waiting_status}.\n"
f"| 'total_time' = 130.00s\n"
)
E assert '' == "SAVECODENOW ...' = 130.00s\n"
E - SAVECODENOW CRITICAL - Save code now request for origin ('git', 'mock://fake-origin-url/3') took more than 130.00s and has status: scheduled.
E - | 'total_time' = 130.00s
.tox/py3/lib/python3.7/site-packages/swh/icinga_plugins/tests/test_save_code_now.py:220: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Jan 12 2022, 3:17 PM