Jelajahi Sumber

HDFS-10921. TestDiskspaceQuotaUpdate doesn't wait for NN to get out of safe mode. Contributed by Eric Badger

(cherry picked from commit 55e1fb8e3221941321e6f5e04b334246c5f23027)
Mingliang Liu 8 tahun lalu
induk
melakukan
cd07a8858c

+ 16 - 3
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDiskspaceQuotaUpdate.java

@@ -55,6 +55,7 @@ import org.apache.log4j.Logger;
 import org.apache.log4j.helpers.AppenderAttachableImpl;
 import org.junit.AfterClass;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -79,6 +80,18 @@ public class TestDiskspaceQuotaUpdate {
     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) {
@@ -255,7 +268,7 @@ public class TestDiskspaceQuotaUpdate {
     assertEquals(spaceUsed, newSpaceUsed);
     // make sure edits aren't corrupted
     getDFS().recoverLease(file);
-    cluster.restartNameNodes();
+    cluster.restartNameNode(true);
   }
 
   /**
@@ -298,7 +311,7 @@ public class TestDiskspaceQuotaUpdate {
     assertEquals(spaceUsed, newSpaceUsed);
     // make sure edits aren't corrupted
     getDFS().recoverLease(file);
-    cluster.restartNameNodes();
+    cluster.restartNameNode(true);
   }
 
   /**
@@ -338,7 +351,7 @@ public class TestDiskspaceQuotaUpdate {
     assertEquals(spaceUsed, newSpaceUsed);
     // make sure edits aren't corrupted
     getDFS().recoverLease(file);
-    cluster.restartNameNodes();
+    cluster.restartNameNode(true);
   }
 
   /**