Yunyung commented on code in PR #20319:
URL: https://github.com/apache/kafka/pull/20319#discussion_r2264592086


##########
tools/src/test/java/org/apache/kafka/tools/reassign/ReassignPartitionsUnitTest.java:
##########
@@ -436,29 +437,50 @@ public void testGenerateAssignmentWithFewerBrokers() 
throws Exception {
 
     @Test
     public void testCurrentPartitionReplicaAssignmentToString() throws 
Exception {
-        Map<TopicPartition, List<Integer>> proposedParts = new HashMap<>();
-
-        proposedParts.put(new TopicPartition("foo", 1), List.of(1, 2, 3));
-        proposedParts.put(new TopicPartition("bar", 0), List.of(7, 8, 9));
-
-        Map<TopicPartition, List<Integer>> currentParts = new HashMap<>();
-
-        currentParts.put(new TopicPartition("foo", 0), List.of(1, 2, 3));
-        currentParts.put(new TopicPartition("foo", 1), List.of(4, 5, 6));
-        currentParts.put(new TopicPartition("bar", 0), List.of(7, 8));
-        currentParts.put(new TopicPartition("baz", 0), List.of(10, 11, 12));
+        try (MockAdminClient adminClient = new MockAdminClient.Builder()
+                .numBrokers(6)
+                .brokerLogDirs(List.of(
+                    List.of("/tmp/broker0/logs"),
+                    List.of("/tmp/broker1/logs"),
+                    List.of("/tmp/broker2/logs"),
+                    List.of("/tmp/broker3/logs"),
+                    List.of("/tmp/broker4/logs"),
+                    List.of("/tmp/broker5/logs")
+                ))
+                .build()
+        ) {
+
+            List<Node> brokers = adminClient.brokers();
+            adminClient.addTopic(false, "foo", List.of(
+                new TopicPartitionInfo(1, brokers.get(1),
+                    List.of(brokers.get(1), brokers.get(2), brokers.get(3)),
+                    List.of(brokers.get(1), brokers.get(2), brokers.get(3)))
+            ), Map.of());
+
+            adminClient.addTopic(false, "bar", List.of(
+                new TopicPartitionInfo(0, brokers.get(4),
+                    List.of(brokers.get(4), brokers.get(5)),
+                    List.of(brokers.get(4), brokers.get(5)))
+            ), Map.of());
+
+            Map<TopicPartition, List<Integer>> proposedParts = new HashMap<>();
+            proposedParts.put(new TopicPartition("foo", 1), List.of(0, 1, 2));
+            proposedParts.put(new TopicPartition("bar", 0), List.of(3, 4, 5));
+
+            Map<TopicPartition, List<Integer>> currentParts = new HashMap<>();
+            currentParts.put(new TopicPartition("foo", 1), List.of(1, 2, 3));
+            currentParts.put(new TopicPartition("bar", 0), List.of(4, 5));
 
-        assertEquals(String.join(System.lineSeparator(),
-            "Current partition replica assignment",
-            "",
-            "{\"version\":1,\"partitions\":" +
-                
"[{\"topic\":\"bar\",\"partition\":0,\"replicas\":[7,8],\"log_dirs\":[\"any\",\"any\"]},"
 +
-                
"{\"topic\":\"foo\",\"partition\":1,\"replicas\":[4,5,6],\"log_dirs\":[\"any\",\"any\",\"any\"]}]"
 +
-                "}",
-            "",
-            "Save this to use as the --reassignment-json-file option during 
rollback"),
-            currentPartitionReplicaAssignmentToString(proposedParts, 
currentParts)
-        );
+            assertEquals(String.join(System.lineSeparator(),
+                "Current partition replica assignment",
+                "",
+                
"{\"version\":1,\"partitions\":[{\"topic\":\"bar\",\"partition\":0,\"replicas\":[4,5],\"log_dirs\":[\"/tmp/broker4/logs\",\"/tmp/broker4/logs\"]},"
 +
+                    
"{\"topic\":\"foo\",\"partition\":1,\"replicas\":[1,2,3],\"log_dirs\":[\"any\",\"any\",\"any\"]}]}",

Review Comment:
   It's fine for me right now, it's MockAdminClient's issue. I'll track this. 
Thanks.



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