Skip to content

Commit b341a4e

Browse files
committed
Fix flaky DefaultAcknowledgementSetManagerTests.testExpirations
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>
1 parent cf682e7 commit b341a4e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

data-prepper-core/src/test/java/org/opensearch/dataprepper/core/acknowledgements/DefaultAcknowledgementSetManagerTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
@ExtendWith(MockitoExtension.class)
3939
class DefaultAcknowledgementSetManagerTests {
4040
private static final Duration TEST_TIMEOUT = Duration.ofMillis(400);
41-
private static final Duration EXPIRY_TEST_TIMEOUT = Duration.ofMillis(100);
41+
private static final Duration EXPIRY_TEST_TIMEOUT = Duration.ofMillis(400);
4242
private DefaultAcknowledgementSetManager acknowledgementSetManager;
4343
private ScheduledExecutorService callbackExecutor;
4444

@@ -109,10 +109,10 @@ void testBasic() {
109109
@Test
110110
void testExpirations() throws InterruptedException {
111111
eventHandle2.release(true);
112-
Thread.sleep(TEST_TIMEOUT.multipliedBy(2).toMillis());
113-
assertThat(acknowledgementSetManager.getAcknowledgementSetMonitor().getSize(), equalTo(0));
112+
Thread.sleep(20);
114113
await().atMost(TEST_TIMEOUT.multipliedBy(3))
115114
.untilAsserted(() -> {
115+
assertThat(acknowledgementSetManager.getAcknowledgementSetMonitor().getSize(), equalTo(0));
116116
assertThat(result, equalTo(null));
117117
});
118118
}

0 commit comments

Comments
 (0)