-
Notifications
You must be signed in to change notification settings - Fork 899
ATLAS-5204: fix flaky test InMemoryAuditRepositoryTest.testDeleteEventsV2() #515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Stabilizes testDeleteEventsV2() by adding a safety time buffer around the TTL cutoff to avoid boundary-condition flakes in TTL-based deletions.
Changes:
- Capture a single
nowtimestamp and use it consistently within the test. - Subtract an additional buffer (5 minutes) from the computed “old event” timestamp to ensure events fall clearly outside TTL.
- Reuse
nowfor the “latest” event timestamp instead of callingSystem.currentTimeMillis()again.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| int ttlInDays = 1; | ||
| long ts = System.currentTimeMillis() - (ttlInDays * DateUtils.MILLIS_PER_DAY); | ||
| long now = System.currentTimeMillis(); | ||
| long bufferMs = 5 * DateUtils.MILLIS_PER_MINUTE; // buffer to avoid failure in TTL based delete in env with faster/lightly-loaded env |
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 5 * DateUtils.MILLIS_PER_MINUTE is a magic number in the test. Consider extracting it into a clearly named constant (e.g., TTL_DELETE_BUFFER_MS) and/or adding a brief reason that’s more specific (e.g., handling timestamp rounding/truncation or cutoff equality) so future readers know why “5 minutes” is required.
| int ttlInDays = 1; | ||
| long ts = System.currentTimeMillis() - (ttlInDays * DateUtils.MILLIS_PER_DAY); | ||
| long now = System.currentTimeMillis(); | ||
| long bufferMs = 5 * DateUtils.MILLIS_PER_MINUTE; // buffer to avoid failure in TTL based delete in env with faster/lightly-loaded env |
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline comment is a bit unclear/grammatically awkward (“in env with faster/lightly-loaded env”). Consider rephrasing to something like: “Buffer to avoid TTL cutoff edge cases due to time truncation/rounding or timing granularity across environments.”
| long bufferMs = 5 * DateUtils.MILLIS_PER_MINUTE; // buffer to avoid failure in TTL based delete in env with faster/lightly-loaded env | |
| long bufferMs = 5 * DateUtils.MILLIS_PER_MINUTE; // buffer to avoid TTL cutoff edge cases due to time truncation/rounding or timing granularity across environments |
What changes were proposed in this pull request?
How was this patch tested?