nizhikov commented on code in PR #14456:
URL: https://github.com/apache/kafka/pull/14456#discussion_r1341576601


##########
tools/src/test/java/org/apache/kafka/tools/reassign/ReassignPartitionsIntegrationTest.java:
##########
@@ -0,0 +1,897 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.tools.reassign;
+
+import kafka.admin.ReassignPartitionsCommand;
+import kafka.cluster.Partition;
+import kafka.log.UnifiedLog;
+import kafka.server.ControllerServer;
+import kafka.server.HostedPartition;
+import kafka.server.IsrChangePropagationConfig;
+import kafka.server.KafkaBroker;
+import kafka.server.KafkaConfig;
+import kafka.server.ZkAlterPartitionManager;
+import kafka.test.ClusterConfig;
+import kafka.test.ClusterGenerator;
+import kafka.test.ClusterInstance;
+import kafka.test.annotation.ClusterTemplate;
+import kafka.test.annotation.Type;
+import kafka.test.junit.ClusterTestExtensions;
+import kafka.test.junit.RaftClusterInvocationContext.RaftClusterInstance;
+import kafka.test.junit.ZkClusterInvocationContext;
+import kafka.utils.TestUtils;
+import org.apache.kafka.clients.admin.Admin;
+import org.apache.kafka.clients.admin.AlterConfigOp;
+import org.apache.kafka.clients.admin.Config;
+import org.apache.kafka.clients.admin.ConfigEntry;
+import org.apache.kafka.clients.admin.DescribeLogDirsResult;
+import org.apache.kafka.clients.admin.NewTopic;
+import org.apache.kafka.clients.consumer.Consumer;
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.TopicPartitionReplica;
+import org.apache.kafka.common.config.ConfigResource;
+import org.apache.kafka.common.security.auth.SecurityProtocol;
+import org.apache.kafka.common.serialization.ByteArrayDeserializer;
+import org.apache.kafka.common.serialization.ByteArraySerializer;
+import org.apache.kafka.common.utils.Time;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.extension.ExtendWith;
+import scala.None$;
+import scala.Option;
+import scala.Tuple2;
+import scala.collection.JavaConverters;
+import scala.collection.Seq;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+
+import static kafka.test.annotation.Type.KRAFT;
+import static kafka.test.annotation.Type.ZK;
+import static 
org.apache.kafka.clients.CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG;
+import static 
org.apache.kafka.clients.producer.ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG;
+import static 
org.apache.kafka.clients.producer.ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG;
+import static org.apache.kafka.server.common.MetadataVersion.IBP_2_7_IV1;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@SuppressWarnings({"ClassDataAbstractionCoupling", "ClassFanOutComplexity"})
+@ExtendWith(value = ClusterTestExtensions.class)
+@Tag("integration")
+@Timeout(300)
+public class ReassignPartitionsIntegrationTest {
+    private static final Map<Integer, String> BROKERS = new HashMap<>();
+
+    private static final Map<String, List<List<Integer>>> TOPICS = new 
HashMap<>();
+
+    private static final Map<Integer, Map<String, Long>> 
UNTHROTTLED_BROKER_CONFIGS;
+
+    static {
+        BROKERS.put(0, "rack0");
+        BROKERS.put(1, "rack0");
+        BROKERS.put(2, "rack1");
+        BROKERS.put(3, "rack1");
+        BROKERS.put(4, "rack1");
+
+        TOPICS.put("foo", Arrays.asList(Arrays.asList(0, 1, 2), 
Arrays.asList(1, 2, 3)));
+        TOPICS.put("bar", Arrays.asList(Arrays.asList(3, 2, 1)));
+        TOPICS.put("baz", Arrays.asList(Arrays.asList(1, 0, 2), 
Arrays.asList(2, 0, 1), Arrays.asList(0, 2, 1)));
+
+        Map<String, Long> brokerConfig = new HashMap<>();
+
+        ReassignPartitionsCommand.brokerLevelThrottles().foreach(throttle -> {
+            brokerConfig.put(throttle, -1L);
+            return null;
+        });
+
+        UNTHROTTLED_BROKER_CONFIGS = IntStream.range(0, 
5).boxed().collect(Collectors.toMap(Function.identity(), brokerId -> 
brokerConfig));
+    }
+
+    private ClusterInstance cluster;
+
+    private Admin adminClient;
+
+    @ClusterTemplate("zkAndKRaft")

Review Comment:
   Hello, @jolshan 
   
   For now, I know the following ways to setup integration test 
   
   * Use scala `QuorumTestHarness` - see existing 
`ReassignPartitionsIntegrationTest.scala`. 
   * Use java annotation `@ClusterTestDefaults` - see 
`DeleteRecordsCommandTest`.
   * Use `@ClusterTemplate` - like I did in 
`ReassignPartitionsIntegrationTest.java` for now. 
   
   I don't know what is the correct way to implement test.
   AFAICU you suggesting to use `QuorumTestHarness` with ParametrizedTest 
annotation. 
   Is this correct?
   
   I had such version of `ReassignPartitionsIntegrationTest.java` but replace 
it with the current version. So it's will be easy to revert to earlier version 
:)
   



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