requests_mock = <requests_mock.mocker.Mocker object at 0x7fbee11a1080>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fbee11a1ef0>
sample_archive = '/tmp/pytest-of-jenkins/pytest-0/swh.icinga_plugins.tests.test_deposit0/archive.tar.gz'
sample_metadata = '/tmp/pytest-of-jenkins/pytest-0/swh.icinga_plugins.tests.test_deposit0/metadata.xml'
mocked_time = None
def test_deposit_then_metadata_update_failed(
requests_mock, mocker, sample_archive, sample_metadata, mocked_time
):
"""Deposit creation passed, deposit metadata update failed
"""
scenario = WebScenario()
scenario.add_step(
"post", f"{BASE_URL}/testcol/", ENTRY_TEMPLATE.format(status="deposited")
)
scenario.add_step(
"get", f"{BASE_URL}/testcol/42/status/", status_template(status="verified"),
)
scenario.add_step(
"get", f"{BASE_URL}/testcol/42/status/", status_template(status="loading"),
)
scenario.add_step(
"get", f"{BASE_URL}/testcol/42/status/", status_template(status="done"),
)
# Then metadata update calls
failed_status_xml = status_template(
status="failed", # lying here
status_detail="Failure to ingest",
swhid="swh:1:dir:02ed6084fb0e8384ac58980e07548a547431cf74",
)
scenario.add_step("get", f"{BASE_URL}/testcol/42/status/", failed_status_xml)
scenario.add_step("get", f"{BASE_URL}/testcol/42/status/", failed_status_xml)
scenario.install_mock(requests_mock)
result = invoke(
[
"--prometheus-exporter",
"--prometheus-exporter-directory",
"/tmp",
"check-deposit",
*COMMON_OPTIONS,
"single",
"--archive",
sample_archive,
"--metadata",
sample_metadata,
],
catch_exceptions=True,
)
> assert result.output == (
"DEPOSIT OK - Deposit took 30.00s and succeeded.\n"
"| 'load_time' = 20.00s\n"
"| 'total_time' = 30.00s\n"
"| 'upload_time' = 0.00s\n"
"| 'validation_time' = 10.00s\n"
"DEPOSIT CRITICAL - Deposit Metadata update failed: You can only update "
"metadata on deposit with status 'done' \n"
"| 'total_time' = 30.00s\n"
"| 'update_time' = 0.00s\n"
)
E assert '' == "DEPOSIT OK -...me' = 0.00s\n"
E - DEPOSIT OK - Deposit took 30.00s and succeeded.
E - | 'load_time' = 20.00s
E - | 'total_time' = 30.00s
E - | 'upload_time' = 0.00s
E - | 'validation_time' = 10.00s
E - DEPOSIT CRITICAL - Deposit Metadata update failed: You can only update metadata on deposit with status 'done'
E - | 'total_time' = 30.00s...
E
E ...Full output truncated (2 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/icinga_plugins/tests/test_deposit.py:349: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Jan 12 2022, 3:17 PM