HDFS-9297. Update TestBlockMissingException to use corruptBlockOnDataNodesByDeletingBlockFile(). (Tony Wu via lei)

(cherry picked from commit 5679e46b7f)
This commit is contained in:
Lei Xu 2015-10-23 17:42:23 -07:00
parent 558ae8c2df
commit 509185c224
2 changed files with 5 additions and 13 deletions

View File

@ -766,6 +766,9 @@ Release 2.8.0 - UNRELEASED
HDFS-9280. Document NFS gateway export point parameter. (Xiao Chen via zhz) HDFS-9280. Document NFS gateway export point parameter. (Xiao Chen via zhz)
HDFS-9297. Update TestBlockMissingException to use corruptBlockOnDataNodesByDeletingBlockFile().
(Tony Wu via lei)
BUG FIXES BUG FIXES
HDFS-8091: ACLStatus and XAttributes should be presented to HDFS-8091: ACLStatus and XAttributes should be presented to

View File

@ -67,7 +67,8 @@ public void testBlockMissingException() throws Exception {
0, numBlocks * blockSize); 0, numBlocks * blockSize);
// remove block of file // remove block of file
LOG.info("Remove first block of file"); LOG.info("Remove first block of file");
corruptBlock(file1, locations.get(0).getBlock()); dfs.corruptBlockOnDataNodesByDeletingBlockFile(
locations.get(0).getBlock());
// validate that the system throws BlockMissingException // validate that the system throws BlockMissingException
validateFile(fileSys, file1); validateFile(fileSys, file1);
@ -118,16 +119,4 @@ private void validateFile(FileSystem fileSys, Path name)
stm.close(); stm.close();
assertTrue("Expected BlockMissingException ", gotException); assertTrue("Expected BlockMissingException ", gotException);
} }
//
// Corrupt specified block of file
//
void corruptBlock(Path file, ExtendedBlock blk) {
// Now deliberately remove/truncate data blocks from the file.
File[] blockFiles = dfs.getAllBlockFiles(blk);
for (File f : blockFiles) {
f.delete();
LOG.info("Deleted block " + f);
}
}
} }