HDFS-16934. TestDFSAdmin.testAllDatanodesReconfig regression (#5434)

Contributed by Shilun Fan
This commit is contained in:
slfan1989 2023-03-06 23:26:53 +08:00 committed by Steve Loughran
parent 157af0cb22
commit e12bc4e1d8
No known key found for this signature in database
GPG Key ID: D22CF846DBB162A0

View File

@ -76,6 +76,8 @@
import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.test.PathUtils; import org.apache.hadoop.test.PathUtils;
import org.apache.hadoop.util.ToolRunner; import org.apache.hadoop.util.ToolRunner;
import org.assertj.core.api.Assertions;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -1129,36 +1131,38 @@ public void testAllDatanodesReconfig()
when(reconfigurationUtil.parseChangedProperties(any(Configuration.class), when(reconfigurationUtil.parseChangedProperties(any(Configuration.class),
any(Configuration.class))).thenReturn(changes); 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> outsForStartReconf = new ArrayList<>();
final List<String> errsForStartReconf = new ArrayList<>(); final List<String> errsForStartReconf = new ArrayList<>();
reconfigurationOutErrFormatter("startReconfiguration", "datanode", reconfigurationOutErrFormatter("startReconfiguration", "datanode",
"livenodes", outsForStartReconf, errsForStartReconf); "livenodes", outsForStartReconf, errsForStartReconf);
assertEquals(3, outsForStartReconf.size()); String started = "Started reconfiguration task on node";
assertEquals(0, errsForStartReconf.size()); String starting =
assertTrue(outsForStartReconf.get(0).startsWith("Started reconfiguration task on node")); "Starting of reconfiguration task successful on 2 nodes, failed on 0 nodes.";
assertTrue(outsForStartReconf.get(1).startsWith("Started reconfiguration task on node")); Assertions.assertThat(outsForStartReconf).hasSize(3);
assertEquals("Starting of reconfiguration task successful on 2 nodes, failed on 0 nodes.", Assertions.assertThat(errsForStartReconf).hasSize(0);
outsForStartReconf.get(2)); Assertions.assertThat(outsForStartReconf.get(0)).startsWith(started);
Assertions.assertThat(outsForStartReconf.get(1)).startsWith(started);
Assertions.assertThat(outsForStartReconf.get(2)).startsWith(starting);
Thread.sleep(1000); Thread.sleep(1000);
final List<String> outs = new ArrayList<>(); final List<String> outs = new ArrayList<>();
final List<String> errs = new ArrayList<>(); final List<String> errs = new ArrayList<>();
awaitReconfigurationFinished("datanode", "livenodes", outs, errs); awaitReconfigurationFinished("datanode", "livenodes", outs, errs);
assertEquals(9, outs.size()); Assertions.assertThat(outs).hasSize(9);
assertEquals(0, errs.size()); Assertions.assertThat(errs).hasSize(0);
LOG.info("dfsadmin -status -livenodes output:"); LOG.info("dfsadmin -status -livenodes output:");
outs.forEach(s -> LOG.info("{}", s)); outs.forEach(s -> LOG.info("{}", s));
assertTrue(outs.get(0).startsWith("Reconfiguring status for node")); Assertions.assertThat(outs.get(0)).startsWith("Reconfiguring status for node");
assertTrue("SUCCESS: Changed property dfs.datanode.peer.stats.enabled".equals(outs.get(2)) String success = "SUCCESS: Changed property dfs.datanode.peer.stats.enabled";
|| "SUCCESS: Changed property dfs.datanode.peer.stats.enabled".equals(outs.get(1))); String from = "\tFrom: \"false\"";
assertTrue("\tFrom: \"false\"".equals(outs.get(3)) || "\tFrom: \"false\"".equals(outs.get(2))); String to = "\tTo: \"true\"";
assertTrue("\tTo: \"true\"".equals(outs.get(4)) || "\tTo: \"true\"".equals(outs.get(3))); String retrieval =
assertEquals("SUCCESS: Changed property dfs.datanode.peer.stats.enabled", outs.get(5)); "Retrieval of reconfiguration status successful on 2 nodes, failed on 0 nodes.";
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.subList(1, 5)).containsSubsequence(success, from, to);
Assertions.assertThat(outs.subList(5, 9)).containsSubsequence(success, from, to, retrieval);
}
} }