diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDiskspaceQuotaUpdate.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDiskspaceQuotaUpdate.java index 4b0ac081950..bb793fe67c9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDiskspaceQuotaUpdate.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDiskspaceQuotaUpdate.java @@ -52,6 +52,7 @@ import org.apache.hadoop.test.GenericTestUtils.LogCapturer; import org.junit.AfterClass; import org.junit.Assert; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; @@ -76,6 +77,18 @@ public static void setUp() throws Exception { cluster.waitActive(); } + @Before + public void resetCluster() throws Exception { + if (!cluster.isClusterUp()) { + // Previous test seems to have left cluster in a bad state; + // recreate the cluster to protect subsequent tests + cluster.shutdown(); + cluster = new MiniDFSCluster.Builder(conf).numDataNodes(REPLICATION) + .build(); + cluster.waitActive(); + } + } + @AfterClass public static void tearDown() throws Exception { if (cluster != null) { @@ -254,7 +267,7 @@ public void testAppendOverStorageQuota() throws Exception { assertEquals(spaceUsed, newSpaceUsed); // make sure edits aren't corrupted getDFS().recoverLease(file); - cluster.restartNameNodes(); + cluster.restartNameNode(true); } /** @@ -297,7 +310,7 @@ public void testAppendOverTypeQuota() throws Exception { assertEquals(spaceUsed, newSpaceUsed); // make sure edits aren't corrupted getDFS().recoverLease(file); - cluster.restartNameNodes(); + cluster.restartNameNode(true); } /** @@ -337,7 +350,7 @@ public void testTruncateOverQuota() throws Exception { assertEquals(spaceUsed, newSpaceUsed); // make sure edits aren't corrupted getDFS().recoverLease(file); - cluster.restartNameNodes(); + cluster.restartNameNode(true); } /**