Skip to content

ATLAS-5204: fix flaky test InMemoryAuditRepositoryTest.testDeleteEventsV2()#515

Open
mneethiraj wants to merge 1 commit intoapache:masterfrom
mneethiraj:ATLAS-5204
Open

ATLAS-5204: fix flaky test InMemoryAuditRepositoryTest.testDeleteEventsV2()#515
mneethiraj wants to merge 1 commit intoapache:masterfrom
mneethiraj:ATLAS-5204

Conversation

@mneethiraj
Copy link
Contributor

What changes were proposed in this pull request?

  • added safer time offset to ensure TTL based deletes pick all appropriate events, resulting in consistent test run

How was this patch tested?

  • verified the fix by running the test multiple time in an environment where it used to fail few time

Copy link

Copilot AI left a 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 now timestamp 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 now for the “latest” event timestamp instead of calling System.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
Copy link

Copilot AI Feb 8, 2026

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.

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Feb 8, 2026

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

Suggested change
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

Copilot uses AI. Check for mistakes.
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