Repository: apache/kafka
Pull request #19217: KAFKA-18975: Move clients-integration-test out of core module
Author: login: FrankYang0529
Labels: name: core
description: Kafka Broker
name: build
description: Gradle build or GitHub Actions
name: clients
name: small
description: Small PRs
Created: 2025-03-16T14:39:46Z | Merged: 2025-03-19T18:43:21Z

Move following tests from core to clients-integration-test module.

- ClientTelemetryTest
- DeleteTopicTest
- DescribeAuthorizedOperationsTest
- ConsumerIntegrationTest
- CustomQuotaCallbackTest
- RackAwareAutoTopicCreationTest

Move following tests from core to server module.

- BootstrapControllersIntegrationTest
- LogManagerIntegrationTest

Reviewers: Kirk True <kirk@kirktrue.pro>, Ken Huang <s7133700@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>



Diff:
diff --git a/build.gradle b/build.gradle
index e3f0a6e58e5f9..6be53ddd52edd 100644
--- a/build.gradle
+++ b/build.gradle
@@ -911,6 +911,8 @@ project(':server') {
     testImplementation libs.mockitoCore
     testImplementation libs.junitJupiter
     testImplementation testLog4j2Libs
+    testImplementation project(':test-common:test-common-internal-api')
+    testImplementation project(':test-common:test-common-runtime')
 
     testRuntimeOnly runtimeTestLibs
   }
@@ -1972,9 +1974,13 @@ project(':clients:clients-integration-tests') {
     testImplementation libs.slf4jApi
     testImplementation project(':test-common:test-common-internal-api')
     testImplementation project(':test-common:test-common-runtime')
+    testImplementation project(':metadata')
+    testImplementation project(':server')
+    testImplementation project(':storage')
+    testImplementation project(':core').sourceSets.test.output
+    testImplementation project(':clients').sourceSets.test.output
     implementation project(':server-common')
     testImplementation project(':metadata')
-    implementation project(':clients').sourceSets.test.output
     implementation project(':group-coordinator')
     implementation project(':transaction-coordinator')
 
diff --git a/checkstyle/import-control-server.xml b/checkstyle/import-control-server.xml
index 94937333a05d5..05e67a153bdf1 100644
--- a/checkstyle/import-control-server.xml
+++ b/checkstyle/import-control-server.xml
@@ -84,6 +84,7 @@
     <allow pkg="org.apache.kafka.server" />
     <allow pkg="org.apache.kafka.image" />
     <allow pkg="org.apache.kafka.storage.internals.log" />
+    <allow pkg="org.apache.kafka.storage.internals.checkpoint" />
     <subpackage name="metrics">
       <allow class="org.apache.kafka.server.authorizer.AuthorizableRequestContext" />
       <allow pkg="org.apache.kafka.server.telemetry" />
diff --git a/core/src/test/java/kafka/admin/ClientTelemetryTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/ClientTelemetryTest.java
similarity index 96%
rename from core/src/test/java/kafka/admin/ClientTelemetryTest.java
rename to clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/ClientTelemetryTest.java
index e43f52f7271a7..008b6096c3d79 100644
--- a/core/src/test/java/kafka/admin/ClientTelemetryTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/ClientTelemetryTest.java
@@ -15,11 +15,10 @@
  * limitations under the License.
  */
 
-package kafka.admin;
+package org.apache.kafka.clients.admin;
+
+import kafka.admin.ConfigCommand;
 
-import org.apache.kafka.clients.admin.Admin;
-import org.apache.kafka.clients.admin.AdminClientConfig;
-import org.apache.kafka.clients.admin.NewTopic;
 import org.apache.kafka.clients.consumer.Consumer;
 import org.apache.kafka.clients.consumer.ConsumerConfig;
 import org.apache.kafka.clients.consumer.ConsumerRecord;
@@ -71,7 +70,7 @@ public class ClientTelemetryTest {
             types = Type.KRAFT, 
             brokers = 3,
             serverProperties = {
-                @ClusterConfigProperty(key = METRIC_REPORTER_CLASSES_CONFIG, value = "kafka.admin.ClientTelemetryTest$GetIdClientTelemetry"),
+                @ClusterConfigProperty(key = METRIC_REPORTER_CLASSES_CONFIG, value = "org.apache.kafka.clients.admin.ClientTelemetryTest$GetIdClientTelemetry"),
             })
     public void testClientInstanceId(ClusterInstance clusterInstance) throws InterruptedException, ExecutionException {
         Map<String, Object> configs = new HashMap<>();
@@ -159,7 +158,7 @@ private static String[] toArray(List<String>... lists) {
 
     /**
      * We should add a ClientTelemetry into plugins to test the clientInstanceId method Otherwise the
-     * {@link  org.apache.kafka.common.protocol.ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS } command will not be supported
+     * {@link org.apache.kafka.common.protocol.ApiKeys#GET_TELEMETRY_SUBSCRIPTIONS} command will not be supported
      * by the server
      **/
     public static class GetIdClientTelemetry implements ClientTelemetry, MetricsReporter {
diff --git a/core/src/test/java/kafka/admin/DeleteTopicTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DeleteTopicTest.java
similarity index 97%
rename from core/src/test/java/kafka/admin/DeleteTopicTest.java
rename to clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DeleteTopicTest.java
index 6a3d87a9e26bd..fceebc0c1b62c 100644
--- a/core/src/test/java/kafka/admin/DeleteTopicTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DeleteTopicTest.java
@@ -14,15 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package kafka.admin;
+package org.apache.kafka.clients.admin;
 
 import kafka.server.KafkaBroker;
 
-import org.apache.kafka.clients.admin.Admin;
-import org.apache.kafka.clients.admin.AdminClientConfig;
-import org.apache.kafka.clients.admin.NewPartitionReassignment;
-import org.apache.kafka.clients.admin.NewPartitions;
-import org.apache.kafka.clients.admin.NewTopic;
 import org.apache.kafka.common.TopicPartition;
 import org.apache.kafka.common.compress.Compression;
 import org.apache.kafka.common.errors.TopicDeletionDisabledException;
@@ -53,8 +48,6 @@
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 
-import scala.jdk.javaapi.OptionConverters;
-
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.fail;
@@ -322,8 +315,8 @@ private void waitForReplicaDeleted(Map<Integer, KafkaBroker> clusters,
     private Supplier<Optional<Integer>> isLeaderKnown(Map<Integer, KafkaBroker> idToBroker, TopicPartition topicPartition) {
         return () -> idToBroker.values()
             .stream()
-            .filter(broker -> OptionConverters.toJava(broker.replicaManager().onlinePartition(topicPartition))
-                .stream().anyMatch(tp -> tp.leaderIdIfLocal().isDefined()))
+            .filter(broker -> broker.replicaManager().onlinePartition(topicPartition)
+                .exists(tp -> tp.leaderIdIfLocal().isDefined()))
             .map(broker -> broker.config().brokerId())
             .findFirst();
     }
diff --git a/core/src/test/java/kafka/admin/DescribeAuthorizedOperationsTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DescribeAuthorizedOperationsTest.java
similarity index 96%
rename from core/src/test/java/kafka/admin/DescribeAuthorizedOperationsTest.java
rename to clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DescribeAuthorizedOperationsTest.java
index d58f1d9ec6e3a..c68218d52bee5 100644
--- a/core/src/test/java/kafka/admin/DescribeAuthorizedOperationsTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DescribeAuthorizedOperationsTest.java
@@ -15,17 +15,9 @@
  * limitations under the License.
  */
 
-package kafka.admin;
+package org.apache.kafka.clients.admin;
 
 import org.apache.kafka.clients.CommonClientConfigs;
-import org.apache.kafka.clients.admin.Admin;
-import org.apache.kafka.clients.admin.ConsumerGroupDescription;
-import org.apache.kafka.clients.admin.DescribeClusterOptions;
-import org.apache.kafka.clients.admin.DescribeConsumerGroupsOptions;
-import org.apache.kafka.clients.admin.DescribeConsumerGroupsResult;
-import org.apache.kafka.clients.admin.DescribeTopicsOptions;
-import org.apache.kafka.clients.admin.NewTopic;
-import org.apache.kafka.clients.admin.TopicDescription;
 import org.apache.kafka.clients.consumer.OffsetAndMetadata;
 import org.apache.kafka.common.TopicPartition;
 import org.apache.kafka.common.acl.AccessControlEntry;
diff --git a/core/src/test/java/kafka/admin/RackAwareAutoTopicCreationTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/RackAwareAutoTopicCreationTest.java
similarity index 98%
rename from core/src/test/java/kafka/admin/RackAwareAutoTopicCreationTest.java
rename to clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/RackAwareAutoTopicCreationTest.java
index e0bc4514ec68d..e3b9efb9b6f94 100644
--- a/core/src/test/java/kafka/admin/RackAwareAutoTopicCreationTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/RackAwareAutoTopicCreationTest.java
@@ -14,10 +14,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package kafka.admin;
+package org.apache.kafka.clients.admin;
 
-import org.apache.kafka.clients.admin.Admin;
-import org.apache.kafka.clients.admin.TopicDescription;
 import org.apache.kafka.clients.producer.Producer;
 import org.apache.kafka.clients.producer.ProducerRecord;
 import org.apache.kafka.common.Node;
diff --git a/core/src/test/java/kafka/clients/consumer/ConsumerIntegrationTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ConsumerIntegrationTest.java
similarity index 96%
rename from core/src/test/java/kafka/clients/consumer/ConsumerIntegrationTest.java
rename to clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ConsumerIntegrationTest.java
index 98cd4d0449bc8..e0572340e5f95 100644
--- a/core/src/test/java/kafka/clients/consumer/ConsumerIntegrationTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ConsumerIntegrationTest.java
@@ -14,14 +14,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package kafka.clients.consumer;
-
-import org.apache.kafka.clients.consumer.ConsumerConfig;
-import org.apache.kafka.clients.consumer.ConsumerRebalanceListener;
-import org.apache.kafka.clients.consumer.ConsumerRecord;
-import org.apache.kafka.clients.consumer.ConsumerRecords;
-import org.apache.kafka.clients.consumer.GroupProtocol;
-import org.apache.kafka.clients.consumer.KafkaConsumer;
+package org.apache.kafka.clients.consumer;
+
 import org.apache.kafka.clients.consumer.internals.AbstractHeartbeatRequestManager;
 import org.apache.kafka.clients.producer.ProducerConfig;
 import org.apache.kafka.clients.producer.ProducerRecord;
diff --git a/core/src/test/java/kafka/test/api/CustomQuotaCallbackTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/server/quota/CustomQuotaCallbackTest.java
similarity index 90%
rename from core/src/test/java/kafka/test/api/CustomQuotaCallbackTest.java
rename to clients/clients-integration-tests/src/test/java/org/apache/kafka/server/quota/CustomQuotaCallbackTest.java
index a7da8ce4eb592..0e4d4f76a42b8 100644
--- a/core/src/test/java/kafka/test/api/CustomQuotaCallbackTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/server/quota/CustomQuotaCallbackTest.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package kafka.test.api;
+package org.apache.kafka.server.quota;
 
 import org.apache.kafka.clients.admin.Admin;
 import org.apache.kafka.clients.admin.NewTopic;
@@ -28,9 +28,6 @@
 import org.apache.kafka.common.test.api.Type;
 import org.apache.kafka.common.test.junit.ClusterTestExtensions;
 import org.apache.kafka.server.config.QuotaConfig;
-import org.apache.kafka.server.quota.ClientQuotaCallback;
-import org.apache.kafka.server.quota.ClientQuotaEntity;
-import org.apache.kafka.server.quota.ClientQuotaType;
 
 import org.junit.jupiter.api.extension.ExtendWith;
 
@@ -42,9 +39,9 @@
 @ClusterTestDefaults(controllers = 3, 
     types = {Type.KRAFT},
     serverProperties = {
-        @ClusterConfigProperty(id = 3000, key = QuotaConfig.CLIENT_QUOTA_CALLBACK_CLASS_CONFIG, value = "kafka.test.api.CustomQuotaCallbackTest$CustomQuotaCallback"),
-        @ClusterConfigProperty(id = 3001, key = QuotaConfig.CLIENT_QUOTA_CALLBACK_CLASS_CONFIG, value = "kafka.test.api.CustomQuotaCallbackTest$CustomQuotaCallback"),
-        @ClusterConfigProperty(id = 3002, key = QuotaConfig.CLIENT_QUOTA_CALLBACK_CLASS_CONFIG, value = "kafka.test.api.CustomQuotaCallbackTest$CustomQuotaCallback"),
+        @ClusterConfigProperty(id = 3000, key = QuotaConfig.CLIENT_QUOTA_CALLBACK_CLASS_CONFIG, value = "org.apache.kafka.server.quota.CustomQuotaCallbackTest$CustomQuotaCallback"),
+        @ClusterConfigProperty(id = 3001, key = QuotaConfig.CLIENT_QUOTA_CALLBACK_CLASS_CONFIG, value = "org.apache.kafka.server.quota.CustomQuotaCallbackTest$CustomQuotaCallback"),
+        @ClusterConfigProperty(id = 3002, key = QuotaConfig.CLIENT_QUOTA_CALLBACK_CLASS_CONFIG, value = "org.apache.kafka.server.quota.CustomQuotaCallbackTest$CustomQuotaCallback"),
     }
 )
 @ExtendWith(ClusterTestExtensions.class)
diff --git a/core/src/test/java/kafka/server/BootstrapControllersIntegrationTest.java b/server/src/test/java/org/apache/kafka/server/BootstrapControllersIntegrationTest.java
similarity index 99%
rename from core/src/test/java/kafka/server/BootstrapControllersIntegrationTest.java
rename to server/src/test/java/org/apache/kafka/server/BootstrapControllersIntegrationTest.java
index 17ba071beb0e3..a472e4d6cae3f 100644
--- a/core/src/test/java/kafka/server/BootstrapControllersIntegrationTest.java
+++ b/server/src/test/java/org/apache/kafka/server/BootstrapControllersIntegrationTest.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package kafka.server;
+package org.apache.kafka.server;
 
 import org.apache.kafka.clients.admin.Admin;
 import org.apache.kafka.clients.admin.AlterConfigOp;
diff --git a/core/src/test/java/kafka/server/LogManagerIntegrationTest.java b/server/src/test/java/org/apache/kafka/server/LogManagerIntegrationTest.java
similarity index 99%
rename from core/src/test/java/kafka/server/LogManagerIntegrationTest.java
rename to server/src/test/java/org/apache/kafka/server/LogManagerIntegrationTest.java
index 66cd5b5b774fb..44ba8cf8425bd 100644
--- a/core/src/test/java/kafka/server/LogManagerIntegrationTest.java
+++ b/server/src/test/java/org/apache/kafka/server/LogManagerIntegrationTest.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package kafka.server;
+package org.apache.kafka.server;
 
 import org.apache.kafka.clients.admin.Admin;
 import org.apache.kafka.clients.admin.NewTopic;


Reviews:
user: login: chia7712
state: APPROVED
author_association: MEMBER
submitted_at: 2025-03-16T17:15:12Z
user: login: kirktrue
body: Thanks for the PR @FrankYang0529!

It'll be very nice for developers to be able to run all the client integration tests in one go!

It looks like we're intentionally _not_ using statically imports for `Assertions.assert*`, and I'm curious about the reason behind it.

Thanks!
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-18T00:24:29Z
user: login: m1a2st
body: Thanks for this patch, left a little comment
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-18T14:43:27Z
user: login: kirktrue
body: @FrankYang0529—Thanks for the changes. It looks good to me, but I'll let you answer the question about `build.gradle` from @m1a2st first. Thanks!
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-18T23:29:59Z
user: login: FrankYang0529
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-19T00:49:49Z
user: login: m1a2st
body: LGTM
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-03-19T03:23:49Z

Review comments:
diff_hunk: @@ -159,7 +158,7 @@ private static String[] toArray(List<String>... lists) {
 
     /**
      * We should add a ClientTelemetry into plugins to test the clientInstanceId method Otherwise the
-     * {@link  org.apache.kafka.common.protocol.ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS } command will not be supported
+     * {@link  org.apache.kafka.common.protocol.ApiKeys#GET_TELEMETRY_SUBSCRIPTIONS } command will not be supported
path: clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/ClientTelemetryTest.java
user: login: kirktrue
body: Since the line is being updated, can we remove the superfluous spaces?

```suggestion
     * {@link org.apache.kafka.common.protocol.ApiKeys#GET_TELEMETRY_SUBSCRIPTIONS} command will not be supported
```
created_at: 2025-03-18T00:18:55Z
author_association: CONTRIBUTOR
diff_hunk: @@ -154,7 +147,7 @@ public void testConsumerGroupAuthorizedOperations(ClusterInstance clusterInstanc
             assertEquals(3, describeConsumerGroupsResult.describedGroups().size());
 
             ConsumerGroupDescription group1Description = describeConsumerGroupsResult.describedGroups().get(GROUP1).get();
-            assertEquals(AclEntry.supportedOperations(ResourceType.GROUP), group1Description.authorizedOperations());
+            Assertions.assertEquals(AclEntry.supportedOperations(ResourceType.GROUP), group1Description.authorizedOperations());
path: clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DescribeAuthorizedOperationsTest.java
user: login: kirktrue
body: Can we use a static import for `Assertions.assertEquals()`?
created_at: 2025-03-18T00:21:15Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1972,6 +1974,11 @@ project(':clients:clients-integration-tests') {
     testImplementation libs.slf4jApi
     testImplementation project(':test-common:test-common-internal-api')
     testImplementation project(':test-common:test-common-runtime')
+    testImplementation project(':metadata')
+    testImplementation project(':server')
+    testImplementation project(':storage')
+    testImplementation project(':core').sourceSets.test.output
+    testImplementation project(':clients').sourceSets.test.output
path: build.gradle
user: login: m1a2st
body: It seems diplicate of `implementation project(':clients').sourceSets.test.output`.
created_at: 2025-03-18T14:39:48Z
author_association: COLLABORATOR
diff_hunk: @@ -1972,6 +1974,11 @@ project(':clients:clients-integration-tests') {
     testImplementation libs.slf4jApi
     testImplementation project(':test-common:test-common-internal-api')
     testImplementation project(':test-common:test-common-runtime')
+    testImplementation project(':metadata')
+    testImplementation project(':server')
+    testImplementation project(':storage')
+    testImplementation project(':core').sourceSets.test.output
+    testImplementation project(':clients').sourceSets.test.output
path: build.gradle
user: login: FrankYang0529
body: Updated it. Thanks.
created_at: 2025-03-19T00:49:49Z
author_association: MEMBER

PR comments:
user: login: chia7712
created_at: 2025-03-16T17:18:15Z
body: @FrankYang0529 Could you please move `RackAwareAutoTopicCreationTest` and `CustomQuotaCallbackTest` too?
author_association: MEMBER
user: login: chia7712
created_at: 2025-03-16T17:26:36Z
body: `BootstrapControllersIntegrationTest`  and `LogManagerIntegrationTest` can be moved to server module.
author_association: MEMBER
user: login: FrankYang0529
created_at: 2025-03-17T05:19:26Z
body: The `RackAwareAutoTopicCreationTest` will update for https://github.com/apache/kafka/pull/18801, because it has Scala converter now.
author_association: MEMBER
user: login: chia7712
created_at: 2025-03-17T16:49:04Z
body: @FrankYang0529 please fix the conflicts and move the RackAwareAutoTopicCreationTest
author_association: MEMBER
user: login: chia7712
created_at: 2025-03-18T06:48:32Z
body: @FrankYang0529 could you please fix the conflicts again?
author_association: MEMBER
user: login: FrankYang0529
created_at: 2025-03-18T10:14:03Z
body: @chia7712 @kirktrue , thanks for review. I addressed all comments.
author_association: MEMBER