protected Path getDefaultWorkingDirectory() throws IOException { return getTestRootPath(fc, "/user/" + System.getProperty("user.name")).makeQualified( fc.getDefaultFileSystem().getUri(), fc.getWorkingDirectory()); }
@Override public void setup() { try { fileContext = FileContextUtils.getFileContext(filePath); if (maxLength == 0) { maxLength = fileContext.getDefaultFileSystem().getServerDefaults().getBlockSize(); } fileSystemWALWriter.recover(); } catch (IOException e) { throw new RuntimeException("during setup", e); } }
public void testFilteringWithNonrequiredAuthority() throws Exception { Configuration conf = new Configuration(); ConfigUtil.addLink(conf, "custom", "/mnt", URI.create("file:///")); FileContext fc = FileContext.getFileContext(URI.create("viewfs://custom/"), conf); new FilterFs(fc.getDefaultFileSystem()) {}; }
private LocalResource createApplicationResource(FileContext fs, Path p, LocalResourceType type) throws IOException { LocalResource rsrc = Records.newRecord(LocalResource.class); FileStatus rsrcStat = fs.getFileStatus(p); rsrc.setResource(ConverterUtils.getYarnUrlFromPath(fs .getDefaultFileSystem().resolvePath(rsrcStat.getPath()))); rsrc.setSize(rsrcStat.getLen()); rsrc.setTimestamp(rsrcStat.getModificationTime()); rsrc.setType(type); rsrc.setVisibility(LocalResourceVisibility.APPLICATION); return rsrc; }
private LocalResource createApplicationResource(FileContext fs, Path p, LocalResourceType type) throws IOException { LocalResource rsrc = recordFactory.newRecordInstance(LocalResource.class); FileStatus rsrcStat = fs.getFileStatus(p); rsrc.setResource(ConverterUtils.getYarnUrlFromPath(fs .getDefaultFileSystem().resolvePath(rsrcStat.getPath()))); rsrc.setSize(rsrcStat.getLen()); rsrc.setTimestamp(rsrcStat.getModificationTime()); rsrc.setType(type); rsrc.setVisibility(LocalResourceVisibility.APPLICATION); return rsrc; }
@Test(expected=FileNotFoundException.class) public void testResolvePathNonExisting() throws IOException { fc.getDefaultFileSystem().resolvePath(new Path("/nonExisting")); }
protected Path getDefaultWorkingDirectory() throws IOException { return getTestRootPath(fc, "/user/" + System.getProperty("user.name")).makeQualified( fc.getDefaultFileSystem().getUri(), fc.getWorkingDirectory()); }
public Path getDefaultWorkingDirectory() throws IOException { return getTestRootPath("/user/" + System.getProperty("user.name")) .makeQualified(fc.getDefaultFileSystem().getUri(), fc.getWorkingDirectory()); }
public Path getDefaultWorkingDirectory() throws IOException { return getTestRootPath("/user/" + System.getProperty("user.name")) .makeQualified(fc.getDefaultFileSystem().getUri(), fc.getWorkingDirectory()); }
@Test public void testResolvePath() throws IOException { Assert.assertEquals(chrootedTo, fc.getDefaultFileSystem().resolvePath(new Path("/"))); fileContextTestHelper.createFile(fc, "/foo"); Assert.assertEquals(new Path(chrootedTo, "foo"), fc.getDefaultFileSystem().resolvePath(new Path("/foo"))); }
@Test public void testIsValidNameValidInBaseFs() throws Exception { AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem()); ChRootedFs chRootedFs = new ChRootedFs(baseFs, new Path("/chroot")); Mockito.doReturn(true).when(baseFs).isValidName(Mockito.anyString()); Assert.assertTrue(chRootedFs.isValidName("/test")); Mockito.verify(baseFs).isValidName("/chroot/test"); }
@Test public void testResolvePath() throws IOException { Assert.assertEquals(chrootedTo, fc.getDefaultFileSystem().resolvePath(new Path("/"))); fileContextTestHelper.createFile(fc, "/foo"); Assert.assertEquals(new Path(chrootedTo, "foo"), fc.getDefaultFileSystem().resolvePath(new Path("/foo"))); }
public Path getDefaultWorkingDirectory(FileContext fc) { return getTestRootPath(fc, "/user/" + System.getProperty("user.name")) .makeQualified(fc.getDefaultFileSystem().getUri(), fc.getWorkingDirectory()); }
@Test public void testIsValidNameInvalidInBaseFs() throws Exception { AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem()); ChRootedFs chRootedFs = new ChRootedFs(baseFs, new Path("/chroot")); Mockito.doReturn(false).when(baseFs).isValidName(Mockito.anyString()); Assert.assertFalse(chRootedFs.isValidName("/test")); Mockito.verify(baseFs).isValidName("/chroot/test"); } }
@Test public void testIsValidNameInvalidInBaseFs() throws Exception { AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem()); ChRootedFs chRootedFs = new ChRootedFs(baseFs, new Path("/chroot")); Mockito.doReturn(false).when(baseFs).isValidName(Mockito.anyString()); Assert.assertFalse(chRootedFs.isValidName("/test")); Mockito.verify(baseFs).isValidName("/chroot/test"); } }
@Test public void testGetMountPoints() { ViewFs viewfs = (ViewFs) fcView.getDefaultFileSystem(); MountPoint[] mountPoints = viewfs.getMountPoints(); Assert.assertEquals(8, mountPoints.length); }
@Test public void testIsValidNameInvalidNames() { String[] invalidNames = { "/foo/../bar", "/foo/./bar", "/foo/:/bar", "/foo:bar" }; for (String invalidName: invalidNames) { Assert.assertFalse(invalidName + " is not valid", fc.getDefaultFileSystem().isValidName(invalidName)); } }
@Test public void testBasicPaths() { Assert.assertEquals(FsConstants.VIEWFS_URI, fcView.getDefaultFileSystem().getUri()); Assert.assertEquals(fcView.makeQualified( new Path("/user/" + System.getProperty("user.name"))), fcView.getWorkingDirectory()); Assert.assertEquals(fcView.makeQualified( new Path("/user/" + System.getProperty("user.name"))), fcView.getHomeDirectory()); Assert.assertEquals( new Path("/foo/bar").makeQualified(FsConstants.VIEWFS_URI, null), fcView.makeQualified(new Path("/foo/bar"))); }
@Test public void ensureAzureBlobFileSystemIsDefaultFileSystem() throws Exception { Configuration rawConfig = getRawConfiguration(); AzureBlobFileSystem fs = (AzureBlobFileSystem) FileSystem.get(rawConfig); assertNotNull("filesystem", fs); if (this.getAuthType() == AuthType.OAuth) { Abfss afs = (Abfss) FileContext.getFileContext(rawConfig).getDefaultFileSystem(); assertNotNull("filecontext", afs); } else { Abfs afs = (Abfs) FileContext.getFileContext(rawConfig).getDefaultFileSystem(); assertNotNull("filecontext", afs); } }
@Before public void setUp() throws Exception { // create the test root on local_fs fcTarget = FileContext.getLocalFSFileContext(); chrootedTo = fileContextTestHelper.getAbsoluteTestRootPath(fcTarget); // In case previous test was killed before cleanup fcTarget.delete(chrootedTo, true); fcTarget.mkdir(chrootedTo, FileContext.DEFAULT_PERM, true); Configuration conf = new Configuration(); // ChRoot to the root of the testDirectory fc = FileContext.getFileContext( new ChRootedFs(fcTarget.getDefaultFileSystem(), chrootedTo), conf); }