You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ratis.apache.org by GitBox <gi...@apache.org> on 2020/11/03 14:17:13 UTC

[GitHub] [incubator-ratis] szetszwo commented on a change in pull request #248: RATIS-1127. Add a stream(RaftGroupId) method to DataStreamApi.

szetszwo commented on a change in pull request #248:
URL: https://github.com/apache/incubator-ratis/pull/248#discussion_r515760843



##########
File path: ratis-test/src/test/java/org/apache/ratis/datastream/DataStreamBaseTest.java
##########
@@ -371,23 +397,24 @@ private void runTestDataStream(DataStreamOutputImpl out, int bufferSize, int buf
       Assert.assertEquals(sizes.get(i).longValue(), reply.getBytesWritten());
       Assert.assertEquals(reply.getType(), Type.STREAM_DATA);
     }
-
-    final RaftClientRequest header = out.getHeader();
-    for (MultiDataStreamStateMachine s : stateMachines.values()) {
-      final SingleDataStream stream = s.getSingleDataStream(header.getCallId());
-      if (stream == null) {
-        continue;
-      }
-      final RaftClientRequest writeRequest = stream.getWriteRequest();
-      if (writeRequest.getClientId().equals(header.getClientId())) {
-        Assert.assertEquals(writeRequest.getCallId(), header.getCallId());
-        Assert.assertEquals(writeRequest.getRaftGroupId(), header.getRaftGroupId());
-        Assert.assertEquals(writeRequest.getServerId(), header.getServerId());
-      }
-      Assert.assertEquals(dataSize, stream.getByteWritten());
+    try {
+      assertHeader(out.getHeader(), dataSize);
+    } catch (Throwable e) {
+      throw new CompletionException(e);
     }
   }
 
+  void assertHeader(RaftClientRequest header, int dataSize) throws Exception {
+    final Server server = servers.get(0);

Review comment:
       > By doing so, this test no longer test all server's written bytes directly.
   
   Do you mean that it checks only the first server instead of a loop?
   
   I found that the loop is not useful since the callId is unique.  Only the first server can match the callId.  Thus, only it will be tested.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org