Browse Source

HDFS-8975. Erasure coding : Fix random failure in TestSafeModeWithStripedFile (Contributed by J.Andreina)

Vinayakumar B 9 years ago
parent
commit
ce02b5532c

+ 4 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt

@@ -418,3 +418,7 @@
 
 
     HDFS-8853. Erasure Coding: Provide ECSchema validation when setting EC
     HDFS-8853. Erasure Coding: Provide ECSchema validation when setting EC
     policy. (andreina via zhz)
     policy. (andreina via zhz)
+
+    HDFS-8975. Erasure coding : Fix random failure in TestSafeModeWithStripedFile
+    (J.Andreina via vinayakumarb)
+

+ 5 - 0
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeModeWithStripedFile.java

@@ -53,6 +53,7 @@ public class TestSafeModeWithStripedFile {
   public void setup() throws IOException {
   public void setup() throws IOException {
     conf = new HdfsConfiguration();
     conf = new HdfsConfiguration();
     conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, blockSize);
     conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, blockSize);
+    conf.setLong(DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_KEY, 100);
     cluster = new MiniDFSCluster.Builder(conf).numDataNodes(numDNs).build();
     cluster = new MiniDFSCluster.Builder(conf).numDataNodes(numDNs).build();
     cluster.getFileSystem().getClient().setErasureCodingPolicy("/", null);
     cluster.getFileSystem().getClient().setErasureCodingPolicy("/", null);
     cluster.waitActive();
     cluster.waitActive();
@@ -124,6 +125,7 @@ public class TestSafeModeWithStripedFile {
     // so the safe blocks count doesn't increment.
     // so the safe blocks count doesn't increment.
     for (int i = 0; i < minStorages - 1; i++) {
     for (int i = 0; i < minStorages - 1; i++) {
       cluster.restartDataNode(dnprops.remove(0));
       cluster.restartDataNode(dnprops.remove(0));
+      cluster.waitActive();
       cluster.triggerBlockReports();
       cluster.triggerBlockReports();
       assertEquals(0, NameNodeAdapter.getSafeModeSafeBlocks(nn));
       assertEquals(0, NameNodeAdapter.getSafeModeSafeBlocks(nn));
     }
     }
@@ -131,17 +133,20 @@ public class TestSafeModeWithStripedFile {
     // the block of smallFile reaches minStorages,
     // the block of smallFile reaches minStorages,
     // so the safe blocks count increment.
     // so the safe blocks count increment.
     cluster.restartDataNode(dnprops.remove(0));
     cluster.restartDataNode(dnprops.remove(0));
+    cluster.waitActive();
     cluster.triggerBlockReports();
     cluster.triggerBlockReports();
     assertEquals(1, NameNodeAdapter.getSafeModeSafeBlocks(nn));
     assertEquals(1, NameNodeAdapter.getSafeModeSafeBlocks(nn));
 
 
     // the 2 blocks of bigFile need DATA_BLK_NUM storages to be safe
     // the 2 blocks of bigFile need DATA_BLK_NUM storages to be safe
     for (int i = minStorages; i < DATA_BLK_NUM - 1; i++) {
     for (int i = minStorages; i < DATA_BLK_NUM - 1; i++) {
       cluster.restartDataNode(dnprops.remove(0));
       cluster.restartDataNode(dnprops.remove(0));
+      cluster.waitActive();
       cluster.triggerBlockReports();
       cluster.triggerBlockReports();
       assertTrue(nn.isInSafeMode());
       assertTrue(nn.isInSafeMode());
     }
     }
 
 
     cluster.restartDataNode(dnprops.remove(0));
     cluster.restartDataNode(dnprops.remove(0));
+    cluster.waitActive();
     cluster.triggerBlockReports();
     cluster.triggerBlockReports();
     assertFalse(nn.isInSafeMode());
     assertFalse(nn.isInSafeMode());
   }
   }