szetszwo commented on code in PR #1296:
URL: https://github.com/apache/ratis/pull/1296#discussion_r2417400119


##########
ratis-examples/src/test/java/org/apache/ratis/examples/counter/TestCounter.java:
##########
@@ -59,4 +63,40 @@ public void testSeveralCounter(MiniRaftCluster cluster) 
throws IOException, Inte
       Assertions.assertEquals(30, 
reply3.getMessage().getContent().asReadOnlyByteBuffer().getInt());
     }
   }
+
+  @ParameterizedTest
+  @MethodSource("data")
+  public void testSeveralCounterFromFollower(MiniRaftCluster cluster) throws 
IOException, InterruptedException {
+    setAndStart(cluster);
+
+    List<RaftServer.Division> followers = cluster.getFollowers();
+    Assertions.assertEquals(2, followers.size());
+    final RaftPeerId f0 = followers.get(0).getId();
+    final RaftServer.Division d1 = cluster.getDivision(f0);
+
+    Message queryMessage = Message.valueOf("GET");
+
+    try (final RaftClient client = cluster.createClient()) {
+      for (int i = 0; i < 10; i++) {
+        client.io().send(Message.valueOf("INCREMENT"));
+      }
+      RaftClientReply reply1 = client.io().sendReadOnly(queryMessage);
+      Assertions.assertEquals(10,  getCounterInt(reply1.getMessage()));
+      boolean isFollowerUptoDate = d1.okForLocalReadBounded(1000, 100);
+      // Clients can choose to query from local StateMachine or leader

Review Comment:
   > Client need to build the RaftServer first.
   
   Client builds a new server?  How would it work?  The Follower is already 
running.  The server built by the client will be different from the Follower.  
Could you show it in the test?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to