You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ch...@apache.org on 2026/09/04 21:30:23 UTC

(kafka) branch trunk updated: MINOR: Migrate additional admin integration tests to Java (#23359)

This is an automated email from the ASF dual-hosted git repository.

chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 54a57d7c70e MINOR: Migrate additional admin integration tests to Java (#23359)
54a57d7c70e is described below

commit 54a57d7c70ee7f1811da282fc2adc594f3b55372
Author: YANG-SYUAN CHOU <di...@gmail.com>
AuthorDate: Sat Sep 5 05:30:17 2026 +0800

    MINOR: Migrate additional admin integration tests to Java (#23359)
    
    ## Summary
    
    - Migrate additional admin integration tests from
    `PlaintextAdminIntegrationTest` to Java
    - Move metadata, topic configuration, and log directory tests to
    `AdminMetadataTest`
    - Move create-partitions coverage to `AddPartitionsTest`
    - Reuse `ClusterInstance` test helpers where applicable
    - Remove the corresponding Scala tests and unused imports
    
    ## Testing
    
    - `./gradlew :clients:clients-integration-tests:test --tests
    org.apache.kafka.clients.admin.AdminMetadataTest --tests
    org.apache.kafka.clients.admin.AddPartitionsTest`
    
    Reviewers: Chia-Ping Tsai <ch...@gmail.com>
---
 .../kafka/clients/admin/AddPartitionsTest.java     | 179 +++++++++++
 .../kafka/clients/admin/AdminMetadataTest.java     | 166 ++++++++++
 .../kafka/api/PlaintextAdminIntegrationTest.scala  | 350 +--------------------
 3 files changed, 346 insertions(+), 349 deletions(-)

diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AddPartitionsTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AddPartitionsTest.java
index 2b8b1563381..bf7e6065606 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AddPartitionsTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AddPartitionsTest.java
@@ -18,7 +18,9 @@ package org.apache.kafka.clients.admin;
 
 import org.apache.kafka.common.Node;
 import org.apache.kafka.common.TopicPartitionInfo;
+import org.apache.kafka.common.errors.InvalidPartitionsException;
 import org.apache.kafka.common.errors.InvalidReplicaAssignmentException;
+import org.apache.kafka.common.errors.UnknownTopicOrPartitionException;
 import org.apache.kafka.common.test.AdminUtils;
 import org.apache.kafka.common.test.ClusterInstance;
 import org.apache.kafka.common.test.api.ClusterTest;
@@ -210,4 +212,181 @@ public class AddPartitionsTest {
             }
         }
     }
+
+    @ClusterTest(brokers = 3)
+    public void testCreatePartitions(ClusterInstance cluster) throws Exception {
+        try (Admin admin = cluster.admin()) {
+            String topic1 = "create-partitions-topic-1";
+            String topic2 = "create-partitions-topic-2";
+            admin.createTopics(List.of(
+                    new NewTopic(topic1, 1, (short) 1),
+                    new NewTopic(topic2, 1, (short) 2))).all().get();
+            cluster.waitTopicCreation(topic1, 1);
+            cluster.waitTopicCreation(topic2, 1);
+            assertEquals(1, numPartitions(admin, topic1));
+            assertEquals(1, numPartitions(admin, topic2));
+
+            CreatePartitionsOptions validateOnly = new CreatePartitionsOptions().validateOnly(true);
+            CreatePartitionsOptions actuallyDoIt = new CreatePartitionsOptions().validateOnly(false);
+
+            admin.createPartitions(Map.of(topic1, NewPartitions.increaseTo(3)), validateOnly)
+                    .values().get(topic1).get();
+            cluster.waitTopicCreation(topic1, 1);
+
+            admin.createPartitions(Map.of(topic1, NewPartitions.increaseTo(3)), actuallyDoIt)
+                    .values().get(topic1).get();
+            cluster.waitTopicCreation(topic1, 3);
+
+            List<Integer> brokerIds = cluster.brokerIds().stream().sorted().toList();
+            List<List<Integer>> newPartition2Assignments = List.of(
+                    List.of(brokerIds.get(0), brokerIds.get(1)),
+                    List.of(brokerIds.get(1), brokerIds.get(2)));
+            admin.createPartitions(Map.of(topic2,
+                    NewPartitions.increaseTo(3, newPartition2Assignments)), validateOnly)
+                    .values().get(topic2).get();
+            cluster.waitTopicCreation(topic2, 1);
+
+            admin.createPartitions(Map.of(topic2,
+                    NewPartitions.increaseTo(3, newPartition2Assignments)), actuallyDoIt)
+                    .values().get(topic2).get();
+            cluster.waitTopicCreation(topic2, 3);
+
+            List<TopicPartitionInfo> actualPartitions2 = partitions(admin, topic2);
+            assertEquals(3, actualPartitions2.size());
+            assertEquals(newPartition2Assignments.get(0), replicaIds(actualPartitions2.get(1)));
+            assertEquals(newPartition2Assignments.get(1), replicaIds(actualPartitions2.get(2)));
+
+            int firstBrokerId = brokerIds.get(0);
+            int secondBrokerId = brokerIds.get(1);
+            int thirdBrokerId = brokerIds.get(2);
+            int unknownBrokerId = brokerIds.get(brokerIds.size() - 1) + 1;
+            for (CreatePartitionsOptions option : List.of(validateOnly, actuallyDoIt)) {
+                assertCreatePartitionsFailure(admin, option, topic1,
+                        NewPartitions.increaseTo(1),
+                        InvalidPartitionsException.class,
+                        "The topic create-partitions-topic-1 currently has 3 partition(s); " +
+                                "1 would not be an increase.",
+                        3);
+                assertCreatePartitionsFailure(admin, option, topic2,
+                        NewPartitions.increaseTo(3),
+                        InvalidPartitionsException.class,
+                        "Topic already has 3 partition(s).",
+                        3);
+                assertCreatePartitionsFailure(admin, option, topic2,
+                        NewPartitions.increaseTo(3, newPartition2Assignments),
+                        InvalidPartitionsException.class,
+                        "Topic already has 3 partition(s).",
+                        3);
+                assertCreatePartitionsFailure(admin, option, topic2,
+                        NewPartitions.increaseTo(3, List.of(
+                                newPartition2Assignments.get(1), newPartition2Assignments.get(0))),
+                        InvalidPartitionsException.class,
+                        "Topic already has 3 partition(s).",
+                        3);
+                assertCreatePartitionsFailure(admin, option, "an-unknown-topic",
+                        NewPartitions.increaseTo(2),
+                        UnknownTopicOrPartitionException.class,
+                        "This server does not host this topic-partition.",
+                        null);
+                assertCreatePartitionsFailure(admin, option, topic1,
+                        NewPartitions.increaseTo(-22),
+                        InvalidPartitionsException.class,
+                        "The topic create-partitions-topic-1 currently has 3 partition(s); " +
+                                "-22 would not be an increase.",
+                        3);
+                assertCreatePartitionsFailure(admin, option, topic1,
+                        NewPartitions.increaseTo(4, List.of(List.of(secondBrokerId, thirdBrokerId))),
+                        InvalidReplicaAssignmentException.class,
+                        "The manual partition assignment includes a partition with 2 replica(s), " +
+                                "but this is not consistent with previous partitions, which have 1 replica(s).",
+                        3);
+                assertCreatePartitionsFailure(admin, option, topic1,
+                        NewPartitions.increaseTo(6, List.of(List.of(secondBrokerId))),
+                        InvalidReplicaAssignmentException.class,
+                        "Attempted to add 3 additional partition(s), but only 1 assignment(s) were specified.",
+                        3);
+                assertCreatePartitionsFailure(admin, option, topic1,
+                        NewPartitions.increaseTo(4, List.of(
+                                List.of(secondBrokerId), List.of(thirdBrokerId))),
+                        InvalidReplicaAssignmentException.class,
+                        "Attempted to add 1 additional partition(s), but only 2 assignment(s) were specified.",
+                        3);
+                assertCreatePartitionsFailure(admin, option, topic1,
+                        NewPartitions.increaseTo(4, List.of(List.of(secondBrokerId, secondBrokerId))),
+                        InvalidReplicaAssignmentException.class,
+                        "The manual partition assignment includes the broker " + secondBrokerId + " more than once.",
+                        3);
+                assertCreatePartitionsFailure(admin, option, topic1,
+                        NewPartitions.increaseTo(5, List.of(
+                                List.of(secondBrokerId), List.of(secondBrokerId, firstBrokerId))),
+                        InvalidReplicaAssignmentException.class,
+                        "The manual partition assignment includes a partition with 2 replica(s), " +
+                                "but this is not consistent with previous partitions, which have 1 replica(s).",
+                        3);
+                assertCreatePartitionsFailure(admin, option, topic1,
+                        NewPartitions.increaseTo(4, List.of(List.of(unknownBrokerId))),
+                        InvalidReplicaAssignmentException.class,
+                        "The manual partition assignment includes broker " + unknownBrokerId +
+                                ", but no such broker is registered.",
+                        3);
+                assertCreatePartitionsFailure(admin, option, topic1,
+                        NewPartitions.increaseTo(4, List.of()),
+                        InvalidReplicaAssignmentException.class,
+                        "Attempted to add 1 additional partition(s), but only 0 assignment(s) were specified.",
+                        3);
+            }
+
+            CreatePartitionsResult mixedResult = admin.createPartitions(Map.of(
+                    topic1, NewPartitions.increaseTo(4),
+                    topic2, NewPartitions.increaseTo(2)), actuallyDoIt);
+            mixedResult.values().get(topic1).get();
+            cluster.waitTopicCreation(topic1, 4);
+            Throwable cause = assertThrows(ExecutionException.class,
+                    () -> mixedResult.values().get(topic2).get()).getCause();
+            assertInstanceOf(InvalidPartitionsException.class, cause);
+            assertEquals("The topic create-partitions-topic-2 currently has 3 partition(s); " +
+                    "2 would not be an increase.", cause.getMessage());
+            cluster.waitTopicCreation(topic2, 3);
+
+            admin.deleteTopics(List.of(topic1)).topicNameValues().get(topic1).get();
+            CreatePartitionsResult deletedTopicResult = admin.createPartitions(
+                    Map.of(topic1, NewPartitions.increaseTo(4)), validateOnly);
+            cause = assertThrows(ExecutionException.class,
+                    () -> deletedTopicResult.values().get(topic1).get()).getCause();
+            assertInstanceOf(UnknownTopicOrPartitionException.class, cause);
+            assertEquals("This server does not host this topic-partition.", cause.getMessage());
+        }
+    }
+
+    private static void assertCreatePartitionsFailure(
+            Admin admin,
+            CreatePartitionsOptions option,
+            String topic,
+            NewPartitions newPartitions,
+            Class<? extends Throwable> expectedException,
+            String expectedMessage,
+            Integer expectedPartitionCount
+    ) throws Exception {
+        String description = "validateOnly=" + option.validateOnly();
+        CreatePartitionsResult result = admin.createPartitions(Map.of(topic, newPartitions), option);
+        Throwable cause = assertThrows(ExecutionException.class,
+                () -> result.values().get(topic).get(), description).getCause();
+        assertInstanceOf(expectedException, cause, description);
+        assertEquals(expectedMessage, cause.getMessage(), description);
+        if (expectedPartitionCount != null) {
+            assertEquals(expectedPartitionCount, numPartitions(admin, topic), description);
+        }
+    }
+
+    private static int numPartitions(Admin admin, String topic) throws Exception {
+        return partitions(admin, topic).size();
+    }
+
+    private static List<TopicPartitionInfo> partitions(Admin admin, String topic) throws Exception {
+        return admin.describeTopics(List.of(topic)).allTopicNames().get().get(topic).partitions();
+    }
+
+    private static List<Integer> replicaIds(TopicPartitionInfo partition) {
+        return partition.replicas().stream().map(Node::id).toList();
+    }
 }
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AdminMetadataTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AdminMetadataTest.java
index 856bbd8e96d..9492ac50767 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AdminMetadataTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AdminMetadataTest.java
@@ -16,11 +16,18 @@
  */
 package org.apache.kafka.clients.admin;
 
+import kafka.server.KafkaBroker;
+
 import org.apache.kafka.common.KafkaFuture;
 import org.apache.kafka.common.Node;
 import org.apache.kafka.common.TopicCollection;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.TopicPartitionReplica;
 import org.apache.kafka.common.Uuid;
+import org.apache.kafka.common.config.ConfigResource;
+import org.apache.kafka.common.errors.InvalidTopicException;
 import org.apache.kafka.common.errors.TimeoutException;
+import org.apache.kafka.common.errors.TopicExistsException;
 import org.apache.kafka.common.errors.UnknownTopicIdException;
 import org.apache.kafka.common.errors.UnknownTopicOrPartitionException;
 import org.apache.kafka.common.internals.Topic;
@@ -34,8 +41,11 @@ import java.time.Duration;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 
@@ -43,6 +53,8 @@ import static org.apache.kafka.test.TestUtils.assertFutureThrows;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
@@ -149,6 +161,120 @@ public class AdminMetadataTest {
         }
     }
 
+    @ClusterTest
+    public void testCreateExistingTopicsThrowTopicExistsException() throws Exception {
+        String topic = "mytopic";
+        clusterInstance.createTopic(topic, 1, (short) 1);
+        try (Admin admin = clusterInstance.admin()) {
+            short invalidReplicationFactor = (short) (clusterInstance.brokerIds().size() + 1);
+            KafkaFuture<Void> future = admin.createTopics(
+                    List.of(new NewTopic(topic, 1, invalidReplicationFactor)),
+                    new CreateTopicsOptions().validateOnly(true)).all();
+            assertFutureThrows(TopicExistsException.class, future);
+        }
+    }
+
+    @ClusterTest
+    public void testDeleteTopicsWithIds() throws Exception {
+        try (Admin admin = clusterInstance.admin()) {
+            List<Integer> brokerIds = clusterInstance.brokerIds().stream().sorted().toList();
+            List<String> topics = List.of("mytopic", "mytopic2", "mytopic3");
+            List<NewTopic> newTopics = List.of(
+                    new NewTopic("mytopic", Map.of(
+                            0, List.of(brokerIds.get(1), brokerIds.get(2)),
+                            1, List.of(brokerIds.get(2), brokerIds.get(0)))),
+                    new NewTopic("mytopic2", 3, (short) brokerIds.size()),
+                    new NewTopic("mytopic3", Optional.empty(), Optional.empty())
+            );
+            CreateTopicsResult createResult = admin.createTopics(newTopics);
+            createResult.all().get();
+            clusterInstance.waitTopicCreation("mytopic", 2);
+            clusterInstance.waitTopicCreation("mytopic2", 3);
+            clusterInstance.waitTopicCreation("mytopic3", 1);
+
+            Set<Uuid> topicIds = Set.of(
+                    createResult.topicId("mytopic").get(),
+                    createResult.topicId("mytopic2").get(),
+                    createResult.topicId("mytopic3").get());
+            admin.deleteTopics(TopicCollection.ofTopicIds(topicIds)).all().get();
+            TestUtils.waitForCondition(() -> {
+                Set<String> remainingTopics = admin.listTopics().names().get();
+                return topics.stream().noneMatch(remainingTopics::contains);
+            }, "Timed out waiting for topics to be deleted");
+        }
+    }
+
+    @ClusterTest
+    public void testDeleteTopicsWithOptionTimeoutMs() {
+        Admin admin = createInvalidAdminClient();
+        try {
+            DeleteTopicsOptions timeoutOption = new DeleteTopicsOptions().timeoutMs(0);
+            ExecutionException exception = assertThrows(ExecutionException.class,
+                    () -> admin.deleteTopics(List.of("test-topic"), timeoutOption).all().get());
+            assertInstanceOf(TimeoutException.class, exception.getCause());
+        } finally {
+            admin.close(Duration.ZERO);
+        }
+    }
+
+    @ClusterTest
+    public void testDescribeLogDirs() throws Exception {
+        String topic = "topic";
+        clusterInstance.createTopic(topic, 10, (short) 1);
+        try (Admin admin = clusterInstance.admin()) {
+            TopicDescription topicDescription = admin.describeTopics(List.of(topic)).allTopicNames().get().get(topic);
+            Map<Integer, Set<Integer>> partitionsByBroker = new HashMap<>();
+            topicDescription.partitions().forEach(partition -> partitionsByBroker
+                    .computeIfAbsent(partition.leader().id(), ignored -> new HashSet<>())
+                    .add(partition.partition()));
+
+            Map<Integer, Map<String, LogDirDescription>> logDirInfosByBroker = admin
+                    .describeLogDirs(clusterInstance.brokerIds()).allDescriptions().get();
+            for (int brokerId : clusterInstance.brokerIds()) {
+                KafkaBroker broker = clusterInstance.brokers().get(brokerId);
+                Map<String, LogDirDescription> logDirInfos = logDirInfosByBroker.get(brokerId);
+                assertNotNull(logDirInfos);
+
+                Set<Integer> actualPartitions = new HashSet<>();
+                logDirInfos.forEach((logDir, logDirInfo) -> {
+                    assertTrue(logDirInfo.totalBytes().isPresent());
+                    assertTrue(logDirInfo.usableBytes().isPresent());
+                    logDirInfo.replicaInfos().keySet().forEach(topicPartition -> {
+                        if (topicPartition.topic().equals(topic)) {
+                            actualPartitions.add(topicPartition.partition());
+                        }
+                        assertEquals(
+                                broker.logManager().getLog(topicPartition, false).get().dir().getParent(),
+                                logDir);
+                    });
+                });
+                assertEquals(partitionsByBroker.getOrDefault(brokerId, Set.of()), actualPartitions);
+            }
+        }
+    }
+
+    @ClusterTest
+    public void testDescribeReplicaLogDirs() throws Exception {
+        String topic = "topic";
+        clusterInstance.createTopic(topic, 10, (short) 1);
+        try (Admin admin = clusterInstance.admin()) {
+            TopicDescription topicDescription = admin.describeTopics(List.of(topic)).allTopicNames().get().get(topic);
+            List<TopicPartitionReplica> replicas = topicDescription.partitions().stream()
+                    .map(partition -> new TopicPartitionReplica(
+                            topic, partition.partition(), partition.leader().id()))
+                    .toList();
+            Map<TopicPartitionReplica, DescribeReplicaLogDirsResult.ReplicaLogDirInfo> replicaDirInfos =
+                    admin.describeReplicaLogDirs(replicas).all().get();
+            replicaDirInfos.forEach((replica, replicaDirInfo) -> {
+                KafkaBroker broker = clusterInstance.brokers().get(replica.brokerId());
+                TopicPartition topicPartition = new TopicPartition(replica.topic(), replica.partition());
+                assertEquals(
+                        broker.logManager().getLog(topicPartition, false).get().dir().getParent(),
+                        replicaDirInfo.getCurrentReplicaLogDir());
+            });
+        }
+    }
+
     @ClusterTest
     public void testDescribeTopicsWithOptionPartitionSizeLimitPerResponse() throws Exception {
         try (Admin admin = clusterInstance.admin()) {
@@ -229,6 +355,46 @@ public class AdminMetadataTest {
         }
     }
 
+    @ClusterTest
+    public void testDescribeConfigsForTopic() throws Exception {
+        String topic = "topic";
+        clusterInstance.createTopic(topic, 2, (short) clusterInstance.brokerIds().size());
+        try (Admin admin = clusterInstance.admin()) {
+            ConfigResource existingTopic = new ConfigResource(ConfigResource.Type.TOPIC, topic);
+            admin.describeConfigs(List.of(existingTopic)).values().get(existingTopic).get();
+
+            ConfigResource defaultTopic = new ConfigResource(ConfigResource.Type.TOPIC, "");
+            assertFutureThrows(InvalidTopicException.class, admin.describeConfigs(List.of(defaultTopic)).all());
+
+            ConfigResource nonExistentTopic = new ConfigResource(ConfigResource.Type.TOPIC, "unknown");
+            assertFutureThrows(UnknownTopicOrPartitionException.class,
+                    admin.describeConfigs(List.of(nonExistentTopic)).all());
+
+            ConfigResource invalidTopic = new ConfigResource(ConfigResource.Type.TOPIC, "(invalid topic)");
+            assertFutureThrows(InvalidTopicException.class, admin.describeConfigs(List.of(invalidTopic)).all());
+        }
+    }
+
+    @ClusterTest
+    public void testIncludeDocumentation() throws Exception {
+        String topic = "topic";
+        clusterInstance.createTopic(topic, 1, (short) 1);
+        try (Admin admin = clusterInstance.admin()) {
+            ConfigResource resource = new ConfigResource(ConfigResource.Type.TOPIC, topic);
+            List<ConfigResource> resources = List.of(resource);
+
+            Config config = admin.describeConfigs(
+                    resources, new DescribeConfigsOptions().includeDocumentation(true))
+                    .values().get(resource).get();
+            config.entries().forEach(entry -> assertNotNull(entry.documentation()));
+
+            config = admin.describeConfigs(
+                    resources, new DescribeConfigsOptions().includeDocumentation(false))
+                    .values().get(resource).get();
+            config.entries().forEach(entry -> assertNull(entry.documentation()));
+        }
+    }
+
     private Admin createInvalidAdminClient() {
         Map<String, Object> config = Map.of(
                 AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:" + INCORRECT_BROKER_PORT
diff --git a/core/src/test/scala/integration/kafka/api/PlaintextAdminIntegrationTest.scala b/core/src/test/scala/integration/kafka/api/PlaintextAdminIntegrationTest.scala
index 4e8fcf7698e..bf102914691 100644
--- a/core/src/test/scala/integration/kafka/api/PlaintextAdminIntegrationTest.scala
+++ b/core/src/test/scala/integration/kafka/api/PlaintextAdminIntegrationTest.scala
@@ -48,7 +48,7 @@ import org.apache.kafka.common.requests.DeleteRecordsRequest
 import org.apache.kafka.common.resource.{PatternType, ResourcePattern, ResourceType}
 import org.apache.kafka.common.serialization.{ByteArrayDeserializer, ByteArraySerializer}
 import org.apache.kafka.common.utils.{Time, Utils}
-import org.apache.kafka.common.{ConsumerGroupState, ElectionType, GroupState, GroupType, IsolationLevel, TopicCollection, TopicPartition, TopicPartitionInfo, TopicPartitionReplica}
+import org.apache.kafka.common.{ConsumerGroupState, ElectionType, GroupState, GroupType, IsolationLevel, TopicPartition, TopicPartitionReplica}
 import org.apache.kafka.controller.ControllerRequestContextUtil.ANONYMOUS_CONTEXT
 import org.apache.kafka.coordinator.group.{GroupConfig, GroupCoordinatorConfig}
 import org.apache.kafka.network.SocketServerConfigs
@@ -644,101 +644,6 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest {
     client.describeCluster().nodes().get()
   }
 
-  @Test
-  def testCreateExistingTopicsThrowTopicExistsException(): Unit = {
-    client = createAdminClient
-    val topic = "mytopic"
-    val topics = Seq(topic)
-    val newTopics = util.List.of(new NewTopic(topic, 1, 1.toShort))
-
-    client.createTopics(newTopics).all.get()
-    waitForTopics(client, topics, List())
-
-    val newTopicsWithInvalidRF = util.List.of(new NewTopic(topic, 1, (brokers.size + 1).toShort))
-    val e = assertThrows(classOf[ExecutionException],
-      () => client.createTopics(newTopicsWithInvalidRF, new CreateTopicsOptions().validateOnly(true)).all.get())
-    assertTrue(e.getCause.isInstanceOf[TopicExistsException])
-  }
-
-  @Test
-  def testDeleteTopicsWithIds(): Unit = {
-    client = createAdminClient
-    val topics = Seq("mytopic", "mytopic2", "mytopic3")
-    val newTopics = util.List.of(
-      new NewTopic("mytopic", util.Map.of(0: Integer, util.List.of[Integer](1, 2), 1: Integer, util.List.of[Integer](2, 0))),
-      new NewTopic("mytopic2", 3, 3.toShort),
-      new NewTopic("mytopic3", Optional.empty[Integer], Optional.empty[java.lang.Short])
-    )
-    val createResult = client.createTopics(newTopics)
-    createResult.all.get()
-    waitForTopics(client, topics, List())
-    val topicIds = getTopicIds().values.toSet
-
-    client.deleteTopics(TopicCollection.ofTopicIds(topicIds.asJava)).all.get()
-    waitForTopics(client, List(), topics)
-  }
-
-  @Test
-  def testDeleteTopicsWithOptionTimeoutMs(): Unit = {
-    client = createInvalidAdminClient()
-
-    try {
-      val timeoutOption = new DeleteTopicsOptions().timeoutMs(0)
-      val exception = assertThrows(classOf[ExecutionException], () =>
-        client.deleteTopics(util.List.of("test-topic"), timeoutOption).all().get())
-      assertInstanceOf(classOf[TimeoutException], exception.getCause)
-    } finally client.close(time.Duration.ZERO)
-  }
-
-  @Test
-  def testDescribeLogDirs(): Unit = {
-    client = createAdminClient
-    val topic = "topic"
-    val leaderByPartition = createTopic(topic, numPartitions = 10)
-    val partitionsByBroker = leaderByPartition.groupBy { case (_, leaderId) => leaderId }.map { case (k, v) =>
-      k -> v.keys.toSeq
-    }
-    ensureConsistentKRaftMetadata()
-    val brokerIds = (0 until brokerCount).map(Integer.valueOf)
-    val logDirInfosByBroker = client.describeLogDirs(brokerIds.asJava).allDescriptions.get
-
-    (0 until brokerCount).foreach { brokerId =>
-      val server = brokers.find(_.config.brokerId == brokerId).get
-      val expectedPartitions = partitionsByBroker(brokerId)
-      val logDirInfos = logDirInfosByBroker.get(brokerId)
-      val replicaInfos = logDirInfos.asScala.flatMap { case (_, logDirInfo) =>
-        logDirInfo.replicaInfos.asScala
-      }.filter { case (k, _) => k.topic == topic }
-
-      assertEquals(expectedPartitions.toSet, replicaInfos.keys.map(_.partition).toSet)
-      logDirInfos.forEach { (logDir, logDirInfo) =>
-        assertTrue(logDirInfo.totalBytes.isPresent)
-        assertTrue(logDirInfo.usableBytes.isPresent)
-        logDirInfo.replicaInfos.asScala.keys.foreach(tp =>
-          assertEquals(server.logManager.getLog(tp).get.dir.getParent, logDir)
-        )
-      }
-    }
-  }
-
-  @Test
-  def testDescribeReplicaLogDirs(): Unit = {
-    client = createAdminClient
-    val topic = "topic"
-    val leaderByPartition = createTopic(topic, numPartitions = 10)
-    val replicas = leaderByPartition.map { case (partition, brokerId) =>
-      new TopicPartitionReplica(topic, partition, brokerId)
-    }.toSeq
-    ensureConsistentKRaftMetadata()
-
-    val replicaDirInfos = client.describeReplicaLogDirs(replicas.asJavaCollection).all.get
-    replicaDirInfos.forEach { (topicPartitionReplica, replicaDirInfo) =>
-      val server = brokers.find(_.config.brokerId == topicPartitionReplica.brokerId()).get
-      val tp = new TopicPartition(topicPartitionReplica.topic(), topicPartitionReplica.partition())
-      assertEquals(server.logManager.getLog(tp).get.dir.getParent, replicaDirInfo.getCurrentReplicaLogDir)
-    }
-  }
-
   @ParameterizedTest(name = TestInfoUtils.TestWithParameterizedGroupProtocolNames)
   @MethodSource(Array("getTestGroupProtocolParametersAll"))
   def testAlterReplicaLogDirs(groupProtocol: String): Unit = {
@@ -1051,220 +956,6 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest {
     assertEquals(Optional.of(50000), brokerServers.head.groupConfigManager.groupConfig(groupId).get.consumerSessionTimeoutMs)
   }
 
-  @Test
-  def testCreatePartitions(): Unit = {
-    client = createAdminClient
-
-    // Create topics
-    val topic1 = "create-partitions-topic-1"
-    createTopic(topic1)
-
-    val topic2 = "create-partitions-topic-2"
-    createTopic(topic2, replicationFactor = 2)
-
-    // assert that both the topics have 1 partition
-    val topic1_metadata = getTopicMetadata(client, topic1)
-    val topic2_metadata = getTopicMetadata(client, topic2)
-    assertEquals(1, topic1_metadata.partitions.size)
-    assertEquals(1, topic2_metadata.partitions.size)
-
-    val validateOnly = new CreatePartitionsOptions().validateOnly(true)
-    val actuallyDoIt = new CreatePartitionsOptions().validateOnly(false)
-
-    def partitions(topic: String, expectedNumPartitionsOpt: Option[Int]): util.List[TopicPartitionInfo] = {
-      getTopicMetadata(client, topic, expectedNumPartitionsOpt = expectedNumPartitionsOpt).partitions
-    }
-
-    def numPartitions(topic: String, expectedNumPartitionsOpt: Option[Int]): Int = partitions(topic, expectedNumPartitionsOpt).size
-
-    // validateOnly: try creating a new partition (no assignments), to bring the total to 3 partitions
-    var alterResult = client.createPartitions(util.Map.of(topic1,
-      NewPartitions.increaseTo(3)), validateOnly)
-    var altered = alterResult.values.get(topic1).get
-    TestUtils.waitForAllPartitionsMetadata(brokers, topic1, expectedNumPartitions = 1)
-
-    // try creating a new partition (no assignments), to bring the total to 3 partitions
-    alterResult = client.createPartitions(util.Map.of(topic1,
-      NewPartitions.increaseTo(3)), actuallyDoIt)
-    altered = alterResult.values.get(topic1).get
-    TestUtils.waitForAllPartitionsMetadata(brokers, topic1, expectedNumPartitions = 3)
-
-    // validateOnly: now try creating a new partition (with assignments), to bring the total to 3 partitions
-    val newPartition2Assignments = util.List.of[util.List[Integer]](util.List.of[Integer](0, 1), util.List.of[Integer](1, 2))
-    alterResult = client.createPartitions(util.Map.of(topic2,
-      NewPartitions.increaseTo(3, newPartition2Assignments)), validateOnly)
-    altered = alterResult.values.get(topic2).get
-    TestUtils.waitForAllPartitionsMetadata(brokers, topic2, expectedNumPartitions = 1)
-
-    // now try creating a new partition (with assignments), to bring the total to 3 partitions
-    alterResult = client.createPartitions(util.Map.of(topic2,
-      NewPartitions.increaseTo(3, newPartition2Assignments)), actuallyDoIt)
-    altered = alterResult.values.get(topic2).get
-    val actualPartitions2 = partitions(topic2, expectedNumPartitionsOpt = Some(3))
-    assertEquals(3, actualPartitions2.size)
-    assertEquals(Seq(0, 1), actualPartitions2.get(1).replicas.asScala.map(_.id).toList)
-    assertEquals(Seq(1, 2), actualPartitions2.get(2).replicas.asScala.map(_.id).toList)
-
-    // loop over error cases calling with+without validate-only
-    for (option <- Seq(validateOnly, actuallyDoIt)) {
-      val desc = if (option.validateOnly()) "validateOnly" else "validateOnly=false"
-
-      // try a newCount which would be a decrease
-      alterResult = client.createPartitions(util.Map.of(topic1,
-        NewPartitions.increaseTo(1)), option)
-
-      var e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(topic1).get,
-        () => s"$desc: Expect InvalidPartitionsException when newCount is a decrease")
-      assertTrue(e.getCause.isInstanceOf[InvalidPartitionsException], desc)
-      var exceptionMsgStr = "The topic create-partitions-topic-1 currently has 3 partition(s); 1 would not be an increase."
-      assertEquals(exceptionMsgStr, e.getCause.getMessage, desc)
-      assertEquals(3, numPartitions(topic1, expectedNumPartitionsOpt = Some(3)), desc)
-
-      // try a newCount which would be a noop (without assignment)
-      alterResult = client.createPartitions(util.Map.of(topic2,
-        NewPartitions.increaseTo(3)), option)
-      e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(topic2).get,
-        () => s"$desc: Expect InvalidPartitionsException when requesting a noop")
-      assertTrue(e.getCause.isInstanceOf[InvalidPartitionsException], desc)
-      exceptionMsgStr = "Topic already has 3 partition(s)."
-      assertEquals(exceptionMsgStr, e.getCause.getMessage, desc)
-      assertEquals(3, numPartitions(topic2, expectedNumPartitionsOpt = Some(3)), desc)
-
-      // try a newCount which would be a noop (where the assignment matches current state)
-      alterResult = client.createPartitions(util.Map.of(topic2,
-        NewPartitions.increaseTo(3, newPartition2Assignments)), option)
-      e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(topic2).get)
-      assertTrue(e.getCause.isInstanceOf[InvalidPartitionsException], desc)
-      assertEquals(exceptionMsgStr, e.getCause.getMessage, desc)
-      assertEquals(3, numPartitions(topic2, expectedNumPartitionsOpt = Some(3)), desc)
-
-      // try a newCount which would be a noop (where the assignment doesn't match current state)
-      alterResult = client.createPartitions(util.Map.of(topic2,
-        NewPartitions.increaseTo(3, newPartition2Assignments.asScala.reverse.toList.asJava)), option)
-      e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(topic2).get)
-      assertTrue(e.getCause.isInstanceOf[InvalidPartitionsException], desc)
-      assertEquals(exceptionMsgStr, e.getCause.getMessage, desc)
-      assertEquals(3, numPartitions(topic2, expectedNumPartitionsOpt = Some(3)), desc)
-
-      // try a bad topic name
-      val unknownTopic = "an-unknown-topic"
-      alterResult = client.createPartitions(util.Map.of(unknownTopic,
-        NewPartitions.increaseTo(2)), option)
-      e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(unknownTopic).get,
-        () => s"$desc: Expect InvalidTopicException when using an unknown topic")
-      assertTrue(e.getCause.isInstanceOf[UnknownTopicOrPartitionException], desc)
-      exceptionMsgStr = "This server does not host this topic-partition."
-      assertEquals(exceptionMsgStr, e.getCause.getMessage, desc)
-
-      // try an invalid newCount
-      alterResult = client.createPartitions(util.Map.of(topic1,
-        NewPartitions.increaseTo(-22)), option)
-      e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(topic1).get,
-        () => s"$desc: Expect InvalidPartitionsException when newCount is invalid")
-      assertTrue(e.getCause.isInstanceOf[InvalidPartitionsException], desc)
-      exceptionMsgStr = "The topic create-partitions-topic-1 currently has 3 partition(s); -22 would not be an increase."
-      assertEquals(exceptionMsgStr, e.getCause.getMessage,
-        desc)
-      assertEquals(3, numPartitions(topic1, expectedNumPartitionsOpt = Some(3)), desc)
-
-      // try assignments where the number of brokers != replication factor
-      alterResult = client.createPartitions(util.Map.of(topic1,
-        NewPartitions.increaseTo(4, util.List.of(util.List.of[Integer](1, 2)))), option)
-      e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(topic1).get,
-        () => s"$desc: Expect InvalidPartitionsException when #brokers != replication factor")
-      assertTrue(e.getCause.isInstanceOf[InvalidReplicaAssignmentException], desc)
-      exceptionMsgStr = "The manual partition assignment includes a partition with 2 replica(s), but this is not " +
-          "consistent with previous partitions, which have 1 replica(s)."
-      assertEquals(exceptionMsgStr, e.getCause.getMessage, desc)
-      assertEquals(3, numPartitions(topic1, expectedNumPartitionsOpt = Some(3)), desc)
-
-      // try #assignments < with the increase
-      alterResult = client.createPartitions(util.Map.of(topic1,
-        NewPartitions.increaseTo(6, util.List.of(util.List.of[Integer](1)))), option)
-      e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(topic1).get,
-        () => s"$desc: Expect InvalidReplicaAssignmentException when #assignments != newCount - oldCount")
-      assertTrue(e.getCause.isInstanceOf[InvalidReplicaAssignmentException], desc)
-      exceptionMsgStr = "Attempted to add 3 additional partition(s), but only 1 assignment(s) were specified."
-      assertEquals(exceptionMsgStr, e.getCause.getMessage, desc)
-      assertEquals(3, numPartitions(topic1, expectedNumPartitionsOpt = Some(3)), desc)
-
-      // try #assignments > with the increase
-      alterResult = client.createPartitions(util.Map.of(topic1,
-        NewPartitions.increaseTo(4, util.List.of(util.List.of[Integer](1), util.List.of[Integer](2)))), option)
-      e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(topic1).get,
-        () => s"$desc: Expect InvalidReplicaAssignmentException when #assignments != newCount - oldCount")
-      exceptionMsgStr = "Attempted to add 1 additional partition(s), but only 2 assignment(s) were specified."
-      assertTrue(e.getCause.isInstanceOf[InvalidReplicaAssignmentException], desc)
-      assertEquals(exceptionMsgStr, e.getCause.getMessage, desc)
-      assertEquals(3, numPartitions(topic1, expectedNumPartitionsOpt = Some(3)), desc)
-
-      // try with duplicate brokers in assignments
-      alterResult = client.createPartitions(util.Map.of(topic1,
-        NewPartitions.increaseTo(4, util.List.of(util.List.of[Integer](1, 1)))), option)
-      e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(topic1).get,
-        () => s"$desc: Expect InvalidReplicaAssignmentException when assignments has duplicate brokers")
-      assertTrue(e.getCause.isInstanceOf[InvalidReplicaAssignmentException], desc)
-      exceptionMsgStr = "The manual partition assignment includes the broker 1 more than once."
-      assertEquals(exceptionMsgStr, e.getCause.getMessage, desc)
-      assertEquals(3, numPartitions(topic1, expectedNumPartitionsOpt = Some(3)), desc)
-
-      // try assignments with differently sized inner lists
-      alterResult = client.createPartitions(util.Map.of(topic1,
-        NewPartitions.increaseTo(5, util.List.of(util.List.of[Integer](1), util.List.of[Integer](1, 0)))), option)
-      e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(topic1).get,
-        () => s"$desc: Expect InvalidReplicaAssignmentException when assignments have differently sized inner lists")
-      assertTrue(e.getCause.isInstanceOf[InvalidReplicaAssignmentException], desc)
-      exceptionMsgStr = "The manual partition assignment includes a partition with 2 replica(s), but this is not " +
-          "consistent with previous partitions, which have 1 replica(s)."
-      assertEquals(exceptionMsgStr, e.getCause.getMessage, desc)
-      assertEquals(3, numPartitions(topic1, expectedNumPartitionsOpt = Some(3)), desc)
-
-      // try assignments with unknown brokers
-      alterResult = client.createPartitions(util.Map.of(topic1,
-        NewPartitions.increaseTo(4, util.List.of(util.List.of[Integer](12)))), option)
-      e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(topic1).get,
-        () => s"$desc: Expect InvalidReplicaAssignmentException when assignments contains an unknown broker")
-      assertTrue(e.getCause.isInstanceOf[InvalidReplicaAssignmentException], desc)
-      exceptionMsgStr = "The manual partition assignment includes broker 12, but no such broker is registered."
-      assertEquals(exceptionMsgStr, e.getCause.getMessage, desc)
-      assertEquals(3, numPartitions(topic1, expectedNumPartitionsOpt = Some(3)), desc)
-
-      // try with empty assignments
-      alterResult = client.createPartitions(util.Map.of(topic1,
-        NewPartitions.increaseTo(4, util.List.of)), option)
-      e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(topic1).get,
-        () => s"$desc: Expect InvalidReplicaAssignmentException when assignments is empty")
-      assertTrue(e.getCause.isInstanceOf[InvalidReplicaAssignmentException], desc)
-      exceptionMsgStr = "Attempted to add 1 additional partition(s), but only 0 assignment(s) were specified."
-      assertEquals(exceptionMsgStr, e.getCause.getMessage, desc)
-      assertEquals(3, numPartitions(topic1, expectedNumPartitionsOpt = Some(3)), desc)
-    }
-
-    // a mixed success, failure response
-    alterResult = client.createPartitions(util.Map.of(
-      topic1, NewPartitions.increaseTo(4),
-      topic2, NewPartitions.increaseTo(2)), actuallyDoIt)
-    // assert that the topic1 now has 4 partitions
-    altered = alterResult.values.get(topic1).get
-    TestUtils.waitForAllPartitionsMetadata(brokers, topic1, expectedNumPartitions = 4)
-    var e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(topic2).get)
-    assertTrue(e.getCause.isInstanceOf[InvalidPartitionsException])
-    val exceptionMsgStr = "The topic create-partitions-topic-2 currently has 3 partition(s); 2 would not be an increase."
-    assertEquals(exceptionMsgStr, e.getCause.getMessage)
-    TestUtils.waitForAllPartitionsMetadata(brokers, topic2, expectedNumPartitions = 3)
-
-    // Delete the topic. Verify addition of partitions to deleted topic is not possible.
-    // In KRaft, the deletion occurs immediately and hence we have a different Exception thrown in the response.
-    val deleteResult = client.deleteTopics(util.List.of(topic1))
-    deleteResult.topicNameValues.get(topic1).get
-    alterResult = client.createPartitions(util.Map.of(topic1,
-      NewPartitions.increaseTo(4)), validateOnly)
-    e = assertThrows(classOf[ExecutionException], () => alterResult.values.get(topic1).get,
-      () => "Expect InvalidTopicException or UnknownTopicOrPartitionException when the topic is queued for deletion")
-    assertTrue(e.getCause.isInstanceOf[UnknownTopicOrPartitionException], e.toString)
-    assertEquals("This server does not host this topic-partition.", e.getCause.getMessage)
-  }
-
   @ParameterizedTest(name = TestInfoUtils.TestWithParameterizedGroupProtocolNames)
   @MethodSource(Array("getTestGroupProtocolParametersAll"))
   def testSeekAfterDeleteRecords(groupProtocol: String): Unit = {
@@ -1572,45 +1263,6 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest {
     assertEquals(classOf[OffsetOutOfRangeException], cause.getClass)
   }
 
-  @Test
-  def testDescribeConfigsForTopic(): Unit = {
-    createTopic(topic, numPartitions = 2, replicationFactor = brokerCount)
-    client = createAdminClient
-
-    val existingTopic = new ConfigResource(ConfigResource.Type.TOPIC, topic)
-    client.describeConfigs(util.List.of(existingTopic)).values.get(existingTopic).get()
-
-    val defaultTopic = new ConfigResource(ConfigResource.Type.TOPIC, "")
-    var describeResult = client.describeConfigs(util.List.of(defaultTopic))
-    assertFutureThrows(classOf[InvalidTopicException], describeResult.all())
-
-    val nonExistentTopic = new ConfigResource(ConfigResource.Type.TOPIC, "unknown")
-    describeResult = client.describeConfigs(util.List.of(nonExistentTopic))
-    assertFutureThrows(classOf[UnknownTopicOrPartitionException], describeResult.all())
-
-    val invalidTopic = new ConfigResource(ConfigResource.Type.TOPIC, "(invalid topic)")
-    describeResult = client.describeConfigs(util.List.of(invalidTopic))
-    assertFutureThrows(classOf[InvalidTopicException], describeResult.all())
-  }
-
-  @Test
-  def testIncludeDocumentation(): Unit = {
-    createTopic(topic)
-    client = createAdminClient
-
-    val resource = new ConfigResource(ConfigResource.Type.TOPIC, topic)
-    val resources = util.List.of(resource)
-    val includeDocumentation = new DescribeConfigsOptions().includeDocumentation(true)
-    var describeConfigs = client.describeConfigs(resources, includeDocumentation)
-    var configEntries = describeConfigs.values().get(resource).get().entries()
-    configEntries.forEach(e => assertNotNull(e.documentation()))
-
-    val excludeDocumentation = new DescribeConfigsOptions().includeDocumentation(false)
-    describeConfigs = client.describeConfigs(resources, excludeDocumentation)
-    configEntries = describeConfigs.values().get(resource).get().entries()
-    configEntries.forEach(e => assertNull(e.documentation()))
-  }
-
   private def subscribeAndWaitForAssignment(topic: String, consumer: Consumer[Array[Byte], Array[Byte]]): Unit = {
     consumer.subscribe(util.List.of(topic))
     TestUtils.pollUntilTrue(consumer, () => !consumer.assignment.isEmpty, "Expected non-empty assignment")