test(openlineage): Make test_ordering deterministic instead of sleeping - #6791
Draft
nikolauspschuetz wants to merge 1 commit into
Draft
Conversation
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>
Contributor
Author
|
/kind housekeeping |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TestGetRuns::test_orderingasserts the most recently upserted run sorts first.get_runs()orders byupdated_at, which each upsert stamps asint(time.time() * 1000)— millisecond resolution, with no secondary sort key. The test slepttime.sleep(0.01)between the two upserts sor2's timestamp would exceedr1'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, andr1sorts 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
OpenLineageStoreSQL: with a same-millisecond clock the old test returnsr1(reproduces the flake); with the injected clock it returnsr2on 200/200 runs.Release note: NONE
Developed with AI assistance (Claude Code); I directed, reviewed, and verified it locally.