public virtual void TestBasicPaths() { URI uri = fc.GetDefaultFileSystem().GetUri(); Assert.Equal(chrootedTo.ToUri(), uri); Assert.Equal(fc.MakeQualified(new Path(Runtime.GetProperty("user.home" ))), fc.GetWorkingDirectory()); Assert.Equal(fc.MakeQualified(new Path(Runtime.GetProperty("user.home" ))), fc.GetHomeDirectory()); /* * ChRootedFs as its uri like file:///chrootRoot. * This is questionable since path.makequalified(uri, path) ignores * the pathPart of a uri. So our notion of chrooted URI is questionable. * But if we were to fix Path#makeQualified() then the next test should * have been: * * Assert.assertEquals( * new Path(chrootedTo + "/foo/bar").makeQualified( * FsConstants.LOCAL_FS_URI, null), * fc.makeQualified(new Path( "/foo/bar"))); */ Assert.Equal(new Path("/foo/bar").MakeQualified(FsConstants.LocalFsUri , null), fc.MakeQualified(new Path("/foo/bar"))); }
/* * return the ViewFS File context to be used for tests */ /// <exception cref="System.Exception"/> public static FileContext SetupForViewFsLocalFs(FileContextTestHelper helper) { FileContext fsTarget = FileContext.GetLocalFSFileContext(); Path targetOfTests = helper.GetTestRootPath(fsTarget); // In case previous test was killed before cleanup fsTarget.Delete(targetOfTests, true); fsTarget.Mkdir(targetOfTests, FileContext.DefaultPerm, true); Configuration conf = new Configuration(); // Set up viewfs link for test dir as described above string testDir = helper.GetTestRootPath(fsTarget).ToUri().GetPath(); LinkUpFirstComponents(conf, testDir, fsTarget, "test dir"); // Set up viewfs link for home dir as described above SetUpHomeDir(conf, fsTarget); // the test path may be relative to working dir - we need to make that work: // Set up viewfs link for wd as described above string wdDir = fsTarget.GetWorkingDirectory().ToUri().GetPath(); LinkUpFirstComponents(conf, wdDir, fsTarget, "working dir"); FileContext fc = FileContext.GetFileContext(FsConstants.ViewfsUri, conf); fc.SetWorkingDirectory(new Path(wdDir)); // in case testdir relative to wd. Org.Mortbay.Log.Log.Info("Working dir is: " + fc.GetWorkingDirectory()); //System.out.println("SRCOfTests = "+ getTestRootPath(fc, "test")); //System.out.println("TargetOfTests = "+ targetOfTests.toUri()); return(fc); }
/// <exception cref="System.IO.IOException"/> /// <exception cref="System.Exception"/> public override void StartLocalizer(Path nmPrivateContainerTokensPath, IPEndPoint nmAddr, string user, string appId, string locId, LocalDirsHandlerService dirsHandler ) { lock (this) { IList <string> localDirs = dirsHandler.GetLocalDirs(); IList <string> logDirs = dirsHandler.GetLogDirs(); ContainerLocalizer localizer = new ContainerLocalizer(lfs, user, appId, locId, GetPaths (localDirs), RecordFactoryProvider.GetRecordFactory(GetConf())); CreateUserLocalDirs(localDirs, user); CreateUserCacheDirs(localDirs, user); CreateAppDirs(localDirs, user, appId); CreateAppLogDirs(appId, logDirs, user); // randomly choose the local directory Path appStorageDir = GetWorkingDir(localDirs, user, appId); string tokenFn = string.Format(ContainerLocalizer.TokenFileNameFmt, locId); Path tokenDst = new Path(appStorageDir, tokenFn); CopyFile(nmPrivateContainerTokensPath, tokenDst, user); Log.Info("Copying from " + nmPrivateContainerTokensPath + " to " + tokenDst); lfs.SetWorkingDirectory(appStorageDir); Log.Info("CWD set to " + appStorageDir + " = " + lfs.GetWorkingDirectory()); // TODO: DO it over RPC for maintaining similarity? localizer.RunLocalization(nmAddr); } }
public virtual void TestBasicPaths() { Assert.Equal(FsConstants.ViewfsUri, fcView.GetDefaultFileSystem ().GetUri()); Assert.Equal(fcView.MakeQualified(new Path("/user/" + Runtime. GetProperty("user.name"))), fcView.GetWorkingDirectory()); Assert.Equal(fcView.MakeQualified(new Path("/user/" + Runtime. GetProperty("user.name"))), fcView.GetHomeDirectory()); Assert.Equal(new Path("/foo/bar").MakeQualified(FsConstants.ViewfsUri , null), fcView.MakeQualified(new Path("/foo/bar"))); }
// the getAbsolutexxx method is needed because the root test dir // can be messed up by changing the working dir. public string GetAbsoluteTestRootDir(FileContext fc) { if (absTestRootDir == null) { if (new Path(testRootDir).IsAbsolute()) { absTestRootDir = testRootDir; } else { absTestRootDir = fc.GetWorkingDirectory().ToString() + "/" + testRootDir; } } return(absTestRootDir); }
public Path GetDefaultWorkingDirectory(FileContext fc) { return(GetTestRootPath(fc, "/user/" + Runtime.GetProperty("user.name")).MakeQualified (fc.GetDefaultFileSystem().GetUri(), fc.GetWorkingDirectory())); }