From 55f2558702a8dc0ea9052b6f4b4b14d974c05c11 Mon Sep 17 00:00:00 2001 From: Alex Cottner <148472676+alexcottner@users.noreply.github.com> Date: Fri, 20 Dec 2024 08:08:55 -0700 Subject: [PATCH] Fixing telescope push timestamp check (#1523) * Fixing telescope push timestamp check * Updated tests for future us --- checks/remotesettings/push_timestamp.py | 4 ++++ tests/checks/remotesettings/test_push_timestamp.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/checks/remotesettings/push_timestamp.py b/checks/remotesettings/push_timestamp.py index 0cf20de7..f7e78cb9 100644 --- a/checks/remotesettings/push_timestamp.py +++ b/checks/remotesettings/push_timestamp.py @@ -43,6 +43,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"]] 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}, ] }, )