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 om...@apache.org on 2008/05/22 18:43:53 UTC
svn commit: r659152 - in /hadoop/core/trunk: CHANGES.txt
src/test/org/apache/hadoop/dfs/TestFsck.java
Author: omalley
Date: Thu May 22 09:43:52 2008
New Revision: 659152
URL: http://svn.apache.org/viewvc?rev=659152&view=rev
Log:
HADOOP-3419. Fixes TestFsck to wait for updates to happen before
checking results to make the test more reliable. Contributed by Lohit Vijaya
Renu.
Modified:
hadoop/core/trunk/CHANGES.txt
hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestFsck.java
Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=659152&r1=659151&r2=659152&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Thu May 22 09:43:52 2008
@@ -323,6 +323,10 @@
HADOOP-3351. Fixes the history viewer tool to not do huge StringBuffer
allocations. (Amareshwari Sriramadasu via ddas)
+ HADOOP-3419. Fixes TestFsck to wait for updates to happen before
+ checking results to make the test more reliable. (Lohit Vijaya
+ Renu via omalley)
+
Release 0.17.0 - 2008-05-18
INCOMPATIBLE CHANGES
Modified: hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestFsck.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestFsck.java?rev=659152&r1=659151&r2=659152&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestFsck.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestFsck.java Thu May 22 09:43:52 2008
@@ -66,6 +66,7 @@
cluster = new MiniDFSCluster(conf, 4, true, null);
fs = cluster.getFileSystem();
util.createFiles(fs, "/srcdat");
+ util.waitReplication(fs, "/srcdat", (short)3);
String outStr = runFsck(conf, "/");
assertTrue(-1 != outStr.indexOf("HEALTHY"));
System.out.println(outStr);
@@ -100,6 +101,7 @@
cluster = new MiniDFSCluster(conf, 4, true, null);
fs = cluster.getFileSystem();
util.createFiles(fs, "/srcdat");
+ util.waitReplication(fs, "/srcdat", (short)3);
String outStr = runFsck(conf, "/non-existent");
assertEquals(-1, outStr.indexOf("HEALTHY"));
System.out.println(outStr);
@@ -122,6 +124,7 @@
fs = cluster.getFileSystem();
cluster.waitActive();
util.createFiles(fs, topDir);
+ util.waitReplication(fs, topDir, (short)3);
String outStr = runFsck(conf, "/");
assertTrue(outStr.contains("HEALTHY"));
@@ -140,15 +143,15 @@
}
}
- //Sleep for a while until block reports are sent to discover corruption
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- }
-
// We excpect the filesystem to be corrupted
outStr = runFsck(conf, "/");
- assertTrue(outStr.contains("CORRUPT"));
+ while (!outStr.contains("CORRUPT")) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException ignore) {
+ }
+ outStr = runFsck(conf, "/");
+ }
// Fix the filesystem by moving corrupted files to lost+found
outStr = runFsck(conf, "/", "-move");
@@ -178,6 +181,7 @@
fs = cluster.getFileSystem();
cluster.waitActive();
util.createFiles(fs, topDir);
+ util.waitReplication(fs, topDir, (short)3);
String outStr = runFsck(conf, "/");
assertTrue(outStr.contains("HEALTHY"));
// Open a file for writing and do not close for now
@@ -216,6 +220,7 @@
public void testCorruptBlock() throws Exception {
Configuration conf = new Configuration();
+ conf.setLong("dfs.blockreport.intervalMsec", 1000);
FileSystem fs = null;
DFSClient dfsClient = null;
LocatedBlocks blocks = null;
@@ -228,6 +233,8 @@
fs = cluster.getFileSystem();
Path file1 = new Path("/testCorruptBlock");
DFSTestUtil.createFile(fs, file1, 1024, (short)3, 0);
+ // Wait until file replication has completed
+ DFSTestUtil.waitReplication(fs, file1, (short)3);
String block = DFSTestUtil.getFirstBlock(fs, file1).getBlockName();
// Make sure filesystem is in healthy state
@@ -257,12 +264,21 @@
} catch (IOException ie) {
// Ignore exception
}
+
dfsClient = new DFSClient(new InetSocketAddress("localhost",
cluster.getNameNodePort()), conf);
blocks = dfsClient.namenode.
getBlockLocations(file1.toString(), 0, Long.MAX_VALUE);
replicaCount = blocks.get(0).getLocations().length;
- assertTrue (replicaCount == 3);
+ while (replicaCount != 3) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException ignore) {
+ }
+ blocks = dfsClient.namenode.
+ getBlockLocations(file1.toString(), 0, Long.MAX_VALUE);
+ replicaCount = blocks.get(0).getLocations().length;
+ }
assertTrue (blocks.get(0).isCorrupt());
// Check if fsck reports the same