diff --git a/swh/icinga_plugins/deposit.py b/swh/icinga_plugins/deposit.py --- a/swh/icinga_plugins/deposit.py +++ b/swh/icinga_plugins/deposit.py @@ -177,16 +177,13 @@ metadata_objects = requests.get( f"{self.api_url}/api/1/raw-extrinsic-metadata/swhid/{swhid}/" f"?authority=deposit_client%20{self._provider_url}" + f"&after={start_datetime.isoformat()}" ).json() expected_origin = f"{self._provider_url}/{self._slug}" - # Filter out objects that were clearly not created by this deposit (ie. created - # before the deposit started, or that are from unrelated origins) + # Filter out objects that were clearly not created by this deposit relevant_metadata_objects = [ - d - for d in metadata_objects - if d.get("origin") == expected_origin - and datetime.datetime.fromisoformat(d["discovery_date"]) >= start_datetime + d for d in metadata_objects if d.get("origin") == expected_origin ] if not relevant_metadata_objects: self.print_result( diff --git a/swh/icinga_plugins/tests/conftest.py b/swh/icinga_plugins/tests/conftest.py --- a/swh/icinga_plugins/tests/conftest.py +++ b/swh/icinga_plugins/tests/conftest.py @@ -1,16 +1,14 @@ -# Copyright (C) 2019 The Software Heritage developers +# Copyright (C) 2019-2022 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -import time - import pytest @pytest.fixture def mocked_time(mocker): - start_time = time.time() + start_time = 1646413359.0 # 2022-03-04-17:02:39Z time_offset = 0 diff --git a/swh/icinga_plugins/tests/test_deposit.py b/swh/icinga_plugins/tests/test_deposit.py --- a/swh/icinga_plugins/tests/test_deposit.py +++ b/swh/icinga_plugins/tests/test_deposit.py @@ -213,7 +213,8 @@ scenario.add_step( "get", f"{BASE_WEB_URL}/api/1/raw-extrinsic-metadata/swhid/{swhid}/" - f"?authority=deposit_client%20http://icinga-checker.example.org", + f"?authority=deposit_client%20http://icinga-checker.example.org" + f"&after=2022-03-04T17:02:39+00:00", [ { "swhid": swhid, @@ -295,7 +296,8 @@ scenario.add_step( "get", f"{BASE_WEB_URL}/api/1/raw-extrinsic-metadata/swhid/{swhid}/" - f"?authority=deposit_client%20http://icinga-checker.example.org", + f"?authority=deposit_client%20http://icinga-checker.example.org" + f"&after=2022-03-04T17:02:39+00:00", [ { "swhid": swhid, @@ -375,7 +377,8 @@ scenario.add_step( "get", f"{BASE_WEB_URL}/api/1/raw-extrinsic-metadata/swhid/{swhid}/" - f"?authority=deposit_client%20http://icinga-checker.example.org", + f"?authority=deposit_client%20http://icinga-checker.example.org" + f"&after=2022-03-04T17:02:39+00:00", [ { "swhid": swhid, @@ -450,7 +453,8 @@ scenario.add_step( "get", f"{BASE_WEB_URL}/api/1/raw-extrinsic-metadata/swhid/{swhid}/" - f"?authority=deposit_client%20http://icinga-checker.example.org", + f"?authority=deposit_client%20http://icinga-checker.example.org" + f"&after=2022-03-04T17:02:39+00:00", [ { "swhid": swhid, @@ -516,7 +520,8 @@ scenario.add_step( "get", f"{BASE_WEB_URL}/api/1/raw-extrinsic-metadata/swhid/{swhid}/" - f"?authority=deposit_client%20http://icinga-checker.example.org", + f"?authority=deposit_client%20http://icinga-checker.example.org" + f"&after=2022-03-04T17:02:39+00:00", [ { "swhid": swhid, @@ -633,18 +638,12 @@ "discovery_date": "2999-03-03T10:48:47+00:00", "metadata_url": f"{BASE_WEB_URL}/the-metadata-url", }, - { - # Filtered out, because too old - "swhid": swhid, - "origin": origin, - "discovery_date": "2022-03-03T09:48:47+00:00", - "metadata_url": f"{BASE_WEB_URL}/the-metadata-url", - }, ] scenario.add_step( "get", f"{BASE_WEB_URL}/api/1/raw-extrinsic-metadata/swhid/{swhid}/" - f"?authority=deposit_client%20http://icinga-checker.example.org", + f"?authority=deposit_client%20http://icinga-checker.example.org" + f"&after=2022-03-04T17:02:39+00:00", metadata_list, ) @@ -706,7 +705,8 @@ scenario.add_step( "get", f"{BASE_WEB_URL}/api/1/raw-extrinsic-metadata/swhid/{swhid}/" - f"?authority=deposit_client%20http://icinga-checker.example.org", + f"?authority=deposit_client%20http://icinga-checker.example.org" + f"&after=2022-03-04T17:02:39+00:00", metadata_list, ) scenario.add_step(