Skip to content

test: Deflake Redis RQ metadata timestamp test with a controlled clock - #2200

Open
vdusek wants to merge 1 commit into
masterfrom
test/fix-flaky-redis-rq-metadata
Open

test: Deflake Redis RQ metadata timestamp test with a controlled clock#2200
vdusek wants to merge 1 commit into
masterfrom
test/fix-flaky-redis-rq-metadata

Conversation

@vdusek

@vdusek vdusek commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

test_metadata_file_updates in tests/unit/storage_clients/_redis/test_redis_rq_client.py failed on Windows / Python 3.12 with assert accessed_at > accessed_at on identical timestamps (run).

The Redis is_empty() never stamps accessed_at, and get_metadata() reads the record before stamping its own access. The two values the test compared were therefore the stamps of two back-to-back get_metadata() calls (the fixture's purge check and the test's first call), about a millisecond apart, with the asyncio.sleep(0.01) sitting after both. On Windows before Python 3.13, datetime.now() ticks at 1–15.6 ms, so the stamps collide.

The test now drives the mixin's clock through a Mock, uses a read the Redis client does treat as an access (fetch_next_request()), and asserts the exact stamps – no sleeps, no wall clock. Removing the accessed_at update from fetch_next_request() makes it fail, so it still guards the behaviour.

Locally, quantizing the mixin clock to 15.625 ms ticks reproduced the failure 18/20 times (2/40 at 1 ms); the new test passes 20/20 and 40/40 under the same clocks, and the Redis test directory passes 20/20 with -n auto.

Note: is_empty() bumps accessed_at in the memory and file-system clients but not in the Redis one. Left as is here; worth deciding separately whether that's intended.

✍️ Drafted by Claude Code

@vdusek vdusek added t-tooling Issues with this label are in the ownership of the tooling team. adhoc Ad-hoc unplanned task added during the sprint. labels Aug 28, 2026
@vdusek vdusek self-assigned this Aug 28, 2026
@github-actions github-actions Bot added this to the 148th sprint - Tooling team milestone Aug 28, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label Aug 28, 2026
@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.73%. Comparing base (8524e23) to head (45ae24a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2200      +/-   ##
==========================================
+ Coverage   93.72%   93.73%   +0.01%     
==========================================
  Files         181      181              
  Lines       12825    12825              
==========================================
+ Hits        12020    12022       +2     
+ Misses        805      803       -2     
Flag Coverage Δ
unit 93.73% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@vdusek
vdusek requested review from Mantisus and Pijukatel August 28, 2026 11:47
@vdusek
vdusek marked this pull request as ready for review August 28, 2026 11:48

@Mantisus Mantisus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants