hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mingliang Liu (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-10972) Add unit test for HDFS command 'dfsadmin -getDatanodeInfo'
Date Thu, 06 Oct 2016 22:21:20 GMT

    [ https://issues.apache.org/jira/browse/HDFS-10972?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15553388#comment-15553388
] 

Mingliang Liu commented on HDFS-10972:
--------------------------------------

Thanks for the patch. I think this UT is useful. I'll confirm that the command is not covered
yet by the current tests.

# Adding support to redirect System.out in {{DFSAdmin}} per se is not preferred.
{code}
final DFSAdmin dfsAdmin = new DFSAdmin(dfsConf, out, err);
{code}
If your goal is to test the System.out output message, you can use {{System.setOut()}}. Code
snippet like:
{code}
final PrintStream stdout = System.out;
try {
  final PrintStream out = new PrintStream();
  System.setOut(out);
  // ...
} finally {
  System.setOut(stdout);
}
{code}
# timeout is good for unit tests.
{code}
142	  //@Test(timeout = 30000)
143	  @Test
{code}
# {{scanIntoList()}} considered static?
# {{miniCluster}} can be used in try-with-resource style. Code snippet as:
{code}
try (MiniDFSCluster cluster = new MiniDFSCluster.Builder(dfsConf).numDataNodes(numDn).build())
{
  cluster.waitForActive();
  // ...
}
{code}
# I don't like the coding style (IMHO, shorter is better, if not losing readability). Can
you confirm that it adheres to the Hadoop coding guide?
{code}
170	        /* invoke getDatanodeInfo */
171	        final int ret = ToolRunner.run(
172	            dfsAdmin,
173	            new String[] {
174	                "-getDatanodeInfo",
175	                String.format(
176	                    "%s:%d",
177	                    dn.getXferAddress().getHostString(),
178	                    dn.getIpcPort()) });
179	
{code}
# Can you add failing message to the assertion {{assertEquals(1, outs.size());}} as it's not
straightforward why the size is 1 (one line per DN I guess?)

> Add unit test for HDFS command 'dfsadmin -getDatanodeInfo'
> ----------------------------------------------------------
>
>                 Key: HDFS-10972
>                 URL: https://issues.apache.org/jira/browse/HDFS-10972
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: fs, shell, test
>            Reporter: Xiaobing Zhou
>            Assignee: Xiaobing Zhou
>         Attachments: HDFS-10972.000.patch
>
>
> getDatanodeInfo should be tested in admin CLI.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-help@hadoop.apache.org


Mime
View raw message