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

lianetm 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 5400a80de32 KAFKA-20059: Fix flaky ConfigCommandIntegrationTest 
testUpdateInvalidBrokerConfigs (#21280)
5400a80de32 is described below

commit 5400a80de32178ef45734a4546368cb4c6f30fc2
Author: ChickenchickenLove <[email protected]>
AuthorDate: Thu Jan 22 23:57:48 2026 +0900

    KAFKA-20059: Fix flaky ConfigCommandIntegrationTest 
testUpdateInvalidBrokerConfigs (#21280)
    
    ### Description
    This PR fixes a flaky failure in
    `ConfigCommandIntegrationTest.testUpdateInvalidBrokerConfigs`.
    
    The test updates an unknown broker dynamic config `(invalid=2)` and
    immediately runs `kafka-configs --describe` to assert that the unknown
    config is treated as sensitive `(sensitive=true)` and returned as
    `invalid=null`.   In KRaft, the alter request can return before the
    change is fully visible to `--describe` because `dynamic config` updates
    are applied asynchronously and published via `DynamicConfigPublisher` as
    metadata updates are processed.
    
    As a result, the first describe may read stale state and miss the
    expected fields, causing intermittent failures.
    
    To make the test robust, we now poll `--describe` for a short period and
    proceed once the expected output becomes visible (or fail with the last
    observed output on timeout).
    
    ### Flaky Test
    
    
https://develocity.apache.org/s/2q7zc77kptd66/tests/task/:tools:test/details/org.apache.kafka.tools.ConfigCommandIntegrationTest/testUpdateInvalidBrokerConfigs()%5B2%5D?expanded-stacktrace=WyIwIl0&top-execution=1
    
    Reviewers: Lianet Magrans <[email protected]>
---
 .../kafka/tools/ConfigCommandIntegrationTest.java  | 31 +++++++++++++---------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git 
a/tools/src/test/java/org/apache/kafka/tools/ConfigCommandIntegrationTest.java 
b/tools/src/test/java/org/apache/kafka/tools/ConfigCommandIntegrationTest.java
index e6d45079d97..9800d9125eb 100644
--- 
a/tools/src/test/java/org/apache/kafka/tools/ConfigCommandIntegrationTest.java
+++ 
b/tools/src/test/java/org/apache/kafka/tools/ConfigCommandIntegrationTest.java
@@ -461,27 +461,32 @@ public class ConfigCommandIntegrationTest {
     }
 
     @ClusterTest
-    public void testUpdateInvalidBrokerConfigs() {
+    public void testUpdateInvalidBrokerConfigs() throws InterruptedException {
         updateAndCheckInvalidBrokerConfig(Optional.empty());
         
updateAndCheckInvalidBrokerConfig(Optional.of(String.valueOf((cluster.brokers().entrySet().iterator().next().getKey()))));
     }
 
-    private void updateAndCheckInvalidBrokerConfig(Optional<String> 
brokerIdOrDefault) {
+    private void updateAndCheckInvalidBrokerConfig(Optional<String> 
brokerIdOrDefault) throws InterruptedException {
         List<String> alterOpts = 
generateDefaultAlterOpts(cluster.bootstrapServers());
         try (Admin client = cluster.admin()) {
             alterConfigWithAdmin(client, brokerIdOrDefault, Map.of("invalid", 
"2"), alterOpts);
+            AtomicReference<String> last = new AtomicReference<>("");
 
-            Stream<String> describeCommand = Stream.concat(
-                    Stream.concat(
-                            Stream.of("--bootstrap-server", 
cluster.bootstrapServers()),
-                            Stream.of(entityOp(brokerIdOrDefault).toArray(new 
String[0]))),
-                    Stream.of("--entity-type", "brokers", "--describe"));
-            String describeResult = captureStandardOut(run(describeCommand));
-
-            // We will treat unknown config as sensitive
-            assertTrue(describeResult.contains("sensitive=true"), 
describeResult);
-            // Sensitive config will not return
-            assertTrue(describeResult.contains("invalid=null"), 
describeResult);
+            TestUtils.waitForCondition(() -> {
+                Stream<String> describeCommand = Stream.concat(
+                        Stream.concat(
+                                Stream.of("--bootstrap-server", 
cluster.bootstrapServers()),
+                                
Stream.of(entityOp(brokerIdOrDefault).toArray(new String[0]))),
+                        Stream.of("--entity-type", "brokers", "--describe")
+                );
+                String describeResult = 
captureStandardOut(run(describeCommand));
+                last.set(describeResult);
+
+                return describeResult.contains("invalid=null");
+            }, 5000, () -> "Dynamic broker config was not visible within 5s 
(missing 'invalid=null').\n" + 
+                    "Last describe output:\n" + last.get());
+
+            assertTrue(last.get().contains("sensitive=true"));
         }
     }
 

Reply via email to