You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sh...@apache.org on 2020/06/18 14:43:44 UTC

[incubator-ratis] branch master updated: RATIS-895. Fix Failed UT: runTestRetryOnStateMachineException (#131)

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

shashikant pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git


The following commit(s) were added to refs/heads/master by this push:
     new 81b4b80  RATIS-895. Fix Failed UT: runTestRetryOnStateMachineException (#131)
81b4b80 is described below

commit 81b4b8007590f6bbf3d96b94aa0f5634c04c5652
Author: runzhiwang <51...@users.noreply.github.com>
AuthorDate: Thu Jun 18 22:43:35 2020 +0800

    RATIS-895. Fix Failed UT: runTestRetryOnStateMachineException (#131)
---
 .../ratis/server/impl/RaftStateMachineExceptionTests.java | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/ratis-server/src/test/java/org/apache/ratis/server/impl/RaftStateMachineExceptionTests.java b/ratis-server/src/test/java/org/apache/ratis/server/impl/RaftStateMachineExceptionTests.java
index 329c8a3..04d13a2 100644
--- a/ratis-server/src/test/java/org/apache/ratis/server/impl/RaftStateMachineExceptionTests.java
+++ b/ratis-server/src/test/java/org/apache/ratis/server/impl/RaftStateMachineExceptionTests.java
@@ -30,6 +30,7 @@ import org.apache.ratis.server.raftlog.RaftLog;
 import org.apache.ratis.statemachine.SimpleStateMachine4Testing;
 import org.apache.ratis.statemachine.StateMachine;
 import org.apache.ratis.statemachine.TransactionContext;
+import org.apache.ratis.util.JavaUtils;
 import org.apache.ratis.util.Log4jUtils;
 import org.junit.Assert;
 import org.junit.Test;
@@ -123,15 +124,15 @@ public abstract class RaftStateMachineExceptionTests<CLUSTER extends MiniRaftClu
         Assert.assertNotNull(reply.getStateMachineException());
       }
 
-      long leaderApplied = cluster.getLeader().getState().getLastAppliedIndex();
-      // make sure retry cache has the entry
       for (RaftServerImpl server : cluster.iterateServerImpls()) {
         LOG.info("check server " + server.getId());
-        if (server.getState().getLastAppliedIndex() < leaderApplied) {
-          Thread.sleep(1000);
-        }
-        Assert.assertNotNull(
-                RaftServerTestUtil.getRetryEntry(server, client.getId(), callId));
+
+        JavaUtils.attemptRepeatedly(() -> {
+          Assert.assertNotNull(
+              RaftServerTestUtil.getRetryEntry(server, client.getId(), callId));
+          return null;
+        }, 5, BaseTest.ONE_SECOND, "GetRetryEntry", LOG);
+
         final RaftLog log = server.getState().getLog();
         RaftTestUtil.logEntriesContains(log, oldLastApplied + 1, log.getNextIndex(), message);
       }