Skip to content

fix: Fix Flaky StreamAppenderatorTest assertions on Windows #20602 - #20626

Open
Nimish2098 wants to merge 1 commit into
apache:masterfrom
Nimish2098:fix-stream-appenderator-test
Open

Nimish2098 wants to merge 1 commit into
apache:masterfrom
Nimish2098:fix-stream-appenderator-test

Conversation

@Nimish2098

Copy link
Copy Markdown

Fixes #20602

Description

Fixed a flaky test in StreamAppenderatorTest where persistTimeMillis() and mergeTimeMillis() could occasionally evaluate to 0 in extremely fast execution environments, causing assertion failures. Updated the assertions from > 0 to >= 0.

Fixed the bug ...

Renamed the class ...

Added a forbidden-apis entry ...


Key changed/added classes in this PR
  • StreamAppenderatorTest

This PR has:

  • been self-reviewed.
  • using the concurrency checklist (Remove this item if the PR doesn't have any relation to concurrency.)
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

FrankChen021

This comment was marked as outdated.

@FrankChen021 FrankChen021 changed the title Fix Flaky StreamAppenderatorTest assertions on Windows #20602 fix: Fix Flaky StreamAppenderatorTest assertions on Windows #20602 Oct 17, 2026
Assertions.assertEquals(2, segmentGenerationMetrics.numPersists());
Assertions.assertEquals(3, segmentGenerationMetrics.rowOutput());
Assertions.assertTrue(segmentGenerationMetrics.persistTimeMillis() > 0);
Assertions.assertTrue(segmentGenerationMetrics.persistTimeMillis() >= 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the change. Updating the condition to use >= solves the flakiness problem, but it changes the semantics of the test case that persistTimeMillis should be updated.

The root cause here is: incrementPersistTimeMillis adds a millisecond value rounded down on every persist, so persists under 1 ms count as 0.

A better fix is(although the change is a little bit broader):

  • SegmentGenerationMetrics: store persist time in nanoseconds, add persistTimeNanos(), and have persistTimeMillis() convert from nanoseconds.
  • StreamAppenderator / BatchAppenderator: pass nanoseconds.
  • TaskRealtimeMetricsMonitor: subtract in nanoseconds, then convert.
  • Test: assert persistTimeNanos() > 0 and metrics.persistTimeMillis() == metrics.persistTimeNanos() / 1000_000

PR title and description should also be updated to reflect the change

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.

Flaky test: StreamAppenderatorTest.testSimpleIngestion

2 participants