From 208eb6cf9662884557a1e28309adcf560b6c3040 Mon Sep 17 00:00:00 2001 From: Nikolaus Schuetz Date: Thu, 27 Aug 2026 15:03:33 -0400 Subject: [PATCH] test(openlineage): Make test_ordering deterministic instead of sleeping get_runs orders by updated_at, stamped as int(time.time() * 1000) -- millisecond resolution with no secondary sort key. The test slept 0.01s so r2's timestamp would exceed r1's, but on a coarse-clock platform both upserts can land in the same millisecond; the tie then falls back to insertion order and r1 sorts first, so the assertion flakes. Inject a monotonic clock in the test so each upsert gets a strictly increasing timestamp -- no sleep, fully deterministic. Signed-off-by: Nikolaus Schuetz --- sdk/python/tests/unit/openlineage/test_store.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sdk/python/tests/unit/openlineage/test_store.py b/sdk/python/tests/unit/openlineage/test_store.py index 66ffb9cd325..329bd739778 100644 --- a/sdk/python/tests/unit/openlineage/test_store.py +++ b/sdk/python/tests/unit/openlineage/test_store.py @@ -269,10 +269,18 @@ def test_limit_and_offset(self, store): runs = store.get_runs(limit=10, offset=3) assert len(runs) == 2 - def test_ordering(self, store): + def test_ordering(self, store, monkeypatch): + # updated_at has millisecond resolution and get_runs orders by it with no + # tiebreaker, so give each upsert a distinct, increasing timestamp instead + # of sleeping and hoping the wall clock advances a millisecond. + import itertools + + from feast.openlineage import store as store_module + + counter = itertools.count(1_000_000) + monkeypatch.setattr(store_module.time, "time", lambda: next(counter) / 1000) store.upsert_job("ns", "j1", {"facets": {}}) store.upsert_run("r1", "ns", "j1", "START") - time.sleep(0.01) store.upsert_run("r2", "ns", "j1", "COMPLETE") runs = store.get_runs() assert runs[0]["run_id"] == "r2"