This is an automated email from the ASF dual-hosted git repository.

dinglei pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new 1e69e3904f Fix flaky test testSemiSyncReplicaWhenAdaptiveDegradation 
(#7631)
1e69e3904f is described below

commit 1e69e3904f20820c9f78971680f99bb7ddcd69ce
Author: rongtong <jinrongto...@163.com>
AuthorDate: Tue Dec 12 14:17:24 2023 +0800

    Fix flaky test testSemiSyncReplicaWhenAdaptiveDegradation (#7631)
---
 store/src/test/java/org/apache/rocketmq/store/HATest.java | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/store/src/test/java/org/apache/rocketmq/store/HATest.java 
b/store/src/test/java/org/apache/rocketmq/store/HATest.java
index 38a0435817..5623adb64f 100644
--- a/store/src/test/java/org/apache/rocketmq/store/HATest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/HATest.java
@@ -213,12 +213,15 @@ public class HATest {
             assertEquals(PutMessageStatus.PUT_OK, 
result.getPutMessageStatus());
             //message has been replicated to slave's commitLog, but maybe not 
dispatch to ConsumeQueue yet
             //so direct read from commitLog by physical offset
-            MessageExt slaveMsg = 
slaveMessageStore.lookMessageByOffset(result.getAppendMessageResult().getWroteOffset());
-            assertNotNull(slaveMsg);
-            assertArrayEquals(msg.getBody(), slaveMsg.getBody());
-            assertEquals(msg.getTopic(), slaveMsg.getTopic());
-            assertEquals(msg.getTags(), slaveMsg.getTags());
-            assertEquals(msg.getKeys(), slaveMsg.getKeys());
+            final MessageExt[] slaveMsg = {null};
+            await().atMost(Duration.ofSeconds(3)).until(() -> {
+                slaveMsg[0] = 
slaveMessageStore.lookMessageByOffset(result.getAppendMessageResult().getWroteOffset());
+                return slaveMsg[0] != null;
+            });
+            assertArrayEquals(msg.getBody(), slaveMsg[0].getBody());
+            assertEquals(msg.getTopic(), slaveMsg[0].getTopic());
+            assertEquals(msg.getTags(), slaveMsg[0].getTags());
+            assertEquals(msg.getKeys(), slaveMsg[0].getKeys());
         }
 
         //shutdown slave, putMessage should return IN_SYNC_REPLICAS_NOT_ENOUGH

Reply via email to