From 0bd0423ff5496fb0aa7afec6a030ca2f8d13c06b Mon Sep 17 00:00:00 2001 From: Vinayakumar B Date: Fri, 5 Sep 2014 10:25:09 +0530 Subject: [PATCH] HDFS-6714. TestBlocksScheduledCounter#testBlocksScheduledCounter should shutdown cluster (vinayakumarb) (cherry picked from commit 772d1fb01e65ca42ef4365d2a9307da6c2448c3f) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hdfs/TestBlocksScheduledCounter.java | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index c921c3a32c6..ef3ced9d60c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -436,6 +436,9 @@ Release 2.6.0 - UNRELEASED HDFS-6905. fs-encryption merge triggered release audit failures. (clamb via tucu) + HDFS-6714. TestBlocksScheduledCounter#testBlocksScheduledCounter should + shutdown cluster (vinayakumarb) + Release 2.5.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestBlocksScheduledCounter.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestBlocksScheduledCounter.java index 59dbb302c4b..a66cd1d8b58 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestBlocksScheduledCounter.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestBlocksScheduledCounter.java @@ -27,6 +27,7 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor; import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeManager; +import org.junit.After; import org.junit.Test; /** @@ -35,14 +36,25 @@ import org.junit.Test; * scheduled to a datanode. */ public class TestBlocksScheduledCounter { + MiniDFSCluster cluster = null; + FileSystem fs = null; + + @After + public void tearDown() throws IOException { + if (fs != null) { + fs.close(); + } + if(cluster!=null){ + cluster.shutdown(); + } + } @Test public void testBlocksScheduledCounter() throws IOException { - MiniDFSCluster cluster = new MiniDFSCluster.Builder(new HdfsConfiguration()) - .build(); + cluster = new MiniDFSCluster.Builder(new HdfsConfiguration()).build(); cluster.waitActive(); - FileSystem fs = cluster.getFileSystem(); + fs = cluster.getFileSystem(); //open a file an write a few bytes: FSDataOutputStream out = fs.create(new Path("/testBlockScheduledCounter"));