Skip to content

Fix flaky DefaultAcknowledgementSetManagerTests#6720

Merged
dlvenable merged 1 commit into
opensearch-project:mainfrom
lawofcycles:fix/flaky-default-ack-set-manager-test
May 5, 2026
Merged

Fix flaky DefaultAcknowledgementSetManagerTests#6720
dlvenable merged 1 commit into
opensearch-project:mainfrom
lawofcycles:fix/flaky-default-ack-set-manager-test

Conversation

@lawofcycles

@lawofcycles lawofcycles commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Description

Fix flaky DefaultAcknowledgementSetManagerTests.testExpirations() that intermittently fails with AssertionError: Expected: <0> but: was <1>.

The test asserts that the acknowledgement set monitor size is 0 immediately after a Thread.sleep(), assuming the cleanup thread has already removed the expired set. Under CI load, the cleanup may not have completed in time. The subsequent await() block only checks the result field, not the monitor size, so the stale size is never retried.

This change moves the getSize() == 0 assertion into the await().untilAsserted() block so both conditions are polled together.

CI impact

This fix targets Gradle Build / build workflow (gradle.yml), specifically DefaultAcknowledgementSetManagerTests.testExpirations() in :data-prepper-core:test.

Local verification (10 consecutive runs each):
The race condition is difficult to reproduce with the default TEST_TIMEOUT (400ms) on a local machine. To amplify it, the Thread.sleep in testExpirations was temporarily hardcoded to 20ms (instead of TEST_TIMEOUT * 2 = 800ms), reducing the margin for the cleanup thread to near zero.

  • Before fix (getSize assertion outside await): 0/10 passed
  • After fix (getSize assertion inside await): 10/10 passed

Issues Resolved

Resolves #6719

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Move the monitor size assertion into the await().untilAsserted() block.
The assertion was placed after Thread.sleep() but before await(),
assuming the cleanup thread had already run. Under CI load, the cleanup
may not have completed in time, causing intermittent failures.

Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
@lawofcycles

Copy link
Copy Markdown
Contributor Author

@dlvenable dlvenable merged commit f559a52 into opensearch-project:main May 5, 2026
71 of 72 checks passed
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.

[BUG] Flaky DefaultAcknowledgementSetManagerTests

3 participants