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



##########
File path: 
ratis-test/src/test/java/org/apache/ratis/datastream/DataStreamTestUtils.java
##########
@@ -343,10 +343,8 @@ static void assertHeader(RaftServer server, 
RaftClientRequest header, int dataSi
 
   static void assertRaftClientMessage(RaftClientMessage expected, RaftPeerId 
expectedServerId, RaftClientMessage computed) {
     Assert.assertNotNull(computed);
-    Assert.assertEquals(expected.getClientId(), computed.getClientId());

Review comment:
       In the test, we may pass the primary server in the builder.
   ```
   +++ 
b/ratis-test/src/test/java/org/apache/ratis/datastream/DataStreamAsyncClusterTests.java
   @@ -106,8 +106,7 @@ public abstract class 
DataStreamAsyncClusterTests<CLUSTER extends MiniRaftCluste
            .orElseThrow(IllegalStateException::new);
      }
    
   -  ClientId getPrimaryClientId(CLUSTER cluster, RaftClient client) {
   -    RaftPeer primary = client.getPrimaryDataStreamServer();
   +  ClientId getPrimaryClientId(CLUSTER cluster, RaftPeer primary) {
        return cluster.getDivision(primary.getId()).getRaftClient().getId();
      }
    
   @@ -115,8 +114,9 @@ public abstract class 
DataStreamAsyncClusterTests<CLUSTER extends MiniRaftCluste
        final Iterable<RaftServer> servers = 
CollectionUtils.as(cluster.getServers(), s -> s);
        final RaftPeerId leader = cluster.getLeader().getId();
        final List<CompletableFuture<RaftClientReply>> futures = new 
ArrayList<>();
   -    try(RaftClient client = cluster.createClient()) {
   -      ClientId primaryClientId = getPrimaryClientId(cluster, client);
   +    final RaftPeer primaryServer = 
CollectionUtils.random(cluster.getGroup().getPeers());
   +    try(RaftClient client = cluster.createClient(primaryServer)) {
   +      ClientId primaryClientId = getPrimaryClientId(cluster, primaryServer);
          for (int i = 0; i < numStreams; i++) {
            final DataStreamOutputImpl out = (DataStreamOutputImpl) 
client.getDataStreamApi().stream();
            futures.add(CompletableFuture.supplyAsync(() -> 
DataStreamTestUtils.writeAndCloseAndAssertReplies(
   ```




----------------------------------------------------------------
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:
[email protected]


Reply via email to