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 ce3e5b0..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 @@ -202,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(); @@ -239,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()) { @@ -252,7 +254,7 @@ public void testDownloadBadPublic() throws IOException, URISyntaxException, } } - @Test (timeout=10000) + @Test public void testDownload() throws IOException, URISyntaxException, InterruptedException { Configuration conf = new Configuration(); @@ -296,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(); @@ -322,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(); @@ -355,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) { @@ -413,6 +421,7 @@ public void testDownloadPatternJar() throws IOException, URISyntaxException, 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( @@ -437,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(); @@ -470,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) { @@ -526,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); @@ -566,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()) { @@ -590,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); @@ -615,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.