From 7ce1283b8f821d89948f6bff8824e2ed9d135c09 Mon Sep 17 00:00:00 2001 From: Alex Cottner Date: Thu, 19 Dec 2024 14:30:50 -0700 Subject: [PATCH 1/3] Fixing telescope push timestamp check --- checks/remotesettings/push_timestamp.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/checks/remotesettings/push_timestamp.py b/checks/remotesettings/push_timestamp.py index 0cf20de7..5f3be2a6 100644 --- a/checks/remotesettings/push_timestamp.py +++ b/checks/remotesettings/push_timestamp.py @@ -10,8 +10,10 @@ import websockets +from operator import attrgetter from telescope.typings import CheckResult from telescope.utils import utcfromtimestamp, utcnow +from datetime import datetime from .utils import KintoClient @@ -43,6 +45,10 @@ async def get_push_timestamp(uri) -> str: async def get_remotesettings_timestamp(uri) -> str: client = KintoClient(server_url=uri) entries = await client.get_monitor_changes(bust_cache=True) + + # sort by timestamp desc as the records are returned by bucket/collection + entries.sort(key=lambda e: e["last_modified"], reverse=True) + # Some collections are excluded (eg. preview) # https://github.com/mozilla-services/cloudops-deployment/blob/master/projects/kinto/puppet/modules/kinto/templates/kinto.ini.erb matched = [e for e in entries if "preview" not in e["bucket"]] From ca5ca891c8ad2c649409d9c5fd43053bf91a2315 Mon Sep 17 00:00:00 2001 From: Alex Cottner Date: Thu, 19 Dec 2024 14:34:07 -0700 Subject: [PATCH 2/3] Fixing formatting --- checks/remotesettings/push_timestamp.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/checks/remotesettings/push_timestamp.py b/checks/remotesettings/push_timestamp.py index 5f3be2a6..f7e78cb9 100644 --- a/checks/remotesettings/push_timestamp.py +++ b/checks/remotesettings/push_timestamp.py @@ -10,10 +10,8 @@ import websockets -from operator import attrgetter from telescope.typings import CheckResult from telescope.utils import utcfromtimestamp, utcnow -from datetime import datetime from .utils import KintoClient From 1187952307a7145ff4acb98a6cd2e00e2b64725f Mon Sep 17 00:00:00 2001 From: Alex Cottner Date: Thu, 19 Dec 2024 14:38:55 -0700 Subject: [PATCH 3/3] Updated tests for future us --- tests/checks/remotesettings/test_push_timestamp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/checks/remotesettings/test_push_timestamp.py b/tests/checks/remotesettings/test_push_timestamp.py index df361a8f..98d6ca88 100644 --- a/tests/checks/remotesettings/test_push_timestamp.py +++ b/tests/checks/remotesettings/test_push_timestamp.py @@ -18,7 +18,8 @@ async def test_positive(mock_responses): payload={ "changes": [ {"id": "a", "bucket": "main-preview", "last_modified": 2000000000000}, - {"id": "b", "bucket": "main", "last_modified": 1573086234731}, + {"id": "b", "bucket": "main", "last_modified": 1273086234731}, + {"id": "c", "bucket": "main", "last_modified": 1573086234731}, ] }, )