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

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


The following commit(s) were added to refs/heads/trunk by this push:
     new ea8deca79d2 HDFS-17885. Fix TestDFSAdmin.testAllDatanodesReconfig 
flaky test.
ea8deca79d2 is described below

commit ea8deca79d21eecb261170fc19d368573302ef8f
Author: slfan1989 <[email protected]>
AuthorDate: Mon Feb 23 17:28:21 2026 +0000

    HDFS-17885. Fix TestDFSAdmin.testAllDatanodesReconfig flaky test.
    
    Closes #8269
    
    Signed-off-by: Chris Nauroth <[email protected]>
---
 .../org/apache/hadoop/hdfs/tools/TestDFSAdmin.java | 29 ++++++++++++++--------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdmin.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdmin.java
index 69d1eade5a2..4ba243c9e1a 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdmin.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdmin.java
@@ -208,6 +208,8 @@ private void getReconfigurationStatus(String nodeType, 
String address,
   private void reconfigurationOutErrFormatter(String methodName,
       String nodeType, String address, final List<String> outs,
       final List<String> errs) throws IOException, InterruptedException {
+    // Start reconfiguration once and capture output directly to avoid
+    // triggering "Another reconfiguration task is running" error.
     ByteArrayOutputStream bufOut = new ByteArrayOutputStream();
     PrintStream outStream = new PrintStream(bufOut);
     ByteArrayOutputStream bufErr = new ByteArrayOutputStream();
@@ -1251,22 +1253,27 @@ public void testAllDatanodesReconfig()
     when(reconfigurationUtil.parseChangedProperties(any(Configuration.class),
         any(Configuration.class))).thenReturn(changes);
 
-    int result = admin.startReconfiguration("datanode", "livenodes");
+    ByteArrayOutputStream bufOut = new ByteArrayOutputStream();
+    PrintStream outStream = new PrintStream(bufOut);
+    ByteArrayOutputStream bufErr = new ByteArrayOutputStream();
+    PrintStream errStream = new PrintStream(bufErr);
+    int result = admin.startReconfigurationUtil("datanode", "livenodes",
+        outStream, errStream);
     assertThat(result).isEqualTo(0);
     final List<String> outsForStartReconf = new ArrayList<>();
     final List<String> errsForStartReconf = new ArrayList<>();
-    reconfigurationOutErrFormatter("startReconfiguration", "datanode",
-        "livenodes", outsForStartReconf, errsForStartReconf);
+    scanIntoList(bufOut, outsForStartReconf);
+    scanIntoList(bufErr, errsForStartReconf);
     String started = "Started reconfiguration task on node";
     String starting =
-        "Starting of reconfiguration task successful on 2 nodes, failed on 0 
nodes.";
-    assertThat(outsForStartReconf).hasSize(3);
-    assertThat(errsForStartReconf).hasSize(0);
-    assertThat(outsForStartReconf.get(0)).startsWith(started);
-    assertThat(outsForStartReconf.get(1)).startsWith(started);
-    assertThat(outsForStartReconf.get(2)).startsWith(starting);
-
-    Thread.sleep(1000);
+        "Starting of reconfiguration task successful on " + NUM_DATANODES
+            + " nodes, failed on 0 nodes.";
+    assertThat(errsForStartReconf).isEmpty();
+    assertThat(outsForStartReconf).hasSize(NUM_DATANODES + 1);
+    assertThat(outsForStartReconf.stream()
+        .filter(s -> s.startsWith(started))
+        .count()).isEqualTo(NUM_DATANODES);
+    assertThat(outsForStartReconf).contains(starting);
     final List<String> outs = new ArrayList<>();
     final List<String> errs = new ArrayList<>();
     awaitReconfigurationFinished("datanode", "livenodes", outs, errs);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to