int mustRead(int serverIndex) throws InterruptedException {
      final ByteBufferConsensusRequest readRequest = TestUtils.TestRequest.getRequest();

      waitUntilActiveLeaderElectedAndReady();

      final TimeDuration maxTryDuration = TimeDuration.valueOf(3, TimeUnit.MINUTES);
      final TimeDuration waitDuration = TimeDuration.valueOf(1000, TimeUnit.MILLISECONDS);
      final Timestamp start = Timestamp.currentTime();

      DataSet readResp = null;
      while (true) {
        try {
          readResp = readThrough(serverIndex);
          break;
        } catch (RatisReadUnavailableException e) {
          logger.warn("ratis is redoing raft log, shall wait some time: ", e);
          waitDuration.sleep();
        } catch (ConsensusException e) {
          logger.error("unexpected error occurred, may try again: ", e);
          waitDuration.sleep();
        }

        if (start.elapsedTime().compareTo(maxTryDuration) > 0) {
          Assert.fail("max retry duration passed without successful read");
        }
      }

      return ((TestUtils.TestDataSet) readResp).getNumber();
    }
A Mini Raft CLuster Wrapper for Test Env.
iotdb-core/consensus/src/test/java/org/apache/iotdb/consensus/ratis/TestUtils.java