diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java index af1e765..86ba0dd 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java @@ -34,6 +34,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; @@ -201,7 +202,7 @@ static LocalResource createZipFile(FileContext files, Path p, int len, return ret; } - @Test (timeout=10000) + @Test public void testDownloadBadPublic() throws IOException, URISyntaxException, InterruptedException { Configuration conf = new Configuration(); @@ -238,6 +239,8 @@ public void testDownloadBadPublic() throws IOException, URISyntaxException, new FSDownload(files, UserGroupInformation.getCurrentUser(), conf, destPath, rsrc); pending.put(rsrc, exec.submit(fsd)); + while (exec.awaitTermination(1000, TimeUnit.MILLISECONDS)); + Assert.assertTrue(pending.get(rsrc).isDone()); try { for (Map.Entry> p : pending.entrySet()) { @@ -251,7 +254,7 @@ public void testDownloadBadPublic() throws IOException, URISyntaxException, } } - @Test (timeout=10000) + @Test public void testDownload() throws IOException, URISyntaxException, InterruptedException { Configuration conf = new Configuration(); @@ -295,6 +298,11 @@ public void testDownload() throws IOException, URISyntaxException, pending.put(rsrc, exec.submit(fsd)); } + while (exec.awaitTermination(1000, TimeUnit.MILLISECONDS)); + for (Future path: pending.values()) { + Assert.assertTrue(path.isDone()); + } + try { for (Map.Entry> p : pending.entrySet()) { Path localized = p.getValue().get(); @@ -321,8 +329,7 @@ public void testDownload() throws IOException, URISyntaxException, } } - @SuppressWarnings("deprecation") - @Test (timeout=10000) + @Test public void testDownloadArchive() throws IOException, URISyntaxException, InterruptedException { Configuration conf = new Configuration(); @@ -354,12 +361,14 @@ public void testDownloadArchive() throws IOException, URISyntaxException, FSDownload fsd = new FSDownload(files, UserGroupInformation.getCurrentUser(), conf, destPath, rsrc); pending.put(rsrc, exec.submit(fsd)); + while (exec.awaitTermination(1000, TimeUnit.MILLISECONDS)); + Assert.assertTrue(pending.get(rsrc).isDone()); try { FileStatus[] filesstatus = files.getDefaultFileSystem().listStatus( basedir); for (FileStatus filestatus : filesstatus) { - if (filestatus.isDir()) { + if (filestatus.isDirectory()) { FileStatus[] childFiles = files.getDefaultFileSystem().listStatus( filestatus.getPath()); for (FileStatus childfile : childFiles) { @@ -377,9 +386,8 @@ public void testDownloadArchive() throws IOException, URISyntaxException, exec.shutdown(); } } - - @SuppressWarnings("deprecation") - @Test (timeout=10000) + + @Test public void testDownloadPatternJar() throws IOException, URISyntaxException, InterruptedException { Configuration conf = new Configuration(); @@ -412,12 +420,14 @@ public void testDownloadPatternJar() throws IOException, URISyntaxException, FSDownload fsdjar = new FSDownload(files, UserGroupInformation.getCurrentUser(), conf, destPathjar, rsrcjar); pending.put(rsrcjar, exec.submit(fsdjar)); + while (exec.awaitTermination(1000, TimeUnit.MILLISECONDS)); + Assert.assertTrue(pending.get(rsrcjar).isDone()); try { FileStatus[] filesstatus = files.getDefaultFileSystem().listStatus( basedir); for (FileStatus filestatus : filesstatus) { - if (filestatus.isDir()) { + if (filestatus.isDirectory()) { FileStatus[] childFiles = files.getDefaultFileSystem().listStatus( filestatus.getPath()); for (FileStatus childfile : childFiles) { @@ -436,8 +446,7 @@ public void testDownloadPatternJar() throws IOException, URISyntaxException, } } - @SuppressWarnings("deprecation") - @Test (timeout=10000) + @Test public void testDownloadArchiveZip() throws IOException, URISyntaxException, InterruptedException { Configuration conf = new Configuration(); @@ -469,12 +478,14 @@ public void testDownloadArchiveZip() throws IOException, URISyntaxException, FSDownload fsdzip = new FSDownload(files, UserGroupInformation.getCurrentUser(), conf, destPathjar, rsrczip); pending.put(rsrczip, exec.submit(fsdzip)); + while (exec.awaitTermination(1000, TimeUnit.MILLISECONDS)); + Assert.assertTrue(pending.get(rsrczip).isDone()); try { FileStatus[] filesstatus = files.getDefaultFileSystem().listStatus( basedir); for (FileStatus filestatus : filesstatus) { - if (filestatus.isDir()) { + if (filestatus.isDirectory()) { FileStatus[] childFiles = files.getDefaultFileSystem().listStatus( filestatus.getPath()); for (FileStatus childfile : childFiles) { @@ -525,7 +536,7 @@ private void verifyPermsRecursively(FileSystem fs, } } - @Test (timeout=10000) + @Test public void testDirDownload() throws IOException, InterruptedException { Configuration conf = new Configuration(); FileContext files = FileContext.getLocalFSFileContext(conf); @@ -565,7 +576,12 @@ public void testDirDownload() throws IOException, InterruptedException { destPath, rsrc); pending.put(rsrc, exec.submit(fsd)); } - + + while (exec.awaitTermination(1000, TimeUnit.MILLISECONDS)); + for (Future path: pending.values()) { + Assert.assertTrue(path.isDone()); + } + try { for (Map.Entry> p : pending.entrySet()) { @@ -589,7 +605,7 @@ public void testDirDownload() throws IOException, InterruptedException { } - @Test(timeout = 1000) + @Test public void testUniqueDestinationPath() throws Exception { Configuration conf = new Configuration(); FileContext files = FileContext.getLocalFSFileContext(conf); @@ -614,6 +630,8 @@ public void testUniqueDestinationPath() throws Exception { new FSDownload(files, UserGroupInformation.getCurrentUser(), conf, destPath, rsrc); Future rPath = singleThreadedExec.submit(fsd); + while (singleThreadedExec.awaitTermination(1000, TimeUnit.MILLISECONDS)); + Assert.assertTrue(rPath.isDone()); // Now FSDownload will not create a random directory to localize the // resource. Therefore the final localizedPath for the resource should be // destination directory (passed as an argument) + file name.