zhtttylz commented on code in PR #6504:
URL: https://github.com/apache/hadoop/pull/6504#discussion_r1469631441
##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSAdmin.java:
##########
@@ -1283,4 +1285,90 @@ public void testAllDatanodesReconfig()
Assertions.assertThat(outs.subList(1, 5)).containsSubsequence(success,
from, to);
Assertions.assertThat(outs.subList(5, 9)).containsSubsequence(success,
from, to, retrieval);
}
+
+ @Test
+ public void testDecommissionDataNodesReconfig()
+ throws IOException, InterruptedException, TimeoutException {
+ redirectStream();
+
+ ReconfigurationUtil reconfigurationUtil = mock(ReconfigurationUtil.class);
+ cluster.getDataNodes().get(0).setReconfigurationUtil(reconfigurationUtil);
+ cluster.getDataNodes().get(1).setReconfigurationUtil(reconfigurationUtil);
+ List<ReconfigurationUtil.PropertyChange> changes = new ArrayList<>();
+ changes.add(new ReconfigurationUtil.PropertyChange(
+ DFS_DATANODE_DATA_TRANSFER_BANDWIDTHPERSEC_KEY
+ , "1000",
+
datanode.getConf().get(DFS_DATANODE_DATA_TRANSFER_BANDWIDTHPERSEC_KEY)));
+ when(reconfigurationUtil.parseChangedProperties(any(Configuration.class),
+ any(Configuration.class))).thenReturn(changes);
+
+ DFSAdmin dfsAdmin = Mockito.spy(new DFSAdmin(conf));
+ DistributedFileSystem dfs = Mockito.spy(cluster.getFileSystem());
+ DatanodeInfo decommissionNode = dfs.getDataNodeStats()[0];
+ DatanodeInfo[] dataNodeStats = new DatanodeInfo[]{decommissionNode};
+ when(dfsAdmin.getDFS()).thenReturn(dfs);
+
when(dfs.getDataNodeStats(DatanodeReportType.DECOMMISSIONING)).thenReturn(dataNodeStats);
+
+ int ret = dfsAdmin.startReconfiguration("datanode", "decomnodes");
+
+ // collect outputs
+ final List<String> outsForStartReconf = Lists.newArrayList();
+ final List<String> errsForStartReconf = Lists.newArrayList();
+ scanIntoList(out, outsForStartReconf);
+ scanIntoList(err, errsForStartReconf);
+
+ // verify startReconfiguration results is as expected
+ assertEquals(0, ret);
+ String started = "Started reconfiguration task on node";
+ String starting =
+ "Starting of reconfiguration task successful on 1 nodes, failed on 0
nodes.";
Review Comment:
Thanks for the guidance! I will expedite the code revisions accordingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]