|
@@ -1471,4 +1471,41 @@ public class TestFsck {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Test(timeout = 300000)
|
|
|
+ public void testFsckCorruptWhenOneReplicaIsCorrupt()
|
|
|
+ throws Exception {
|
|
|
+ Configuration conf = new HdfsConfiguration();
|
|
|
+ final MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
|
|
|
+ .nnTopology(MiniDFSNNTopology.simpleHATopology()).numDataNodes(2)
|
|
|
+ .build();
|
|
|
+ try {
|
|
|
+ cluster.waitActive();
|
|
|
+ FileSystem fs = HATestUtil.configureFailoverFs(cluster, conf);
|
|
|
+ cluster.transitionToActive(0);
|
|
|
+ String filePath = "/appendTest";
|
|
|
+ Path fileName = new Path(filePath);
|
|
|
+ DFSTestUtil.createFile(fs, fileName, 512, (short) 2, 0);
|
|
|
+ DFSTestUtil.waitReplication(fs, fileName, (short) 2);
|
|
|
+ assertTrue("File not created", fs.exists(fileName));
|
|
|
+ cluster.getDataNodes().get(1).shutdown();
|
|
|
+ DFSTestUtil.appendFile(fs, fileName, "appendCorruptBlock");
|
|
|
+ cluster.restartDataNode(1, true);
|
|
|
+ GenericTestUtils.waitFor(new Supplier<Boolean>() {
|
|
|
+ @Override
|
|
|
+ public Boolean get() {
|
|
|
+ return (
|
|
|
+ cluster.getNameNode(0).getNamesystem().getCorruptReplicaBlocks()
|
|
|
+ > 0);
|
|
|
+ }
|
|
|
+ }, 100, 5000);
|
|
|
+
|
|
|
+ DFSTestUtil.appendFile(fs, fileName, "appendCorruptBlock");
|
|
|
+ runFsck(cluster.getConfiguration(0), 0, true, "/");
|
|
|
+ }finally {
|
|
|
+ if(cluster!=null){
|
|
|
+ cluster.shutdown();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|