HADOOP-6933. TestListFiles is flaky. Contributed by Todd Lipcon.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1005581 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas White 2010-10-07 19:11:45 +00:00
parent bf9fccca0c
commit a503521a2c
2 changed files with 18 additions and 3 deletions

View File

@ -256,6 +256,8 @@ Trunk (unreleased changes)
HADOOP-6984. Combine the compress kind and the codec in the same option HADOOP-6984. Combine the compress kind and the codec in the same option
for SequenceFiles. (cdouglas via omalley) for SequenceFiles. (cdouglas via omalley)
HADOOP-6933. TestListFiles is flaky. (Todd Lipcon via tomwhite)
Release 0.21.1 - Unreleased Release 0.21.1 - Unreleased
IMPROVEMENTS IMPROVEMENTS

View File

@ -19,7 +19,9 @@ package org.apache.hadoop.fs;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
import java.util.HashSet;
import java.util.Random; import java.util.Random;
import java.util.Set;
import org.apache.commons.logging.impl.Log4JLogger; import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
@ -135,17 +137,28 @@ public class TestListFiles {
writeFile(fs, FILE1, FILE_LEN); writeFile(fs, FILE1, FILE_LEN);
writeFile(fs, FILE3, FILE_LEN); writeFile(fs, FILE3, FILE_LEN);
Set<Path> filesToFind = new HashSet<Path>();
filesToFind.add(fs.makeQualified(FILE1));
filesToFind.add(fs.makeQualified(FILE2));
filesToFind.add(fs.makeQualified(FILE3));
itor = fs.listFiles(TEST_DIR, true); itor = fs.listFiles(TEST_DIR, true);
stat = itor.next(); stat = itor.next();
assertTrue(stat.isFile()); assertTrue(stat.isFile());
assertEquals(fs.makeQualified(FILE2), stat.getPath()); assertTrue("Path " + stat.getPath() + " unexpected",
filesToFind.remove(stat.getPath()));
stat = itor.next(); stat = itor.next();
assertTrue(stat.isFile()); assertTrue(stat.isFile());
assertEquals(fs.makeQualified(FILE3), stat.getPath()); assertTrue("Path " + stat.getPath() + " unexpected",
filesToFind.remove(stat.getPath()));
stat = itor.next(); stat = itor.next();
assertTrue(stat.isFile()); assertTrue(stat.isFile());
assertEquals(fs.makeQualified(FILE1), stat.getPath()); assertTrue("Path " + stat.getPath() + " unexpected",
filesToFind.remove(stat.getPath()));
assertFalse(itor.hasNext()); assertFalse(itor.hasNext());
assertTrue(filesToFind.isEmpty());
itor = fs.listFiles(TEST_DIR, false); itor = fs.listFiles(TEST_DIR, false);
stat = itor.next(); stat = itor.next();