Changeset View
Changeset View
Standalone View
Standalone View
swh/icinga_plugins/tests/test_deposit.py
# Copyright (C) 2019-2021 The Software Heritage developers | # Copyright (C) 2019-2022 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import io | import io | ||||
import os | import os | ||||
import tarfile | import tarfile | ||||
import time | import time | ||||
▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | ): | ||||
scenario.add_step( | scenario.add_step( | ||||
"get", f"{BASE_URL}/testcol/42/status/", status_xml, | "get", f"{BASE_URL}/testcol/42/status/", status_xml, | ||||
) | ) | ||||
scenario.install_mock(requests_mock) | scenario.install_mock(requests_mock) | ||||
result = invoke( | result = invoke( | ||||
[ | [ | ||||
"--prometheus-exporter", | |||||
"--prometheus-exporter-directory", | |||||
"/tmp", | |||||
"check-deposit", | "check-deposit", | ||||
*COMMON_OPTIONS, | *COMMON_OPTIONS, | ||||
"single", | "single", | ||||
"--archive", | "--archive", | ||||
sample_archive, | sample_archive, | ||||
"--metadata", | "--metadata", | ||||
sample_metadata, | sample_metadata, | ||||
] | ] | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | ): | ||||
scenario.add_step( | scenario.add_step( | ||||
"get", f"{BASE_URL}/testcol/42/status/", status_xml, | "get", f"{BASE_URL}/testcol/42/status/", status_xml, | ||||
) | ) | ||||
scenario.install_mock(requests_mock) | scenario.install_mock(requests_mock) | ||||
result = invoke( | result = invoke( | ||||
[ | [ | ||||
"--prometheus-exporter", | |||||
"--prometheus-exporter-directory", | |||||
"/tmp", | |||||
"check-deposit", | "check-deposit", | ||||
*COMMON_OPTIONS, | *COMMON_OPTIONS, | ||||
"single", | "single", | ||||
"--archive", | "--archive", | ||||
sample_archive, | sample_archive, | ||||
"--metadata", | "--metadata", | ||||
sample_metadata, | sample_metadata, | ||||
] | ] | ||||
Show All 40 Lines | ): | ||||
) | ) | ||||
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.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) | scenario.install_mock(requests_mock) | ||||
result = invoke( | result = invoke( | ||||
[ | [ | ||||
"--prometheus-exporter", | |||||
"--prometheus-exporter-directory", | |||||
"/tmp", | |||||
"check-deposit", | "check-deposit", | ||||
*COMMON_OPTIONS, | *COMMON_OPTIONS, | ||||
"single", | "single", | ||||
"--archive", | "--archive", | ||||
sample_archive, | sample_archive, | ||||
"--metadata", | "--metadata", | ||||
sample_metadata, | sample_metadata, | ||||
], | ], | ||||
Show All 31 Lines | ): | ||||
scenario.add_step( | scenario.add_step( | ||||
"get", f"{BASE_URL}/testcol/42/status/", status_template(status="done"), | "get", f"{BASE_URL}/testcol/42/status/", status_template(status="done"), | ||||
) | ) | ||||
scenario.install_mock(requests_mock) | scenario.install_mock(requests_mock) | ||||
result = invoke( | result = invoke( | ||||
[ | [ | ||||
"--prometheus-exporter", | |||||
"--prometheus-exporter-directory", | |||||
"/tmp", | |||||
"--warning", | "--warning", | ||||
"15", | "15", | ||||
"check-deposit", | "check-deposit", | ||||
*COMMON_OPTIONS, | *COMMON_OPTIONS, | ||||
"single", | "single", | ||||
"--archive", | "--archive", | ||||
sample_archive, | sample_archive, | ||||
"--metadata", | "--metadata", | ||||
Show All 31 Lines | ): | ||||
) | ) | ||||
scenario.install_mock(requests_mock) | scenario.install_mock(requests_mock) | ||||
result = invoke( | result = invoke( | ||||
[ | [ | ||||
"--critical", | "--critical", | ||||
"50", | "50", | ||||
"--prometheus-exporter", | |||||
"--prometheus-exporter-directory", | |||||
"/tmp", | |||||
"check-deposit", | "check-deposit", | ||||
*COMMON_OPTIONS, | *COMMON_OPTIONS, | ||||
"single", | "single", | ||||
"--archive", | "--archive", | ||||
sample_archive, | sample_archive, | ||||
"--metadata", | "--metadata", | ||||
sample_metadata, | sample_metadata, | ||||
], | ], | ||||
Show All 33 Lines | scenario.add_step( | ||||
status_template(status="loading"), | status_template(status="loading"), | ||||
callback=lambda: time.sleep(1500), | callback=lambda: time.sleep(1500), | ||||
) | ) | ||||
scenario.install_mock(requests_mock) | scenario.install_mock(requests_mock) | ||||
result = invoke( | result = invoke( | ||||
[ | [ | ||||
"--prometheus-exporter", | |||||
"--prometheus-exporter-directory", | |||||
"/tmp", | |||||
"check-deposit", | "check-deposit", | ||||
*COMMON_OPTIONS, | *COMMON_OPTIONS, | ||||
"single", | "single", | ||||
"--archive", | "--archive", | ||||
sample_archive, | sample_archive, | ||||
"--metadata", | "--metadata", | ||||
sample_metadata, | sample_metadata, | ||||
], | ], | ||||
Show All 23 Lines | scenario.add_step( | ||||
f"{BASE_URL}/testcol/42/status/", | f"{BASE_URL}/testcol/42/status/", | ||||
status_template(status="rejected", status_detail="booo"), | status_template(status="rejected", status_detail="booo"), | ||||
) | ) | ||||
scenario.install_mock(requests_mock) | scenario.install_mock(requests_mock) | ||||
result = invoke( | result = invoke( | ||||
[ | [ | ||||
"--prometheus-exporter", | |||||
"--prometheus-exporter-directory", | |||||
"/tmp", | |||||
"check-deposit", | "check-deposit", | ||||
*COMMON_OPTIONS, | *COMMON_OPTIONS, | ||||
"single", | "single", | ||||
"--archive", | "--archive", | ||||
sample_archive, | sample_archive, | ||||
"--metadata", | "--metadata", | ||||
sample_metadata, | sample_metadata, | ||||
], | ], | ||||
Show All 28 Lines | scenario.add_step( | ||||
f"{BASE_URL}/testcol/42/status/", | f"{BASE_URL}/testcol/42/status/", | ||||
status_template(status="failed", status_detail="booo"), | status_template(status="failed", status_detail="booo"), | ||||
) | ) | ||||
scenario.install_mock(requests_mock) | scenario.install_mock(requests_mock) | ||||
result = invoke( | result = invoke( | ||||
[ | [ | ||||
"--prometheus-exporter", | |||||
"--prometheus-exporter-directory", | |||||
"/tmp", | |||||
"check-deposit", | "check-deposit", | ||||
*COMMON_OPTIONS, | *COMMON_OPTIONS, | ||||
"single", | "single", | ||||
"--archive", | "--archive", | ||||
sample_archive, | sample_archive, | ||||
"--metadata", | "--metadata", | ||||
sample_metadata, | sample_metadata, | ||||
], | ], | ||||
Show All 29 Lines | scenario.add_step( | ||||
f"{BASE_URL}/testcol/42/status/", | f"{BASE_URL}/testcol/42/status/", | ||||
status_template(status="what", status_detail="booo"), | status_template(status="what", status_detail="booo"), | ||||
) | ) | ||||
scenario.install_mock(requests_mock) | scenario.install_mock(requests_mock) | ||||
result = invoke( | result = invoke( | ||||
[ | [ | ||||
"--prometheus-exporter", | |||||
"--prometheus-exporter-directory", | |||||
"/tmp", | |||||
"check-deposit", | "check-deposit", | ||||
*COMMON_OPTIONS, | *COMMON_OPTIONS, | ||||
"single", | "single", | ||||
"--archive", | "--archive", | ||||
sample_archive, | sample_archive, | ||||
"--metadata", | "--metadata", | ||||
sample_metadata, | sample_metadata, | ||||
], | ], | ||||
Show All 11 Lines |