Skip to content

test(queue): stop the trim rate-limit test racing its own first trim - #473

Merged
sunib merged 1 commit into
mainfrom
fix/fact-stream-trim-test-flake
Nov 4, 2026
Merged

sunib merged 1 commit into
mainfrom
fix/fact-stream-trim-test-flake

Conversation

@sunib

@sunib sunib commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Description

TestRedisFactStream_TrimIsRateLimited no longer fails at random. It failed Unit tests on #471, which doesn't touch this package.

The test uses a 1 ms TTL, and the first publish on a stream runs its trim after its XADD. If more than 1 ms passes between the two, that publish removes its own entry, and the test finds one entry instead of two. A real TTL is minutes long, so this only affects the test.

An opening publish now starts the trim interval, and the test asserts only on the two entries after it. Nothing is asserted about the opening entry, which may or may not survive.

Type of Change

  • Test coverage improvement

Testing

  • task lint and task test pass locally
  • Before: 1 failure in 2,400 runs under CPU load, with the same message as CI
  • With a temporary 5 ms delay before the trim: the old test failed with that same message, and the new test passed all 20 runs
  • After: 12,000 runs under CPU load with -race, no failures
  • The test still catches regressions: it failed all 20 runs with the rate limit removed, and all 20 with the trim time no longer recorded

🤖 Generated with Claude Code

The opening publish trims after its XADD. With a 1 ms TTL, a pause over
1 ms between the two removed the entry the test then counted, about once
in 2,400 runs under load. Let an opening publish start the interval and
assert on the two entries after it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 40 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3782000b-408f-4af0-86ff-5a3c15d44773
Commits

Reviewing files that changed from the base of the PR and between 2686da2 and b873e05.

Files selected for processing: 1
  • internal/queue/fact_stream_redis_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sunib
sunib merged commit fef8956 into main Nov 4, 2026
21 checks passed
@sunib
sunib deleted the fix/fact-stream-trim-test-flake branch November 4, 2026 05:26
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.

1 participant