You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "andyhuangdev (via GitHub)" <gi...@apache.org> on 2026/10/05 08:03:21 UTC
[PR] MINOR: Migrate PlaintextConsumerAssignorsTest to Java [kafka]
andyhuangdev opened a new pull request, #23707:
URL: https://github.com/apache/kafka/pull/23707
Migrates `PlaintextConsumerAssignorsTest` from Scala in `core` to Java in `clients-integration-tests` using `ClusterTestExtensions`, as part of KAFKA-19042.
Preserves all nine assignor scenarios and adds regression coverage for assignment validation. Reuses existing consumer polling helpers and ensures pollers and consumers are cleaned up after each test. Removes the original Scala test.
Testing:
- All 10 tests in `PlaintextConsumerAssignorsTest` passed.
- Sticky assignor and both rebalance scenarios passed on rerun.
- Checkstyle and Spotless checks passed.
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Migrate PlaintextConsumerAssignorsTest to Java [kafka]
Posted by "m1a2st (via GitHub)" <gi...@apache.org>.
m1a2st commented on code in PR #23707:
URL: https://github.com/apache/kafka/pull/23707#discussion_r4181992285
##########
clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerAssignorsTest.java:
##########
@@ -0,0 +1,352 @@
+/*
+ * 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.clients.consumer;
+
+import org.apache.kafka.clients.ClientsTestUtils;
+import org.apache.kafka.clients.producer.Producer;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.errors.UnsupportedAssignorException;
+import org.apache.kafka.common.test.ClusterInstance;
+import org.apache.kafka.common.test.api.AutoStart;
+import org.apache.kafka.common.test.api.ClusterConfigProperty;
+import org.apache.kafka.common.test.api.ClusterTest;
+import org.apache.kafka.common.test.api.ClusterTestDefaults;
+import org.apache.kafka.common.test.api.Type;
+import org.apache.kafka.test.TestUtils;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Timeout;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Integration tests for client-side and server-side consumer assignors.
+ */
+@Timeout(600)
+@ClusterTestDefaults(
+ types = {Type.KRAFT},
+ brokers = 3,
+ serverProperties = {
+ @ClusterConfigProperty(key = "offsets.topic.replication.factor", value = "3"),
+ @ClusterConfigProperty(key = "offsets.topic.num.partitions", value = "1"),
+ @ClusterConfigProperty(key = "group.min.session.timeout.ms", value = "100"),
+ @ClusterConfigProperty(key = "group.max.session.timeout.ms", value = "60000"),
+ @ClusterConfigProperty(key = "group.initial.rebalance.delay.ms", value = "10")
+ }
+)
+public class PlaintextConsumerAssignorsTest {
+ private final ClusterInstance cluster;
+ private final List<Consumer<byte[], byte[]>> consumers = new ArrayList<>();
+ private final List<ConsumerAssignmentPoller> pollers = new ArrayList<>();
+
+ public PlaintextConsumerAssignorsTest(ClusterInstance cluster) {
+ this.cluster = cluster;
+ }
+
+ @ClusterTest(autoStart = AutoStart.NO)
+ public void testAssignmentValidation() {
+ var first = new TopicPartition("topic", 0);
+ var second = new TopicPartition("topic", 1);
+ var partitions = Set.of(first, second);
+ assertFalse(isPartitionAssignmentValid(List.of(Set.of(first), partitions), partitions, List.of()));
+ assertFalse(isPartitionAssignmentValid(List.of(Set.of(first), Set.of(first)), partitions, List.of()));
+ assertFalse(isPartitionAssignmentValid(List.of(partitions, Set.of()), partitions, List.of()));
+ assertFalse(isPartitionAssignmentValid(List.of(Set.of(first), Set.of(second)), partitions,
+ List.of(partitions)));
+ assertTrue(isPartitionAssignmentValid(List.of(Set.of(second), Set.of(first)), partitions,
+ List.of(Set.of(first), Set.of(second))));
+ }
Review Comment:
Could you explain the purpose of this test? It seems to be validating the test helper method itself rather than the functionality under test.
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Migrate PlaintextConsumerAssignorsTest to Java [kafka]
Posted by "andyhuangdev (via GitHub)" <gi...@apache.org>.
andyhuangdev closed pull request #23707: MINOR: Migrate PlaintextConsumerAssignorsTest to Java
URL: https://github.com/apache/kafka/pull/23707
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org