fix(ci): use fresh relative ts in conductor-snapshot tests (fixes #2550, unblocks core gate) #2551

Merged
core-be merged 1 commits from fix/ops-scripts-snapshot-frozen-ts-2550 into main 2026-06-10 18:44:39 +00:00
2 changed files with 24 additions and 4 deletions
+14 -2
View File
@@ -1789,8 +1789,20 @@ import os
import tempfile
def _make_snapshot(prs, ts="2026-06-10T12:00:00Z"):
return {"ts": ts, "repo": "molecule-ai/molecule-core", "prs": prs}
def _fresh_ts():
# Conductor snapshots are only honored within a 10-minute freshness window
# (load_conductor_snapshot in gitea-merge-queue.py). A frozen literal ts
# goes stale the moment wall-clock passes that window, silently dropping the
# snapshot and self-fetching -> empty OWNER/NAME -> "/repos///" crash. Default
# to NOW so the snapshot is fresh whenever the suite runs. Tests that want a
# STALE snapshot pass ts= explicitly (test_load_conductor_snapshot_ignores_stale_snapshot).
from datetime import datetime, timezone
return datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
def _make_snapshot(prs, ts=None):
return {"ts": ts if ts is not None else _fresh_ts(),
"repo": "molecule-ai/molecule-core", "prs": prs}
def test_list_candidate_issues_uses_snapshot_when_present(monkeypatch):
+10 -2
View File
@@ -175,6 +175,14 @@ def test_reap_preserves_failed_pr_context_without_push_success(monkeypatch):
import os
import tempfile
from datetime import datetime, timezone
def _fresh_ts():
# See test_gitea_merge_queue._fresh_ts: snapshots are only honored within a
# 10-minute freshness window; a frozen literal ts goes stale and triggers a
# self-fetch -> "/repos///" crash. Default to NOW.
return datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
def test_get_combined_status_uses_snapshot_when_sha_matches(monkeypatch):
@@ -183,7 +191,7 @@ def test_get_combined_status_uses_snapshot_when_sha_matches(monkeypatch):
mod = load_reaper()
head_sha = "a" * 40
snapshot = {
"ts": "2026-06-10T12:00:00Z",
"ts": _fresh_ts(),
"repo": "molecule-ai/molecule-core",
"prs": [
{
@@ -217,7 +225,7 @@ def test_get_combined_status_self_fetches_when_sha_not_in_snapshot(monkeypatch):
"""If the SHA is not in the snapshot, get_combined_status falls back to API."""
mod = load_reaper()
snapshot = {
"ts": "2026-06-10T12:00:00Z",
"ts": _fresh_ts(),
"repo": "molecule-ai/molecule-core",
"prs": [
{"number": 1, "head_sha": "b" * 40, "labels": [],