HDFS-3758. TestFuseDFS test failing. Contributed by Colin Patrick McCabe

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1371555 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2012-08-10 03:42:36 +00:00
parent 4bca22005f
commit bcb715459c
2 changed files with 50 additions and 7 deletions

View File

@ -583,6 +583,8 @@ Branch-2 ( Unreleased changes )
HDFS-3721. hsync support broke wire compatibility. (todd and atm) HDFS-3721. hsync support broke wire compatibility. (todd and atm)
HDFS-3758. TestFuseDFS test failing. (Colin Patrick McCabe via eli)
BREAKDOWN OF HDFS-3042 SUBTASKS BREAKDOWN OF HDFS-3042 SUBTASKS
HDFS-2185. HDFS portion of ZK-based FailoverController (todd) HDFS-2185. HDFS portion of ZK-based FailoverController (todd)

View File

@ -44,6 +44,7 @@ public class TestFuseDFS {
private static MiniDFSCluster cluster; private static MiniDFSCluster cluster;
private static FileSystem fs; private static FileSystem fs;
private static Process fuseProcess;
private static Runtime r; private static Runtime r;
private static String mountPoint; private static String mountPoint;
@ -137,8 +138,28 @@ private static void checkFile(File f, String expectedContents)
assertEquals("File content differs", expectedContents, s); assertEquals("File content differs", expectedContents, s);
} }
private static class RedirectToStdoutThread extends Thread {
private InputStream is;
RedirectToStdoutThread(InputStream is) {
this.is = is;
}
public void run() {
try {
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null) {
LOG.error("FUSE_LINE:" + line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
/** Run a fuse-dfs process to mount the given DFS */ /** Run a fuse-dfs process to mount the given DFS */
private static void establishMount(URI uri) throws IOException { private static Process establishMount(URI uri) throws IOException {
Runtime r = Runtime.getRuntime(); Runtime r = Runtime.getRuntime();
String cp = System.getProperty("java.class.path"); String cp = System.getProperty("java.class.path");
@ -163,6 +184,8 @@ private static void establishMount(URI uri) throws IOException {
"-obig_writes", // Allow >4kb writes "-obig_writes", // Allow >4kb writes
"-oentry_timeout=0.1", // Don't cache dents long "-oentry_timeout=0.1", // Don't cache dents long
"-oattribute_timeout=0.1", // Don't cache attributes long "-oattribute_timeout=0.1", // Don't cache attributes long
"-ononempty", // Don't complain about junk in mount point
"-f", // Don't background the process
"-ordbuffer=32768", // Read buffer size in kb "-ordbuffer=32768", // Read buffer size in kb
"rw" "rw"
}; };
@ -178,17 +201,35 @@ private static void establishMount(URI uri) throws IOException {
execAssertSucceeds("mkdir -p " + mountPoint); execAssertSucceeds("mkdir -p " + mountPoint);
// Mount the mini cluster // Mount the mini cluster
try { String cmdStr = "";
Process fuseProcess = r.exec(mountCmd, env); for (String c : mountCmd) {
assertEquals(0, fuseProcess.waitFor()); cmdStr += (" " + c);
} catch (InterruptedException ie) {
fail("Failed to mount");
} }
LOG.info("now mounting with:" + cmdStr);
Process fuseProcess = r.exec(mountCmd, env);
RedirectToStdoutThread stdoutThread =
new RedirectToStdoutThread(fuseProcess.getInputStream());
RedirectToStdoutThread stderrThread =
new RedirectToStdoutThread(fuseProcess.getErrorStream());
stdoutThread.start();
stderrThread.start();
// Wait for fusermount to start up, so that we know we're operating on the
// FUSE FS when we run the tests.
try {
Thread.sleep(50000);
} catch (InterruptedException e) {
}
return fuseProcess;
} }
/** Tear down the fuse-dfs process and mount */ /** Tear down the fuse-dfs process and mount */
private static void teardownMount() throws IOException { private static void teardownMount() throws IOException {
execWaitRet("fusermount -u " + mountPoint); execWaitRet("fusermount -u " + mountPoint);
try {
assertEquals(0, fuseProcess.waitFor()); // fuse_dfs should exit cleanly
} catch (InterruptedException e) {
fail("interrupted while waiting for fuse_dfs process to exit.");
}
} }
@BeforeClass @BeforeClass
@ -200,7 +241,7 @@ public static void startUp() throws IOException {
cluster = new MiniDFSCluster.Builder(conf).build(); cluster = new MiniDFSCluster.Builder(conf).build();
cluster.waitClusterUp(); cluster.waitClusterUp();
fs = cluster.getFileSystem(); fs = cluster.getFileSystem();
establishMount(fs.getUri()); fuseProcess = establishMount(fs.getUri());
} }
@AfterClass @AfterClass