Skip to content

Commit 7323dca

Browse files
committed
Fix git-source lag logics
1 parent d5ff051 commit 7323dca

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

checks/remotesettings/git_reader_commit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from telescope import config
88
from telescope.typings import CheckResult
9-
from telescope.utils import fetch_json, utcfromisoformat, utcnow
9+
from telescope.utils import fetch_json, utcfromisoformat
1010

1111

1212
EXPOSED_PARAMETERS = ["server", "repo", "lag_margin_seconds"]
@@ -32,12 +32,13 @@ async def run(
3232
server_info = await fetch_json(server + "/")
3333
git_info = server_info["git"]["common"]
3434
source_commit = git_info["id"]
35+
commit_datetime = git_info["datetime"]
3536

3637
latest_sha = details["commit"]["sha"]
3738
latest_datetime = details["commit"]["commit"]["author"]["date"]
3839

3940
is_recent = (
40-
utcnow() - utcfromisoformat(latest_datetime)
41+
utcfromisoformat(latest_datetime) - utcfromisoformat(commit_datetime)
4142
).total_seconds() < lag_margin_seconds
4243

4344
return (

tests/checks/remotesettings/test_git_reader_commit.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ async def test_positive_latency(mock_aioresponses):
7878
"common": {
7979
# Different source commit.
8080
"id": "7a50f5506e0a3e4a28e6761645da6e3e1276a5cc", # pragma: allowlist secret
81+
# Latest commit date is within lag margin.
8182
"datetime": "2025-02-25T18:02:02Z",
8283
}
8384
},
@@ -90,12 +91,7 @@ async def test_positive_latency(mock_aioresponses):
9091
payload=GITHUB_EXAMPLE_COMMIT,
9192
)
9293

93-
# Less than 30min after commit was made.
94-
fake_now = datetime(2025, 2, 25, 18, 30, 0, tzinfo=timezone.utc)
95-
with mock.patch(
96-
"checks.remotesettings.git_reader_commit.utcnow", return_value=fake_now
97-
):
98-
status, data = await run(server=url, repo="mozilla/remote-settings-data")
94+
status, data = await run(server=url, repo="mozilla/remote-settings-data")
9995

10096
assert status is True
10197
assert (
@@ -123,7 +119,7 @@ async def test_negative(mock_aioresponses):
123119
"common": {
124120
# Different source commit.
125121
"id": "7a50f5506e0a3e4a28e6761645da6e3e1276a5cc", # pragma: allowlist secret
126-
"datetime": "2025-02-25T18:02:02Z",
122+
"datetime": "2025-02-25T17:02:02Z",
127123
}
128124
},
129125
},
@@ -147,7 +143,7 @@ async def test_negative(mock_aioresponses):
147143
},
148144
"source_commit": {
149145
"sha": "7a50f5506e0a3e4a28e6761645da6e3e1276a5cc", # pragma: allowlist secret
150-
"date": "2025-02-25T18:02:02Z",
146+
"date": "2025-02-25T17:02:02Z",
151147
},
152148
}
153149
)

0 commit comments

Comments
 (0)