diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/pendingack/PendingAckPersistentTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/pendingack/PendingAckPersistentTest.java index 2ef8b8f68eee3..1eb04ca1ccf0c 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/pendingack/PendingAckPersistentTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/pendingack/PendingAckPersistentTest.java @@ -460,7 +460,9 @@ public void testDeleteUselessLogDataWhenSubCursorMoved() throws Exception { Message message2 = consumer.receive(5, TimeUnit.SECONDS); consumer.acknowledgeAsync(message2.getMessageId(), transaction2).get(); - Assert.assertEquals(pendingAckLogIndex.size(), 0); + Awaitility.await().untilAsserted(() -> { + Assert.assertEquals(pendingAckLogIndex.size(), 0); + }); maxIndexLag = (long) field4.get(pendingAckStore); Assert.assertEquals(maxIndexLag, 5); }