HDFS-15038. TestFsck testFsckListCorruptSnapshotFiles is failing in trunk. Contributed by hemanthboyina.
This commit is contained in:
parent
72aee114f8
commit
7a87007545
@ -1151,17 +1151,7 @@ public void testFsckListCorruptFilesBlocks() throws Exception {
|
||||
}
|
||||
}
|
||||
|
||||
// wait for the namenode to see the corruption
|
||||
final NamenodeProtocols namenode = cluster.getNameNodeRpc();
|
||||
CorruptFileBlocks corruptFileBlocks = namenode
|
||||
.listCorruptFileBlocks("/corruptData", null);
|
||||
int numCorrupt = corruptFileBlocks.getFiles().length;
|
||||
while (numCorrupt == 0) {
|
||||
Thread.sleep(1000);
|
||||
corruptFileBlocks = namenode
|
||||
.listCorruptFileBlocks("/corruptData", null);
|
||||
numCorrupt = corruptFileBlocks.getFiles().length;
|
||||
}
|
||||
waitForCorruptionBlocks(3, "/corruptData");
|
||||
outStr = runFsck(conf, -1, true, "/corruptData", "-list-corruptfileblocks");
|
||||
System.out.println("2. bad fsck out: " + outStr);
|
||||
assertTrue(outStr.contains("has 3 CORRUPT files"));
|
||||
@ -2148,17 +2138,7 @@ public void testFsckListCorruptSnapshotFiles() throws Exception {
|
||||
hdfs.delete(fp, false);
|
||||
numFiles--;
|
||||
|
||||
// wait for the namenode to see the corruption
|
||||
final NamenodeProtocols namenode = cluster.getNameNodeRpc();
|
||||
CorruptFileBlocks corruptFileBlocks = namenode
|
||||
.listCorruptFileBlocks("/corruptData", null);
|
||||
int numCorrupt = corruptFileBlocks.getFiles().length;
|
||||
while (numCorrupt == 0) {
|
||||
Thread.sleep(1000);
|
||||
corruptFileBlocks = namenode
|
||||
.listCorruptFileBlocks("/corruptData", null);
|
||||
numCorrupt = corruptFileBlocks.getFiles().length;
|
||||
}
|
||||
waitForCorruptionBlocks(numSnapshots, "/corruptData");
|
||||
|
||||
// with -includeSnapshots all files are reported
|
||||
outStr = runFsck(conf, -1, true, "/corruptData",
|
||||
@ -2176,6 +2156,30 @@ public void testFsckListCorruptSnapshotFiles() throws Exception {
|
||||
assertFalse(outStr.contains("/.snapshot/"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the namenode to see the corruption.
|
||||
* @param corruptBlocks The expected number of corruptfilelocks
|
||||
* @param path The Directory Path where corruptfileblocks exists
|
||||
* @throws IOException
|
||||
*/
|
||||
private void waitForCorruptionBlocks(int corruptBlocks, String path)
|
||||
throws Exception {
|
||||
GenericTestUtils.waitFor(() -> {
|
||||
try {
|
||||
final NamenodeProtocols namenode = cluster.getNameNodeRpc();
|
||||
CorruptFileBlocks corruptFileBlocks =
|
||||
namenode.listCorruptFileBlocks(path, null);
|
||||
int numCorrupt = corruptFileBlocks.getFiles().length;
|
||||
if (numCorrupt == corruptBlocks) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Exception while getting Corrupt file blocks", e);
|
||||
}
|
||||
return false;
|
||||
}, 100, 10000);
|
||||
}
|
||||
|
||||
@Test (timeout = 300000)
|
||||
public void testFsckMoveAfterCorruption() throws Exception {
|
||||
final int dfsBlockSize = 512 * 1024;
|
||||
|
Loading…
Reference in New Issue
Block a user