Skip to content

test(openlineage): Make test_ordering deterministic instead of sleeping - #6791

Draft
nikolauspschuetz wants to merge 1 commit into
feast-dev:masterfrom
nikolauspschuetz:test/openlineage-deterministic-ordering
Draft

test(openlineage): Make test_ordering deterministic instead of sleeping#6791
nikolauspschuetz wants to merge 1 commit into
feast-dev:masterfrom
nikolauspschuetz:test/openlineage-deterministic-ordering

Conversation

@nikolauspschuetz

Copy link
Copy Markdown
Contributor

TestGetRuns::test_ordering asserts the most recently upserted run sorts first. get_runs() orders by updated_at, which each upsert stamps as int(time.time() * 1000) — millisecond resolution, with no secondary sort key. The test slept time.sleep(0.01) between the two upserts so r2's timestamp would exceed r1's.

On a coarse-clock platform (e.g. ~15.6 ms timer granularity) a 10 ms sleep can fail to advance the millisecond, so both runs get the same updated_at, the tie falls back to insertion order, and r1 sorts first — the assertion flakes.

This replaces the sleep with a monotonic clock injected via monkeypatch, so each upsert gets a strictly increasing timestamp deterministically — no wall-clock dependence, no sleep.

Verified against the real OpenLineageStore SQL: with a same-millisecond clock the old test returns r1 (reproduces the flake); with the injected clock it returns r2 on 200/200 runs.

Release note: NONE

Developed with AI assistance (Claude Code); I directed, reviewed, and verified it locally.

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 <nikolauspschuetz@gmail.com>
@nikolauspschuetz

Copy link
Copy Markdown
Contributor Author

/kind housekeeping

@codecov-commenter

codecov-commenter commented Aug 27, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.09%. Comparing base (1f2584d) to head (208eb6c).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #6791   +/-   ##
=======================================
  Coverage   47.08%   47.09%           
=======================================
  Files         419      419           
  Lines       51878    51878           
  Branches     7525     7525           
=======================================
+ Hits        24429    24430    +1     
  Misses      25700    25700           
+ Partials     1749     1748    -1     
Flag Coverage Δ
go-feature-server 30.58% <ø> (ø)
python-unit 48.40% <ø> (+<0.01%) ⬆️
see 1 file with indirect coverage changes

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f2584d...208eb6c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants