commit 433120b87c32067946017ae380bc7d2caf9966df Author: Gera Shegalov Date: Tue May 6 03:11:29 2014 -0700 YARN-1542.v04.patch diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java index 4d0c8da..d07f493 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java @@ -63,9 +63,11 @@ import org.apache.hadoop.fs.FileContext; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.FsConstants; import org.apache.hadoop.fs.LocalDirAllocator; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.permission.FsPermission; +import org.apache.hadoop.fs.viewfs.ConfigUtil; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.yarn.api.records.LocalResource; import org.apache.hadoop.yarn.api.records.LocalResourceType; @@ -669,4 +671,38 @@ public void testUniqueDestinationPath() throws Exception { // destination directory (passed as an argument) + file name. Assert.assertEquals(destPath, rPath.get().getParent()); } + + @Test + public void testViewFsResource() throws Exception { + final Configuration conf = new Configuration(); + final FileContext files = FileContext.getLocalFSFileContext(conf); + final Path basedir = files.makeQualified(new Path("target", + getClass().getSimpleName())); + files.mkdir(basedir, null, true); + conf.setStrings(getClass().getName(), basedir.toString()); + + // create a public cache file + // + final Path cacheDir = new Path(basedir, "public-cache"); + files.mkdir(cacheDir, null, false); + ConfigUtil.addLink(conf, "/pubcache", cacheDir.toUri()); + final FileSystem vfs = FileSystem.get(FsConstants.VIEWFS_URI, conf); + final Path vfsCacheFile = vfs.makeQualified( + new Path("/pubcache/cache.txt")); + final Random rand = new Random(); + final long seed = rand.nextLong(); + rand.setSeed(seed); + System.out.println("SEED: " + seed); + final LocalResource rsrc = createFile(files, vfsCacheFile, 100, rand, + LocalResourceVisibility.PUBLIC); + + // set destination path + // + final LocalDirAllocator dirs = new LocalDirAllocator(getClass().getName()); + final Path path = new Path(basedir, "dest-" + rand.nextInt()); + final Path destPath = dirs.getLocalPathForWrite(path.toString(), conf); + final FSDownload fsd = new FSDownload(files, + UserGroupInformation.getCurrentUser(), conf, destPath, rsrc); + fsd.call(); + } }