This is an automated email from the ASF dual-hosted git repository. stevel pushed a commit to branch branch-3.3.5 in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.3.5 by this push: new 143fe8095d4 HDFS-16934. TestDFSAdmin.testAllDatanodesReconfig regression (#5434) 143fe8095d4 is described below commit 143fe8095d44d04ed6b2df0a2c6eafc97e74c181 Author: slfan1989 <55643692+slfan1...@users.noreply.github.com> AuthorDate: Mon Mar 6 23:26:53 2023 +0800 HDFS-16934. TestDFSAdmin.testAllDatanodesReconfig regression (#5434) Contributed by Shilun Fan --- .../org/apache/hadoop/hdfs/tools/TestDFSAdmin.java | 44 ++++++++++++---------- 1 file changed, 24 insertions(+), 20 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 5b0646f3d1e..591ab47f8c0 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 @@ -74,6 +74,8 @@ import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.test.PathUtils; import org.apache.hadoop.util.ToolRunner; + +import org.assertj.core.api.Assertions; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -1125,36 +1127,38 @@ public class TestDFSAdmin { when(reconfigurationUtil.parseChangedProperties(any(Configuration.class), any(Configuration.class))).thenReturn(changes); - assertEquals(0, admin.startReconfiguration("datanode", "livenodes")); + int result = admin.startReconfiguration("datanode", "livenodes"); + Assertions.assertThat(result).isEqualTo(0); final List<String> outsForStartReconf = new ArrayList<>(); final List<String> errsForStartReconf = new ArrayList<>(); reconfigurationOutErrFormatter("startReconfiguration", "datanode", "livenodes", outsForStartReconf, errsForStartReconf); - assertEquals(3, outsForStartReconf.size()); - assertEquals(0, errsForStartReconf.size()); - assertTrue(outsForStartReconf.get(0).startsWith("Started reconfiguration task on node")); - assertTrue(outsForStartReconf.get(1).startsWith("Started reconfiguration task on node")); - assertEquals("Starting of reconfiguration task successful on 2 nodes, failed on 0 nodes.", - outsForStartReconf.get(2)); + String started = "Started reconfiguration task on node"; + String starting = + "Starting of reconfiguration task successful on 2 nodes, failed on 0 nodes."; + Assertions.assertThat(outsForStartReconf).hasSize(3); + Assertions.assertThat(errsForStartReconf).hasSize(0); + Assertions.assertThat(outsForStartReconf.get(0)).startsWith(started); + Assertions.assertThat(outsForStartReconf.get(1)).startsWith(started); + Assertions.assertThat(outsForStartReconf.get(2)).startsWith(starting); Thread.sleep(1000); final List<String> outs = new ArrayList<>(); final List<String> errs = new ArrayList<>(); awaitReconfigurationFinished("datanode", "livenodes", outs, errs); - assertEquals(9, outs.size()); - assertEquals(0, errs.size()); + Assertions.assertThat(outs).hasSize(9); + Assertions.assertThat(errs).hasSize(0); LOG.info("dfsadmin -status -livenodes output:"); outs.forEach(s -> LOG.info("{}", s)); - assertTrue(outs.get(0).startsWith("Reconfiguring status for node")); - assertTrue("SUCCESS: Changed property dfs.datanode.peer.stats.enabled".equals(outs.get(2)) - || "SUCCESS: Changed property dfs.datanode.peer.stats.enabled".equals(outs.get(1))); - assertTrue("\tFrom: \"false\"".equals(outs.get(3)) || "\tFrom: \"false\"".equals(outs.get(2))); - assertTrue("\tTo: \"true\"".equals(outs.get(4)) || "\tTo: \"true\"".equals(outs.get(3))); - assertEquals("SUCCESS: Changed property dfs.datanode.peer.stats.enabled", outs.get(5)); - assertEquals("\tFrom: \"false\"", outs.get(6)); - assertEquals("\tTo: \"true\"", outs.get(7)); - assertEquals("Retrieval of reconfiguration status successful on 2 nodes, failed on 0 nodes.", - outs.get(8)); + Assertions.assertThat(outs.get(0)).startsWith("Reconfiguring status for node"); + String success = "SUCCESS: Changed property dfs.datanode.peer.stats.enabled"; + String from = "\tFrom: \"false\""; + String to = "\tTo: \"true\""; + String retrieval = + "Retrieval of reconfiguration status successful on 2 nodes, failed on 0 nodes."; + + Assertions.assertThat(outs.subList(1, 5)).containsSubsequence(success, from, to); + Assertions.assertThat(outs.subList(5, 9)).containsSubsequence(success, from, to, retrieval); } +} -} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org