You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by sc...@apache.org on 2026/09/10 07:11:24 UTC

(kafka) branch trunk updated: KAFKA-21017: Deflake ConsumerGroupCommandSaslAuthenticationTest (#23154)

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

AndrewJSchofield 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 26180810205 KAFKA-21017: Deflake ConsumerGroupCommandSaslAuthenticationTest (#23154)
26180810205 is described below

commit 2618081020540e1e6b65233c36a33b5a705edeba
Author: Po-Han Shih <79...@users.noreply.github.com>
AuthorDate: Thu Sep 10 15:11:15 2026 +0800

    KAFKA-21017: Deflake ConsumerGroupCommandSaslAuthenticationTest (#23154)
    
    ClassicKafkaConsumer has no background thread, so poll() is what drives
    JoinGroup and SyncGroup for the classic group protocol. In
    testConsumerGroupServiceWithAuthenticationSuccess, the second
    waitForCondition checked group visibility but never called poll() again.
    If the handshake was not finished after the first successful poll,
    nothing pushed it forward, and the test timed out under load.
    
    Andrew asked to match ListConsumerGroupTest: an executor that keeps
    polling until the consumer is closed. The success path now uses
    ConsumerGroupCommandTestUtils.buildConsumers, so the classic consumer
    keeps polling JoinGroup/SyncGroup on a background thread until the test
    closes it. The two waitForCondition blocks stay separate so the
    auth-failure and missing-group-visibility messages stay distinguishable.
    
    Fixes KAFKA-21017.
    
    Verified:
    - First poll() patch: class run 30 times (all green); 60 times reverted
    under a warm daemon (all green); 30 times reverted under artificial CPU
    load (4/30 red).
    - After the buildConsumers refactor I did not re-run the cluster test on
    this Windows box. dino2895 repeated
    
    testConsumerGroupServiceWithAuthenticationSuccessWithClassicGroupProtocol
    300 times with -Pkafka.cluster.test.repeat=300; all 300 passed.
    
    Co-Authored-By: Claude Sonnet 5 <cl...@anthropic.com>
    
    Reviewers: Uros (github:uros-b), YANG-SYUAN CHOU <di...@gmail.com>,
    Andrew Schofield <as...@confluent.io>
    
    ---------
    
    Signed-off-by: Stan Shih <st...@users.noreply.github.com>
    Co-authored-by: stantheman0128 <st...@users.noreply.github.com>
    Co-authored-by: Claude Sonnet 5 <cl...@anthropic.com>
    Co-authored-by: Cursor <cu...@cursor.com>
---
 .../ConsumerGroupCommandSaslAuthenticationTest.java  | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/tools/src/test/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandSaslAuthenticationTest.java b/tools/src/test/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandSaslAuthenticationTest.java
index ea03a1aa1c6..b0e5dd41792 100644
--- a/tools/src/test/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandSaslAuthenticationTest.java
+++ b/tools/src/test/java/org/apache/kafka/tools/consumer/group/ConsumerGroupCommandSaslAuthenticationTest.java
@@ -24,7 +24,6 @@ import org.apache.kafka.clients.admin.UserScramCredentialUpsertion;
 import org.apache.kafka.clients.consumer.ConsumerConfig;
 import org.apache.kafka.clients.consumer.GroupProtocol;
 import org.apache.kafka.clients.consumer.KafkaConsumer;
-import org.apache.kafka.common.errors.SaslAuthenticationException;
 import org.apache.kafka.common.security.auth.SecurityProtocol;
 import org.apache.kafka.common.serialization.ByteArrayDeserializer;
 import org.apache.kafka.common.test.ClusterInstance;
@@ -38,7 +37,6 @@ import org.junit.jupiter.api.function.Executable;
 
 import java.io.File;
 import java.io.IOException;
-import java.time.Duration;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -113,19 +111,13 @@ public class ConsumerGroupCommandSaslAuthenticationTest {
         createScramCredential(SCRAM_USER, SCRAM_PASSWORD);
         try (
             ConsumerGroupCommand.ConsumerGroupService consumerGroupService = prepareConsumerGroupService();
-            KafkaConsumer<byte[], byte[]> consumer = createScramConsumer(groupProtocol)
+            AutoCloseable consumerExecutor = ConsumerGroupCommandTestUtils.buildConsumers(
+                1,
+                false,
+                TOPIC,
+                () -> createScramConsumer(groupProtocol)
+            )
         ) {
-            consumer.subscribe(List.of(TOPIC));
-
-            TestUtils.waitForCondition(() -> {
-                try {
-                    consumer.poll(Duration.ofMillis(1000));
-                    return true;
-                } catch (SaslAuthenticationException ignored) {
-                    return false;
-                }
-            }, "failed to poll data with authentication");
-
             TestUtils.waitForCondition(
                 () -> consumerGroupService.listConsumerGroups().size() == 1,
                 "failed to find consumer group after successful poll"