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

Xiaoyu Yao commented on HDFS-9354:
----------------------------------

Thanks [~cnauroth] for reviewing the patch and providing helpful suggestions. 

bq. 1. We could add a JUnit @After method that always shuts down cluster if it 
is non-null. Then, the individual tests wouldn't need to do try-finally, and 
any new tests that get added over time will get the automatic shutdown for 
free. This would require a bigger patch though.

That's a good idea and I had similar thoughts too. Compared with the small 
change in patch v0, it would require a bigger patch as you mentioned but can 
help us avoid leaks in future. I can update the patch based on that.

bq. 2. The check for HadoopIllegalArgumentException could be simplified by 
using JUnit's ExpectedException rule. If you'd like to see a simple example of 
this, I recommend looking at TestAclConfigFlag.

My understanding of "Rule and ExpectedException" (JUnit 4.7) is an alternative 
to the @Test(expected= HadoopIllegalArgumentException.class), which allows 
finer grain validation of exception message. But both will need to rely on 
JUnit @After method to ensure cluster is shutdown upon exception. 

> Fix TestBalancer#testBalancerWithZeroThreadsForMove on Windows
> --------------------------------------------------------------
>
>                 Key: HDFS-9354
>                 URL: https://issues.apache.org/jira/browse/HDFS-9354
>             Project: Hadoop HDFS
>          Issue Type: Test
>            Reporter: Xiaoyu Yao
>            Assignee: Xiaoyu Yao
>         Attachments: HDFS-9354.00.patch
>
>
> This negative test expect HadoopIllegalArgumentException on illegal 
> configuration. It uses JUnit (expected=HadoopIllegalArgumentException.class)  
> and passed fine on Linux.
> On windows, this test passes as well. But it left open handles on NN metadata 
> directories used by MiniDFSCluster. As a result, quite a few of subsequent 
> TestBalancer unit tests can't start MiniDFSCluster. The open handles prevents 
> them from cleaning up NN metadata directories on Windows. 
> This JIRA is opened to explicitly catch the Exception and ensure the test 
> cluster is properly shutdown.



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

Reply via email to