jsancio commented on code in PR #16563:
URL: https://github.com/apache/kafka/pull/16563#discussion_r1672284614


##########
raft/src/test/java/org/apache/kafka/raft/RaftClientTestContext.java:
##########
@@ -576,6 +577,10 @@ void assertSentDescribeQuorumResponse(
             partitionData,
             nodes
         );
+
+        List<ReplicaState> sortedVoters = 
response.topics().get(0).partitions().get(0).currentVoters().stream().sorted(Comparator.comparingInt(ReplicaState::replicaId)).collect(Collectors.toList());
+        
response.topics().get(0).partitions().get(0).setCurrentVoters(sortedVoters);

Review Comment:
   Let try to split this over a few lines. I am okay with this formatting:
   ```java
           List<ReplicaState> sortedVoters = response
               .topics()
               .get(0)
               .partitions()
               .get(0)
               .currentVoters()
               .stream()
               .sorted(Comparator.comparingInt(ReplicaState::replicaId))
               .collect(Collectors.toList());
           
response.topics().get(0).partitions().get(0).setCurrentVoters(sortedVoters);
   ```



##########
raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java:
##########
@@ -3854,4 +3859,13 @@ private static ReplicaKey replicaKey(int id, boolean 
withDirectoryId) {
         Uuid directoryId = withDirectoryId ? Uuid.randomUuid() : 
ReplicaKey.NO_DIRECTORY_ID;
         return ReplicaKey.of(id, directoryId);
     }
+
+    private static Integer getRandomPort() {
+        int minPort = 1024;
+        int mockAddressPrefix = 9990;
+        // Number of nodes we can set up if we got a random number that is 
maximum in the range
+        int reservedNumberOfPorts = 50;
+        int maxPort = 65535 - mockAddressPrefix - reservedNumberOfPorts;
+        return ThreadLocalRandom.current().nextInt((maxPort - minPort) + 1) + 
minPort;
+    }

Review Comment:
   Node ids are positive int32 including 0. Did you mean to name this method 
`randomReplicaId`?



##########
raft/src/test/java/org/apache/kafka/raft/RaftClientTestContext.java:
##########
@@ -1233,7 +1238,7 @@ static void verifyLeaderChangeMessage(
         LeaderChangeMessage leaderChangeMessage = 
ControlRecordUtils.deserializeLeaderChangeMessage(recordValue);
         assertEquals(leaderId, leaderChangeMessage.leaderId());
         assertEquals(voters.stream().map(voterId -> new 
Voter().setVoterId(voterId)).collect(Collectors.toList()),
-            leaderChangeMessage.voters());
+            
leaderChangeMessage.voters().stream().sorted(Comparator.comparingInt(Voter::voterId)).collect(Collectors.toList()));

Review Comment:
   Same here let's fix the formatting a bit. How about:
   ```java
           assertEquals(
               voters.stream().map(voterId -> new Voter().setVoterId(voterId)),
               
leaderChangeMessage.voters().stream().sorted(Comparator.comparingInt(Voter::voterId))
           );
   ```



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to