You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ay...@apache.org on 2019/12/14 19:06:12 UTC
[hadoop] branch trunk updated: HDFS-15038. TestFsck
testFsckListCorruptSnapshotFiles is failing in trunk. Contributed by
hemanthboyina.
This is an automated email from the ASF dual-hosted git repository.
ayushsaxena pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 7a87007 HDFS-15038. TestFsck testFsckListCorruptSnapshotFiles is failing in trunk. Contributed by hemanthboyina.
7a87007 is described below
commit 7a8700754537353496b7546177a4706f3f1404cf
Author: Ayush Saxena <ay...@apache.org>
AuthorDate: Sun Dec 15 00:25:22 2019 +0530
HDFS-15038. TestFsck testFsckListCorruptSnapshotFiles is failing in trunk. Contributed by hemanthboyina.
---
.../hadoop/hdfs/server/namenode/TestFsck.java | 48 ++++++++++++----------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFsck.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFsck.java
index e4aed89..3bd7c4d 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFsck.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFsck.java
@@ -1151,17 +1151,7 @@ public class TestFsck {
}
}
- // 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 class TestFsck {
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 class TestFsck {
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;
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org