diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java index afc977fc0e..d60e0253a8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java @@ -108,29 +108,35 @@ public void testClusterSetStorageCapacity() throws Throwable { capacities, defaultBlockSize, fileLen); - verifyStorageCapacity(cluster, capacities); + try { + verifyStorageCapacity(cluster, capacities); - /* restart all data nodes */ - cluster.restartDataNodes(); - cluster.waitActive(); - verifyStorageCapacity(cluster, capacities); + /* restart all data nodes */ + cluster.restartDataNodes(); + cluster.waitActive(); + verifyStorageCapacity(cluster, capacities); - /* restart all name nodes */ - cluster.restartNameNodes(); - cluster.waitActive(); - verifyStorageCapacity(cluster, capacities); + /* restart all name nodes */ + cluster.restartNameNodes(); + cluster.waitActive(); + verifyStorageCapacity(cluster, capacities); - /* restart all name nodes firstly and data nodes then */ - cluster.restartNameNodes(); - cluster.restartDataNodes(); - cluster.waitActive(); - verifyStorageCapacity(cluster, capacities); + /* restart all name nodes firstly and data nodes then */ + cluster.restartNameNodes(); + cluster.restartDataNodes(); + cluster.waitActive(); + verifyStorageCapacity(cluster, capacities); - /* restart all data nodes firstly and name nodes then */ - cluster.restartDataNodes(); - cluster.restartNameNodes(); - cluster.waitActive(); - verifyStorageCapacity(cluster, capacities); + /* restart all data nodes firstly and name nodes then */ + cluster.restartDataNodes(); + cluster.restartNameNodes(); + cluster.waitActive(); + verifyStorageCapacity(cluster, capacities); + } finally { + if (cluster != null) { + cluster.shutdown(); + } + } } private void verifyStorageCapacity(