mirror of
https://github.com/apache/rocketmq.git
synced 2026-09-24 16:04:00 +08:00
[ISSUE #3741] Use wait-until-${async-complete}-reaches DSL instead of sleep(n) to to reduce invalid wait time. (#3829)
This commit is contained in:
@@ -24,6 +24,7 @@ import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -39,6 +40,9 @@ import org.apache.rocketmq.store.PutMessageStatus;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
public class DLedgerCommitlogTest extends MessageStoreTestBase {
|
||||
|
||||
|
||||
@@ -330,10 +334,9 @@ public class DLedgerCommitlogTest extends MessageStoreTestBase {
|
||||
|
||||
|
||||
DefaultMessageStore followerStore = createDledgerMessageStore(createBaseDir(), group, "n1", peers, "n0", false, 0);
|
||||
Thread.sleep(10000);
|
||||
await().atMost(10, SECONDS).until(followerCatchesUp(followerStore, topic));
|
||||
|
||||
Assert.assertEquals(1, leaderStore.getMaxOffsetInQueue(topic, 0));
|
||||
Assert.assertEquals(1, followerStore.getMaxOffsetInQueue(topic, 0));
|
||||
Assert.assertTrue(leaderStore.getCommitLog().getMaxOffset() > 0);
|
||||
|
||||
|
||||
@@ -364,10 +367,9 @@ public class DLedgerCommitlogTest extends MessageStoreTestBase {
|
||||
|
||||
|
||||
DefaultMessageStore followerStore = createDledgerMessageStore(createBaseDir(), group, "n1", peers, "n0", false, 0);
|
||||
Thread.sleep(10000);
|
||||
await().atMost(10, SECONDS).until(followerCatchesUp(followerStore, topic));
|
||||
|
||||
Assert.assertEquals(1, leaderStore.getMaxOffsetInQueue(topic, 0));
|
||||
Assert.assertEquals(1, followerStore.getMaxOffsetInQueue(topic, 0));
|
||||
Assert.assertTrue(leaderStore.getCommitLog().getMaxOffset() > 0);
|
||||
|
||||
|
||||
@@ -378,5 +380,7 @@ public class DLedgerCommitlogTest extends MessageStoreTestBase {
|
||||
followerStore.shutdown();
|
||||
}
|
||||
|
||||
|
||||
private Callable<Boolean> followerCatchesUp(DefaultMessageStore followerStore, String topic) {
|
||||
return () -> followerStore.getMaxOffsetInQueue(topic, 0) == 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user