HADOOP-14306. TestLocalFileSystem tests have very low timeouts. Contributed by Eric Badger

(cherry picked from commit cedaf4cab9d5013acd559dcb92d4976823ccdf85)
This commit is contained in:
Jason Lowe 2017-05-02 16:50:51 -05:00
parent b337a1da31
commit 9e9c3a511c

View File

@ -40,7 +40,9 @@
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Timeout;
import org.mockito.internal.util.reflection.Whitebox;
@ -56,6 +58,17 @@ public class TestLocalFileSystem {
private Configuration conf;
private LocalFileSystem fileSys;
/**
* standard test timeout: {@value}.
*/
public static final int DEFAULT_TEST_TIMEOUT = 60 * 1000;
/**
* Set the timeout for every test.
*/
@Rule
public Timeout testTimeout = new Timeout(DEFAULT_TEST_TIMEOUT);
private void cleanupFile(FileSystem fs, Path name) throws IOException {
assertTrue(fs.exists(name));
fs.delete(name, true);
@ -81,7 +94,7 @@ public void after() throws IOException {
/**
* Test the capability of setting the working directory.
*/
@Test(timeout = 10000)
@Test
public void testWorkingDirectory() throws IOException {
Path origDir = fileSys.getWorkingDirectory();
Path subdir = new Path(TEST_ROOT_DIR, "new");
@ -135,7 +148,7 @@ public void testWorkingDirectory() throws IOException {
* test Syncable interface on raw local file system
* @throws IOException
*/
@Test(timeout = 1000)
@Test
public void testSyncable() throws IOException {
FileSystem fs = fileSys.getRawFileSystem();
Path file = new Path(TEST_ROOT_DIR, "syncable");
@ -168,7 +181,7 @@ private void verifyFile(FileSystem fs, Path file, int bytesToVerify,
}
}
@Test(timeout = 10000)
@Test
public void testCopy() throws IOException {
Path src = new Path(TEST_ROOT_DIR, "dingo");
Path dst = new Path(TEST_ROOT_DIR, "yak");
@ -194,7 +207,7 @@ public void testCopy() throws IOException {
}
}
@Test(timeout = 1000)
@Test
public void testHomeDirectory() throws IOException {
Path home = new Path(System.getProperty("user.home"))
.makeQualified(fileSys);
@ -202,7 +215,7 @@ public void testHomeDirectory() throws IOException {
assertEquals(home, fsHome);
}
@Test(timeout = 1000)
@Test
public void testPathEscapes() throws IOException {
Path path = new Path(TEST_ROOT_DIR, "foo%bar");
writeFile(fileSys, path, 1);
@ -211,7 +224,7 @@ public void testPathEscapes() throws IOException {
cleanupFile(fileSys, path);
}
@Test(timeout = 1000)
@Test
public void testCreateFileAndMkdirs() throws IOException {
Path test_dir = new Path(TEST_ROOT_DIR, "test_dir");
Path test_file = new Path(test_dir, "file1");
@ -247,7 +260,7 @@ public void testCreateFileAndMkdirs() throws IOException {
}
/** Test deleting a file, directory, and non-existent path */
@Test(timeout = 1000)
@Test
public void testBasicDelete() throws IOException {
Path dir1 = new Path(TEST_ROOT_DIR, "dir1");
Path file1 = new Path(TEST_ROOT_DIR, "file1");
@ -262,7 +275,7 @@ public void testBasicDelete() throws IOException {
assertTrue("Did not delete non-empty dir", fileSys.delete(dir1));
}
@Test(timeout = 1000)
@Test
public void testStatistics() throws Exception {
int fileSchemeCount = 0;
for (Statistics stats : FileSystem.getAllStatistics()) {
@ -273,7 +286,7 @@ public void testStatistics() throws Exception {
assertEquals(1, fileSchemeCount);
}
@Test(timeout = 1000)
@Test
public void testHasFileDescriptor() throws IOException {
Path path = new Path(TEST_ROOT_DIR, "test-file");
writeFile(fileSys, path, 1);
@ -283,7 +296,7 @@ public void testHasFileDescriptor() throws IOException {
bis.close();
}
@Test(timeout = 1000)
@Test
public void testListStatusWithColons() throws IOException {
assumeTrue(!Shell.WINDOWS);
File colonFile = new File(TEST_ROOT_DIR, "foo:bar");
@ -309,7 +322,7 @@ public void testListStatusReturnConsistentPathOnWindows() throws IOException {
stats[0].getPath().toUri().getPath());
}
@Test(timeout = 10000)
@Test
public void testReportChecksumFailure() throws IOException {
base.mkdirs();
assertTrue(base.exists() && base.isDirectory());
@ -389,7 +402,7 @@ private void checkTimesStatus(Path path,
assertEquals(expectedAccTime, status.getAccessTime());
}
@Test(timeout = 1000)
@Test
public void testSetTimes() throws Exception {
Path path = new Path(TEST_ROOT_DIR, "set-times");
writeFile(fileSys, path, 1);